From b57c9212bfb2235405e318dfb136ce4b96e6702c Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Mon, 9 Sep 2024 21:59:07 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=BF=BB=E8=AF=91=E4=B8=BA=E5=8D=95=E4=BE=8B=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/trans-strategy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/trans-strategy.js b/utils/trans-strategy.js index 81294a9..aa4ac9f 100644 --- a/utils/trans-strategy.js +++ b/utils/trans-strategy.js @@ -118,7 +118,7 @@ class DeeplTranslateStrategy extends TranslateStrategy { export default class Translate { constructor(config) { this.config = config; - this.strategy = this.selectStrategy(); + this.strategy = null; } selectStrategy() { @@ -133,7 +133,7 @@ export default class Translate { async translate(query, targetLanguage) { if (!this.strategy) { - throw new Error("无翻译策略可用"); + this.strategy = this.selectStrategy(); } return this.strategy.translate(query, targetLanguage); }