From e911896cfb658f03d0b3e01f2fcd1990c816bc28 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Mon, 18 Aug 2025 11:27:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=9F=A5=E8=AF=86?= =?UTF-8?q?=E5=BA=93=E6=8F=92=E4=BB=B6=E6=9B=B4=E6=96=B0=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E5=92=8C=E6=9B=B4=E6=96=B0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../en-US/features/alkaid/knowledge-base.json | 26 +++--- .../zh-CN/features/alkaid/knowledge-base.json | 26 +++--- dashboard/src/views/ExtensionPage.vue | 12 ++- dashboard/src/views/alkaid/KnowledgeBase.vue | 81 +++++++++++++++++++ 4 files changed, 112 insertions(+), 33 deletions(-) diff --git a/dashboard/src/i18n/locales/en-US/features/alkaid/knowledge-base.json b/dashboard/src/i18n/locales/en-US/features/alkaid/knowledge-base.json index c985229a..48e5a354 100644 --- a/dashboard/src/i18n/locales/en-US/features/alkaid/knowledge-base.json +++ b/dashboard/src/i18n/locales/en-US/features/alkaid/knowledge-base.json @@ -1,21 +1,6 @@ { "title": "Knowledge Base", "subtitle": "Manage and query knowledge base content", - "upload": { - "title": "Upload Documents", - "selectFiles": "Select Files", - "supportedFormats": "Supported Formats", - "dragDrop": "Drag files here", - "processing": "Processing...", - "success": "Upload Successful", - "error": "Upload Failed" - }, - "search": { - "placeholder": "Search knowledge base...", - "results": "Search Results", - "noResults": "No relevant content found", - "searching": "Searching..." - }, "documents": { "title": "Document List", "name": "Document Name", @@ -42,6 +27,8 @@ "title": "Knowledge Base List", "create": "Create Knowledge Base", "config": "Configure", + "checkUpdate": "Check Plugin Update", + "updatePlugin": "Update Plugin to {version}", "knowledgeCount": "knowledge items", "tips": "Tips: Learn how to use through /kb command in chat page!" }, @@ -132,7 +119,14 @@ "knowledgeBaseDeleted": "Knowledge base deleted successfully", "deleteFailed": "Deletion failed", "deleteKnowledgeBaseFailed": "Failed to delete knowledge base", - "getEmbeddingModelListFailed": "Failed to get embedding model list" + "getEmbeddingModelListFailed": "Failed to get embedding model list", + "updateAvailable": "New version available: {current} -> {latest}", + "pluginUpToDate": "Plugin is up to date", + "pluginNotFoundInMarket": "Plugin not found in market", + "checkUpdateFailed": "Failed to check for updates", + "updateSuccess": "Plugin updated successfully", + "updateFailed": "Update failed", + "updatePluginFailed": "Failed to update plugin" }, "importFromUrl": { "title": "Import from URL", diff --git a/dashboard/src/i18n/locales/zh-CN/features/alkaid/knowledge-base.json b/dashboard/src/i18n/locales/zh-CN/features/alkaid/knowledge-base.json index 2e1c8c81..f435b39e 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/alkaid/knowledge-base.json +++ b/dashboard/src/i18n/locales/zh-CN/features/alkaid/knowledge-base.json @@ -1,21 +1,6 @@ { "title": "知识库", "subtitle": "管理和查询知识库内容", - "upload": { - "title": "上传文档", - "selectFiles": "选择文件", - "supportedFormats": "支持的格式", - "dragDrop": "拖拽文件到此处", - "processing": "处理中...", - "success": "上传成功", - "error": "上传失败" - }, - "search": { - "placeholder": "搜索知识库...", - "results": "搜索结果", - "noResults": "未找到相关内容", - "searching": "搜索中..." - }, "documents": { "title": "文档列表", "name": "文档名称", @@ -42,6 +27,8 @@ "title": "知识库列表", "create": "创建知识库", "config": "配置", + "checkUpdate": "检查插件更新", + "updatePlugin": "更新插件到 {version}", "knowledgeCount": "条知识", "tips": "Tips: 在聊天页面通过 /kb 指令了解如何使用!" }, @@ -132,7 +119,14 @@ "knowledgeBaseDeleted": "知识库删除成功", "deleteFailed": "删除失败", "deleteKnowledgeBaseFailed": "删除知识库失败", - "getEmbeddingModelListFailed": "获取嵌入模型列表失败" + "getEmbeddingModelListFailed": "获取嵌入模型列表失败", + "updateAvailable": "发现新版本: {current} -> {latest}", + "pluginUpToDate": "插件已是最新版本", + "pluginNotFoundInMarket": "在插件市场中未找到该插件", + "checkUpdateFailed": "检查更新失败", + "updateSuccess": "插件更新成功", + "updateFailed": "更新失败", + "updatePluginFailed": "更新插件失败" }, "importFromUrl": { "title": "从 URL 导入", diff --git a/dashboard/src/views/ExtensionPage.vue b/dashboard/src/views/ExtensionPage.vue index 9d159990..2c06e6ec 100644 --- a/dashboard/src/views/ExtensionPage.vue +++ b/dashboard/src/views/ExtensionPage.vue @@ -585,9 +585,19 @@ onMounted(async () => { await getExtensions(); // 检查是否有 open_config 参数 - const urlParams = new URLSearchParams(window.location.search); + let urlParams; + if (window.location.hash) { + // For hash mode (#/path?param=value) + const hashQuery = window.location.hash.split('?')[1] || ''; + urlParams = new URLSearchParams(hashQuery); + } else { + // For history mode (/path?param=value) + urlParams = new URLSearchParams(window.location.search); + } + console.log("URL Parameters:", urlParams.toString()); const plugin_name = urlParams.get('open_config'); if (plugin_name) { + console.log(`Opening config for plugin: ${plugin_name}`); openExtensionConfig(plugin_name); } diff --git a/dashboard/src/views/alkaid/KnowledgeBase.vue b/dashboard/src/views/alkaid/KnowledgeBase.vue index cf606e3a..93921f21 100644 --- a/dashboard/src/views/alkaid/KnowledgeBase.vue +++ b/dashboard/src/views/alkaid/KnowledgeBase.vue @@ -36,6 +36,14 @@ @click="$router.push('/extension?open_config=astrbot_plugin_knowledge_base')"> {{ tm('list.config') }} + + {{ tm('list.checkUpdate') }} + + + {{ tm('list.updatePlugin', { version: pluginLatestVersion }) }} +
0) { this.installed = true; + this.pluginCurrentVersion = response.data.data[0].version || '未知'; this.getKBCollections(); + // 自动检查更新 + this.checkPluginUpdate(); } else { this.installed = false; } @@ -575,6 +592,70 @@ export default { }) }, + async checkPluginUpdate() { + this.checkingUpdate = true; + this.pluginHasUpdate = false; + try { + // 获取在线插件数据 + const onlineResponse = await axios.get('/api/plugin/market_list'); + if (onlineResponse.data.status === 'ok') { + const knowledgeBasePlugin = onlineResponse.data.data['astrbot_plugin_knowledge_base']; + if (knowledgeBasePlugin) { + this.pluginLatestVersion = knowledgeBasePlugin.version || '未知'; + + // 比较版本 + if (this.pluginCurrentVersion && this.pluginLatestVersion && + this.pluginCurrentVersion !== '未知' && this.pluginLatestVersion !== '未知') { + this.pluginHasUpdate = this.pluginCurrentVersion != this.pluginLatestVersion + } + + if (this.pluginHasUpdate) { + this.showSnackbar(this.tm('messages.updateAvailable', { + current: this.pluginCurrentVersion, + latest: this.pluginLatestVersion + }), 'info'); + } else { + this.showSnackbar(this.tm('messages.pluginUpToDate'), 'success'); + } + } else { + this.showSnackbar(this.tm('messages.pluginNotFoundInMarket'), 'warning'); + } + } else { + this.showSnackbar(this.tm('messages.checkUpdateFailed'), 'error'); + } + } catch (error) { + console.error('Error checking plugin update:', error); + this.showSnackbar(this.tm('messages.checkUpdateFailed'), 'error'); + } finally { + this.checkingUpdate = false; + } + }, + + async updatePlugin() { + this.updatingPlugin = true; + try { + const response = await axios.post('/api/plugin/update', { + name: 'astrbot_plugin_knowledge_base', + proxy: localStorage.getItem('selectedGitHubProxy') || "" + }); + + if (response.data.status === 'ok') { + this.showSnackbar(this.tm('messages.updateSuccess'), 'success'); + this.pluginHasUpdate = false; + this.pluginCurrentVersion = this.pluginLatestVersion; + // 刷新插件信息 + this.checkPlugin(); + } else { + this.showSnackbar(response.data.message || this.tm('messages.updateFailed'), 'error'); + } + } catch (error) { + console.error('Error updating plugin:', error); + this.showSnackbar(this.tm('messages.updatePluginFailed'), 'error'); + } finally { + this.updatingPlugin = false; + } + }, + installPlugin() { this.installing = true; axios.post('/api/plugin/install', {