diff --git a/dashboard/src/i18n/composables.ts b/dashboard/src/i18n/composables.ts index 3d569ef3e..69e6c4bb3 100644 --- a/dashboard/src/i18n/composables.ts +++ b/dashboard/src/i18n/composables.ts @@ -57,13 +57,15 @@ export function useI18n() { value = value[k]; } else { console.warn(`Translation key not found: ${key}`); - return key; // 返回键名作为回退 + // 返回带括号的键名,便于在开发时识别缺失的翻译 + return `[MISSING: ${key}]`; } } if (typeof value !== 'string') { - console.warn(`Translation value is not string: ${key}`); - return key; + console.warn(`Translation value is not string: ${key}`, value); + // 返回带括号的键名,便于在开发时识别类型错误的翻译 + return `[INVALID: ${key}]`; } // 此时value确定是string类型 diff --git a/dashboard/src/i18n/loader.ts b/dashboard/src/i18n/loader.ts index 743603129..c9632e8cb 100644 --- a/dashboard/src/i18n/loader.ts +++ b/dashboard/src/i18n/loader.ts @@ -127,70 +127,45 @@ export class I18nLoader { } } + /** + * 通用模块加载器 - 减少重复代码,提高可维护性 + */ + private async loadModules( + locale: string, + prefix: string, + overrideList: string[] = [] + ): Promise { + // 使用覆盖列表或从注册表中筛选符合前缀的模块名 + const moduleNames = overrideList.length > 0 + ? overrideList + : Array.from(this.moduleRegistry.keys()).filter(key => key.startsWith(prefix)); + + const results = await Promise.all( + moduleNames.map(module => this.loadModule(locale, module)) + ); + + return this.mergeModules(results, moduleNames); + } + /** * 加载核心模块(最高优先级) */ async loadCoreModules(locale: string): Promise { - const coreModules = [ - 'core/common', - 'core/actions', - 'core/status', - 'core/navigation', - 'core/header' - ]; - - const results = await Promise.all( - coreModules.map(module => this.loadModule(locale, module)) - ); - - return this.mergeModules(results, coreModules); + return this.loadModules(locale, 'core'); } /** * 加载功能模块 */ async loadFeatureModules(locale: string, features?: string[]): Promise { - const featureModules = features || [ - 'features/chat', - 'features/extension', - 'features/conversation', - 'features/tooluse', - 'features/provider', - 'features/platform', - 'features/config', - 'features/console', - 'features/about', - 'features/settings', - 'features/auth', - 'features/chart', - 'features/dashboard', - 'features/alkaid/index', - 'features/alkaid/knowledge-base', - 'features/alkaid/memory' - ]; - - const results = await Promise.all( - featureModules.map(module => this.loadModule(locale, module)) - ); - - return this.mergeModules(results, featureModules); + return this.loadModules(locale, 'features', features || []); } /** * 加载消息模块 */ async loadMessageModules(locale: string): Promise { - const messageModules = [ - 'messages/errors', - 'messages/success', - 'messages/validation' - ]; - - const results = await Promise.all( - messageModules.map(module => this.loadModule(locale, module)) - ); - - return this.mergeModules(results, messageModules); + return this.loadModules(locale, 'messages'); } /** diff --git a/dashboard/src/views/ChatPage.vue b/dashboard/src/views/ChatPage.vue index 345b16183..ec2bb9512 100644 --- a/dashboard/src/views/ChatPage.vue +++ b/dashboard/src/views/ChatPage.vue @@ -594,7 +594,25 @@ export default { console.log(line) // data: {"type": "plain", "data": "helloworld"} - let chunk_json = JSON.parse(line.replace('data: ', '')); + let chunk_json; + try { + chunk_json = JSON.parse(line.replace('data: ', '')); + } catch (parseError) { + console.warn('JSON解析失败:', line, parseError); + continue; + } + + // 检查解析后的数据是否有效 + if (!chunk_json || typeof chunk_json !== 'object') { + console.warn('无效的数据对象:', chunk_json); + continue; + } + + // 检查是否有type字段 + if (!chunk_json.hasOwnProperty('type')) { + console.warn('数据缺少type字段:', chunk_json); + continue; + } if (chunk_json.type === 'heartbeat') { continue; // 心跳包 diff --git a/dashboard/src/views/ExtensionPage.vue b/dashboard/src/views/ExtensionPage.vue index 89aefc55e..28743cf4f 100644 --- a/dashboard/src/views/ExtensionPage.vue +++ b/dashboard/src/views/ExtensionPage.vue @@ -568,8 +568,10 @@ onMounted(async () => { -
- + +
+ + mdi-puzzle {{ tm('tabs.installed') }} @@ -580,20 +582,40 @@ onMounted(async () => { - - - - + + + + + + + + +
- + @@ -605,13 +627,14 @@ onMounted(async () => { - + {{ showReserved ? tm('buttons.hideSystemPlugins') : tm('buttons.showSystemPlugins') }} - + {{ tm('buttons.platformConfig') }}