From c6f0268ff5a18babe7f1e57cc353ebc8c3021a1a Mon Sep 17 00:00:00 2001 From: octopus_yan Date: Fri, 22 Nov 2024 00:01:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=88=90=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E5=86=8D=E6=AC=A1=E5=8A=A0=E8=BD=BDpbo=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E6=97=A0=E6=B3=95=E5=BC=80=E5=A7=8B=E7=BF=BB=E8=AF=91?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/cn/octopusyan/dmt/utils/PBOUtil.java | 2 +- .../java/cn/octopusyan/dmt/viewModel/MainViewModel.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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()) {