-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
修改subHD下载的压缩文件保存出错问题。(javafx的webview的js绑定不稳定,去掉一部分)
- Loading branch information
Showing
10 changed files
with
215 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/main/java/zimu/server/controllers/ExtractApiController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package zimu.server.controllers; | ||
|
||
import java.io.File; | ||
|
||
import com.hibegin.http.server.api.HttpRequest; | ||
import com.hibegin.http.server.api.HttpResponse; | ||
|
||
import cn.hutool.core.util.ArrayUtil; | ||
import cn.hutool.json.JSONArray; | ||
import cn.hutool.json.JSONObject; | ||
import cn.hutool.json.JSONUtil; | ||
import cn.hutool.log.Log; | ||
import cn.hutool.log.LogFactory; | ||
import zimu.AppConfig; | ||
import zimu.gui.ExtractDialog; | ||
import zimu.util.StringUtil; | ||
/* | ||
* 解压文件接口 | ||
*/ | ||
public class ExtractApiController extends Base { | ||
static final Log logger = LogFactory.get(); | ||
|
||
/** | ||
* 获取初始化数据 | ||
*/ | ||
public void get_init_data() { | ||
JSONObject resp = new JSONObject(); | ||
JSONArray list = new JSONArray(); | ||
for (int i = 0; i < ExtractDialog.extractDialog.archiveFiles.size(); i++) { | ||
File file = ExtractDialog.extractDialog.archiveFiles.get(i); | ||
String title = file.getName(); | ||
|
||
if(!ArrayUtil.contains(AppConfig.subExtNames, StringUtil.extName(file).toLowerCase())){ | ||
continue; | ||
} | ||
|
||
String key = title; | ||
JSONObject row = new JSONObject(); | ||
row.put("key", key); | ||
row.put("title", title); | ||
row.put("size", file.length()); | ||
row.put("sizeF", StringUtil.getPrintSize(file.length())); | ||
|
||
list.add(row); | ||
} | ||
resp.put("list", list); | ||
resp.put("title", ExtractDialog.extractDialog.title); | ||
resp.put("archiveExt", ExtractDialog.extractDialog.archiveExt); | ||
resp.put("archiveSize", ExtractDialog.extractDialog.archiveData.length); | ||
resp.put("archiveSizeF", StringUtil.getPrintSize(ExtractDialog.extractDialog.archiveData.length)); | ||
|
||
outJsonpMessage(request,response, 0, "OK", resp); | ||
} | ||
/** | ||
* 下载压缩文件中的字幕 | ||
* @param data | ||
* @return | ||
*/ | ||
public void down_archive_file() { | ||
HttpRequest request = getRequest(); | ||
HttpResponse response = getResponse(); | ||
String data = request.getParaToStr("data"); | ||
if(data == null) { | ||
outJsonpMessage(request,response, 1, "请求数据错误"); | ||
return; | ||
} | ||
logger.info("data="+data); | ||
if(data == null || data.length() < 10) { | ||
logger.error("data=null"); | ||
outJsonpMessage(request,response, 1, "参数错误"); | ||
return; | ||
} | ||
JSONObject dataJson = JSONUtil.parseObj(data); | ||
JSONArray items = dataJson.getJSONArray("items"); | ||
if(items == null || items.size() == 0) { | ||
logger.error("items=null"); | ||
outJsonpMessage(request,response, 1, "参数错误"); | ||
return; | ||
} | ||
|
||
JSONObject resp = new JSONObject(); | ||
resp.put("saveSelected", ExtractDialog.extractDialog.saveSelected(items)); | ||
outJsonpMessage(request,response, 0, "OK", resp); | ||
} | ||
} |
Oops, something went wrong.