From aa2f2439d66d10d46ae89084d9e806fc84bae494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=94=A6=E9=BA=9F=20=E7=8E=8B?= Date: Fri, 6 Feb 2026 09:48:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=87=8D=E6=9E=84=E4=B8=BB=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E9=80=BB=E8=BE=91=EF=BC=8C=E5=88=86=E7=A6=BB=E6=8C=82?= =?UTF-8?q?=E8=BD=BD=E6=93=8D=E4=BD=9C=E5=88=B0=20main.js=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=AD=E6=96=87=E8=AF=AD=E8=A8=80=E5=8C=85?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/minenasai/webtui/static/webui/index.html | 8 +++++--- src/minenasai/webtui/static/webui/js/app.js | 19 +++++++++++++++---- src/minenasai/webtui/static/webui/js/main.js | 13 +++++++++++++ 3 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 src/minenasai/webtui/static/webui/js/main.js diff --git a/src/minenasai/webtui/static/webui/index.html b/src/minenasai/webtui/static/webui/index.html index 54f5828..7255bb1 100644 --- a/src/minenasai/webtui/static/webui/index.html +++ b/src/minenasai/webtui/static/webui/index.html @@ -126,7 +126,9 @@ - + + + @@ -135,7 +137,7 @@ - - + + diff --git a/src/minenasai/webtui/static/webui/js/app.js b/src/minenasai/webtui/static/webui/js/app.js index c60aa38..7d18419 100644 --- a/src/minenasai/webtui/static/webui/js/app.js +++ b/src/minenasai/webtui/static/webui/js/app.js @@ -7,6 +7,18 @@ const { createApp, ref, reactive, computed, onMounted, watch } = Vue; // API 基础路径 const API_BASE = '/api'; +// 全局 app 变量,供组件注册使用 +var app = null; + +// 获取 Element Plus 中文语言包(兼容不同变量名) +const zhCnLocale = (function() { + if (typeof ElementPlusLocaleZhCn !== 'undefined') return ElementPlusLocaleZhCn; + if (typeof ELEMENT_PLUS_LOCALE_ZH_CN !== 'undefined') return ELEMENT_PLUS_LOCALE_ZH_CN; + // 如果都没有,返回 undefined,Element Plus 会使用默认英文 + console.warn('Element Plus 中文语言包未加载'); + return undefined; +})(); + // API 请求封装 const api = { async get(url) { @@ -40,7 +52,7 @@ const api = { }; // 创建 Vue 应用 -const app = createApp({ +app = createApp({ setup() { // 状态 const isCollapsed = ref(false); @@ -230,7 +242,7 @@ const app = createApp({ saveLLMConfig, saveChannelsConfig, saveProxyConfig, - zhCn: ElementPlusLocaleZhCn + zhCn: zhCnLocale }; } }); @@ -243,5 +255,4 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) { // 使用 Element Plus app.use(ElementPlus); -// 挂载应用 -app.mount('#app'); +// 注意:挂载操作在 main.js 中进行,确保组件先注册 diff --git a/src/minenasai/webtui/static/webui/js/main.js b/src/minenasai/webtui/static/webui/js/main.js new file mode 100644 index 0000000..35eef87 --- /dev/null +++ b/src/minenasai/webtui/static/webui/js/main.js @@ -0,0 +1,13 @@ +/** + * MineNASAI WebUI 入口文件 + * 在所有组件注册完成后挂载应用 + */ + +// 确保 app 存在 +if (typeof app !== 'undefined' && app) { + // 挂载应用 + app.mount('#app'); + console.log('MineNASAI WebUI 已启动'); +} else { + console.error('Vue 应用初始化失败,请检查控制台错误'); +}