From 5bca72e46f7f2d0b4dcb1d71cc8476742c9ced77 Mon Sep 17 00:00:00 2001 From: kjqwer <2990346238@qq.com> Date: Tue, 11 Nov 2025 08:29:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8C=85=E8=A3=B9=E4=B8=8D?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/promptStore.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/stores/promptStore.ts b/src/stores/promptStore.ts index b1f8b1c..dc959bc 100644 --- a/src/stores/promptStore.ts +++ b/src/stores/promptStore.ts @@ -353,9 +353,13 @@ export const usePromptStore = defineStore('promptStore', { return null; }, getTranslation(key: string, lang: LangCode): string | null { - const tag = this.getTagByKey(key); + // 兼容包裹层:如 {aaa}、(aaa) 等 + const { core, wrappers } = this.parseTokenWrappers(key); + const tag = this.getTagByKey(core); if (!tag) return null; - return tag.translation?.[lang] ?? tag.key; + const translatedCore = tag.translation?.[lang] ?? tag.key; + // 保持原有包裹层结构,返回被翻译后的核心 + return this.wrapToken(translatedCore, wrappers); }, getSuggestions(prefix: string, limit = 8): string[] { const list: string[] = [];