mirror of
https://github.com/octopusYan/dayz-mod-translator.git
synced 2025-12-08 17:21:57 +08:00
Compare commits
3 Commits
5214485a36
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| a4ff07ce7b | |||
| 3ed4979aa9 | |||
| 16aa917d09 |
@ -1,7 +1,7 @@
|
||||
package cn.octopusyan.dmt.common.manager.http;
|
||||
|
||||
import cn.octopusyan.dmt.common.enums.ProxySetup;
|
||||
import cn.octopusyan.dmt.common.manager.http.response.BodyHandler;
|
||||
import cn.octopusyan.dmt.common.manager.http.response.DownloadBodyHandler;
|
||||
import cn.octopusyan.dmt.common.util.JsonUtil;
|
||||
import cn.octopusyan.dmt.model.ProxyInfo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@ -130,7 +130,7 @@ public class HttpUtil {
|
||||
}
|
||||
|
||||
// 下载处理器
|
||||
var handler = BodyHandler.create(
|
||||
var handler = DownloadBodyHandler.create(
|
||||
Path.of(savePath),
|
||||
StandardOpenOption.CREATE, StandardOpenOption.WRITE
|
||||
);
|
||||
|
||||
@ -21,16 +21,16 @@ import java.util.function.Consumer;
|
||||
* @author octopus_yan
|
||||
*/
|
||||
@Slf4j
|
||||
public class BodyHandler implements HttpResponse.BodyHandler<Path> {
|
||||
public class DownloadBodyHandler implements HttpResponse.BodyHandler<Path> {
|
||||
private final HttpResponse.BodyHandler<Path> handler;
|
||||
private BiConsumer<Long, Long> consumer;
|
||||
|
||||
private BodyHandler(HttpResponse.BodyHandler<Path> handler) {
|
||||
private DownloadBodyHandler(HttpResponse.BodyHandler<Path> handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public static BodyHandler create(Path directory, OpenOption... openOptions) {
|
||||
return new BodyHandler(HttpResponse.BodyHandlers.ofFileDownload(directory, openOptions));
|
||||
public static DownloadBodyHandler create(Path directory, OpenOption... openOptions) {
|
||||
return new DownloadBodyHandler(HttpResponse.BodyHandlers.ofFileDownload(directory, openOptions));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -89,6 +89,9 @@ public class MainController extends BaseController<MainViewModel> {
|
||||
fileChooser.getExtensionFilters().add(extFilter);
|
||||
}
|
||||
|
||||
private File historySelectFolder;
|
||||
private File historySaveFolder;
|
||||
|
||||
@Override
|
||||
public Pane getRootPanel() {
|
||||
return root;
|
||||
@ -150,6 +153,8 @@ public class MainController extends BaseController<MainViewModel> {
|
||||
* 打开文件选择器
|
||||
*/
|
||||
public void selectFile() {
|
||||
if (historySelectFolder != null)
|
||||
fileChooser.setInitialDirectory(historySelectFolder);
|
||||
selectFile(fileChooser.showOpenDialog(getWindow()));
|
||||
}
|
||||
|
||||
@ -247,11 +252,15 @@ public class MainController extends BaseController<MainViewModel> {
|
||||
public void onPackOver(File packFile) {
|
||||
// 选择文件保存地址
|
||||
fileChooser.setInitialFileName(packFile.getName());
|
||||
if (historySaveFolder != null)
|
||||
fileChooser.setInitialDirectory(historySaveFolder);
|
||||
File file = fileChooser.showSaveDialog(getWindow());
|
||||
|
||||
if (file == null)
|
||||
return;
|
||||
|
||||
historySaveFolder = file.getParentFile();
|
||||
|
||||
if (file.exists()) {
|
||||
//文件已存在,则删除覆盖文件
|
||||
FileUtils.deleteQuietly(file);
|
||||
@ -322,6 +331,10 @@ public class MainController extends BaseController<MainViewModel> {
|
||||
* 打开文件
|
||||
*/
|
||||
private void selectFile(File file) {
|
||||
if (file != null) {
|
||||
// 设置选择文件记录
|
||||
historySelectFolder = file.getParentFile();
|
||||
}
|
||||
viewModel.selectFile(file);
|
||||
viewModel.unpack();
|
||||
}
|
||||
|
||||
@ -37,11 +37,6 @@ public class FreeBaiduTranslateProcessor extends AbstractTranslateProcessor {
|
||||
return "https://fanyi.baidu.com/transapi";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int qps() {
|
||||
return source().getDefaultQps();
|
||||
}
|
||||
|
||||
/**
|
||||
* 翻译处理
|
||||
*
|
||||
|
||||
@ -25,11 +25,6 @@ public class FreeGoogleTranslateProcessor extends AbstractTranslateProcessor {
|
||||
return "https://translate.googleapis.com/translate_a/single";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int qps() {
|
||||
return source().getDefaultQps();
|
||||
}
|
||||
|
||||
/**
|
||||
* 翻译处理
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user