From aa61815fcd10899116d99687e095be67e2bf7d6f Mon Sep 17 00:00:00 2001 From: Ocetars Date: Wed, 3 Dec 2025 20:58:53 +0800 Subject: [PATCH] =?UTF-8?q?feat(extension):=20=E6=B7=BB=E5=8A=A0=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=8C=87=E4=BB=A4=E5=86=B2=E7=AA=81=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E4=B8=8E=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在插件安装或启用后,自动检测并提示指令冲突。 - 当检测到指令冲突时,显示警告对话框,告知用户冲突数量及可能的影响。 --- astrbot/core/star/command_management.py | 2 +- .../locales/en-US/features/extension.json | 6 ++ .../locales/zh-CN/features/extension.json | 6 ++ dashboard/src/views/ExtensionPage.vue | 65 ++++++++++++++++++- 4 files changed, 75 insertions(+), 4 deletions(-) diff --git a/astrbot/core/star/command_management.py b/astrbot/core/star/command_management.py index 72c88fd30..c823695b4 100644 --- a/astrbot/core/star/command_management.py +++ b/astrbot/core/star/command_management.py @@ -30,7 +30,7 @@ class CommandDescriptor: raw_command_name: str | None = None current_fragment: str | None = None parent_signature: str = "" - parent_group_handler: str = "" # 父指令组的 handler_full_name + parent_group_handler: str = "" original_command: str | None = None effective_command: str | None = None aliases: list[str] = field(default_factory=list) diff --git a/dashboard/src/i18n/locales/en-US/features/extension.json b/dashboard/src/i18n/locales/en-US/features/extension.json index b1ec35191..4a9884533 100644 --- a/dashboard/src/i18n/locales/en-US/features/extension.json +++ b/dashboard/src/i18n/locales/en-US/features/extension.json @@ -173,5 +173,11 @@ "errors": { "confirmNotRegistered": "$confirm not properly registered" } + }, + "conflicts": { + "title": "Command Conflicts Detected", + "message": "This may cause some commands to not work properly. It is recommended to go to Command Management to resolve.", + "pairs": "command conflicts", + "goToManage": "Go to Manage" } } diff --git a/dashboard/src/i18n/locales/zh-CN/features/extension.json b/dashboard/src/i18n/locales/zh-CN/features/extension.json index 4b7a8058f..b33922ae5 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/extension.json +++ b/dashboard/src/i18n/locales/zh-CN/features/extension.json @@ -173,5 +173,11 @@ "errors": { "confirmNotRegistered": "$confirm 未正确注册" } + }, + "conflicts": { + "title": "检测到指令冲突", + "message": "这可能导致部分指令无法正常工作,建议前往指令管理页面处理。", + "pairs": "对指令冲突", + "goToManage": "前往处理" } } diff --git a/dashboard/src/views/ExtensionPage.vue b/dashboard/src/views/ExtensionPage.vue index a9dec0679..97b3d0996 100644 --- a/dashboard/src/views/ExtensionPage.vue +++ b/dashboard/src/views/ExtensionPage.vue @@ -11,12 +11,37 @@ import { useCommonStore } from '@/stores/common'; import { useI18n, useModuleI18n } from '@/i18n/composables'; import defaultPluginIcon from '@/assets/images/plugin_icon.png'; -import { ref, computed, onMounted, reactive, inject, watch } from 'vue'; - +import { ref, computed, onMounted, reactive, watch } from 'vue'; +import { useRouter } from 'vue-router'; const commonStore = useCommonStore(); const { t } = useI18n(); const { tm } = useModuleI18n('features/extension'); +const router = useRouter(); + +// 检查指令冲突并提示 +const conflictDialog = reactive({ + show: false, + count: 0 +}); +const checkAndPromptConflicts = async () => { + try { + const res = await axios.get('/api/commands'); + if (res.data.status === 'ok') { + const conflicts = res.data.data.summary?.conflicts || 0; + if (conflicts > 0) { + conflictDialog.count = conflicts; + conflictDialog.show = true; + } + } + } catch (err) { + console.debug('Failed to check command conflicts:', err); + } +}; +const handleConflictConfirm = () => { + router.push('/commands'); +}; + const fileInput = ref(null); const activeTab = ref('installed'); const extension_data = reactive({ @@ -435,7 +460,9 @@ const pluginOn = async (extension) => { return; } toast(res.data.message, "success"); - getExtensions(); + await getExtensions(); + + await checkAndPromptConflicts(); } catch (err) { toast(err, "error"); } @@ -618,6 +645,8 @@ const newExtension = async () => { name: res.data.data.name, repo: res.data.data.repo || null }); + + await checkAndPromptConflicts(); }).catch((err) => { loading_.value = false; onLoadingDialogResult(2, err, -1); @@ -644,6 +673,8 @@ const newExtension = async () => { name: res.data.data.name, repo: res.data.data.repo || null }); + + await checkAndPromptConflicts(); }).catch((err) => { loading_.value = false; toast(tm('messages.installFailed') + " " + err, "error"); @@ -1222,6 +1253,34 @@ watch(marketSearch, (newVal) => { + + + + + mdi-alert-circle + {{ tm('conflicts.title') }} + + +
+ + {{ conflictDialog.count }} + + {{ tm('conflicts.pairs') }} +
+

+ {{ tm('conflicts.message') }} +

+
+ + + {{ tm('buttons.cancel') }} + + {{ tm('conflicts.goToManage') }} + + +
+
+