mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 08:09:19 +00:00
🐞 fix: 修复翻译为单例模式
This commit is contained in:
parent
2fa0294311
commit
b57c9212bf
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user