diff --git a/src/main/java/cn/octopusyan/dmt/utils/PBOUtil.java b/src/main/java/cn/octopusyan/dmt/utils/PBOUtil.java index b6b1238..87ddb4b 100644 --- a/src/main/java/cn/octopusyan/dmt/utils/PBOUtil.java +++ b/src/main/java/cn/octopusyan/dmt/utils/PBOUtil.java @@ -518,7 +518,7 @@ public class PBOUtil { * @param str 需要判断的字符串 * @return 是否含有中文 */ - private static boolean containsChinese(String str) { + public static boolean containsChinese(String str) { return Pattern.compile("[\u4e00-\u9fa5]").matcher(str).find(); } } diff --git a/src/main/java/cn/octopusyan/dmt/viewModel/MainViewModel.java b/src/main/java/cn/octopusyan/dmt/viewModel/MainViewModel.java index c2259d8..da8f7b0 100644 --- a/src/main/java/cn/octopusyan/dmt/viewModel/MainViewModel.java +++ b/src/main/java/cn/octopusyan/dmt/viewModel/MainViewModel.java @@ -10,6 +10,7 @@ import cn.octopusyan.dmt.task.UnpackTask; import cn.octopusyan.dmt.task.listener.DefaultTaskListener; import cn.octopusyan.dmt.translate.DelayWord; import cn.octopusyan.dmt.translate.TranslateUtil; +import cn.octopusyan.dmt.utils.PBOUtil; import cn.octopusyan.dmt.view.ConsoleLog; import cn.octopusyan.dmt.view.alert.AlertUtil; import javafx.application.Platform; @@ -18,7 +19,6 @@ import javafx.beans.property.StringProperty; import javafx.collections.ObservableList; import javafx.concurrent.Worker; import javafx.scene.control.ProgressIndicator; -import org.apache.commons.lang3.StringUtils; import org.kordamp.ikonli.feather.Feather; import org.kordamp.ikonli.javafx.FontIcon; @@ -107,9 +107,11 @@ public class MainViewModel extends BaseViewModel { if (wordItems.isEmpty()) return; if (translateTask == null) { - List words = wordItems.stream().filter(item -> StringUtils.isEmpty(item.getChinese())).toList(); + List words = wordItems.stream().filter(item -> !PBOUtil.containsChinese(item.getChinese())).toList(); delayQueue = TranslateUtil.getDelayQueue(words); translateTask = createTask(); + translateTask.execute(); + return; } if (!translateTask.isRunning()) {