diff --git a/astrbot/core/star/command_management.py b/astrbot/core/star/command_management.py index b2bedefcc..b8b6442e1 100644 --- a/astrbot/core/star/command_management.py +++ b/astrbot/core/star/command_management.py @@ -38,7 +38,6 @@ class CommandDescriptor: is_group: bool = False is_sub_command: bool = False config: CommandConfig | None = None - keep_original_alias: bool = False has_conflict: bool = False @@ -77,7 +76,7 @@ async def toggle_command(handler_full_name: str, enabled: bool) -> CommandDescri else descriptor.current_fragment ), enabled=enabled, - keep_original_alias=existing_cfg.keep_original_alias if existing_cfg else False, + keep_original_alias=False, conflict_key=existing_cfg.conflict_key if existing_cfg and existing_cfg.conflict_key else descriptor.original_command, @@ -94,7 +93,6 @@ async def toggle_command(handler_full_name: str, enabled: bool) -> CommandDescri async def rename_command( handler_full_name: str, new_fragment: str, - keep_original_alias: bool = False, ) -> CommandDescriptor: descriptor = _build_descriptor_by_full_name(handler_full_name) if not descriptor: @@ -115,7 +113,7 @@ async def rename_command( original_command=descriptor.original_command or descriptor.handler_name, resolved_command=new_fragment, enabled=True if descriptor.enabled else False, - keep_original_alias=keep_original_alias, + keep_original_alias=False, conflict_key=descriptor.original_command, resolution_strategy="manual_rename", note=None, @@ -304,7 +302,6 @@ def _compose_command(parent_signature: str, fragment: str | None) -> str: def _bind_descriptor_with_config(descriptor: CommandDescriptor, config: CommandConfig): descriptor.config = config - descriptor.keep_original_alias = config.keep_original_alias descriptor.enabled = config.enabled descriptor.handler.enabled = config.enabled @@ -319,20 +316,12 @@ def _bind_descriptor_with_config(descriptor: CommandDescriptor, config: CommandC ) if descriptor.filter_ref and new_fragment: - _set_filter_fragment( - descriptor.filter_ref, - new_fragment, - keep_original=config.keep_original_alias, - original_fragment=descriptor.raw_command_name, - ) + _set_filter_fragment(descriptor.filter_ref, new_fragment) def _set_filter_fragment( filter_ref: CommandFilter | CommandGroupFilter, fragment: str, - *, - keep_original: bool, - original_fragment: str | None, ) -> None: attr = ( "group_name" if isinstance(filter_ref, CommandGroupFilter) else "command_name" @@ -340,9 +329,6 @@ def _set_filter_fragment( current_value = getattr(filter_ref, attr) if fragment == current_value: return - if keep_original and original_fragment: - alias_set = getattr(filter_ref, "alias", set()) - alias_set.add(original_fragment) setattr(filter_ref, attr, fragment) if hasattr(filter_ref, "_cmpl_cmd_names"): filter_ref._cmpl_cmd_names = None @@ -383,5 +369,4 @@ def _descriptor_to_dict(desc: CommandDescriptor) -> dict[str, Any]: "enabled": desc.enabled, "is_group": desc.is_group, "has_conflict": desc.has_conflict, - "keep_original_alias": desc.keep_original_alias, } diff --git a/astrbot/dashboard/routes/command.py b/astrbot/dashboard/routes/command.py index 6d3477302..3a0c13fc6 100644 --- a/astrbot/dashboard/routes/command.py +++ b/astrbot/dashboard/routes/command.py @@ -62,13 +62,12 @@ class CommandRoute(Route): data = await request.get_json() handler_full_name = data.get("handler_full_name") new_name = data.get("new_name") - keep_original = bool(data.get("keep_original_alias", False)) if not handler_full_name or not new_name: return Response().error("handler_full_name 与 new_name 均为必填。").__dict__ try: - await rename_command_service(handler_full_name, new_name, keep_original) + await rename_command_service(handler_full_name, new_name) except ValueError as exc: return Response().error(str(exc)).__dict__ diff --git a/dashboard/src/i18n/locales/en-US/features/command.json b/dashboard/src/i18n/locales/en-US/features/command.json index e855488d6..f2346096e 100644 --- a/dashboard/src/i18n/locales/en-US/features/command.json +++ b/dashboard/src/i18n/locales/en-US/features/command.json @@ -35,7 +35,6 @@ "rename": { "title": "Rename Command", "newName": "New command name", - "keepAlias": "Keep original name as alias", "cancel": "Cancel", "confirm": "Confirm" }, diff --git a/dashboard/src/i18n/locales/zh-CN/features/command.json b/dashboard/src/i18n/locales/zh-CN/features/command.json index 0e3b309fb..278038029 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/command.json +++ b/dashboard/src/i18n/locales/zh-CN/features/command.json @@ -35,7 +35,6 @@ "rename": { "title": "重命名指令", "newName": "新指令名", - "keepAlias": "保留原名作为别名", "cancel": "取消", "confirm": "确认" }, diff --git a/dashboard/src/views/CommandPage.vue b/dashboard/src/views/CommandPage.vue index 6b4b92f86..9244b8095 100644 --- a/dashboard/src/views/CommandPage.vue +++ b/dashboard/src/views/CommandPage.vue @@ -20,7 +20,6 @@ interface CommandItem { enabled: boolean; is_group: boolean; has_conflict: boolean; - keep_original_alias: boolean; } interface CommandSummary { @@ -56,7 +55,6 @@ const renameDialog = reactive({ show: false, command: null as CommandItem | null, newName: '', - keepAlias: false, loading: false }); @@ -166,7 +164,6 @@ const toggleCommand = async (cmd: CommandItem) => { const openRenameDialog = (cmd: CommandItem) => { renameDialog.command = cmd; renameDialog.newName = cmd.current_fragment || ''; - renameDialog.keepAlias = cmd.keep_original_alias; renameDialog.show = true; }; @@ -178,8 +175,7 @@ const confirmRename = async () => { try { const res = await axios.post('/api/commands/rename', { handler_full_name: renameDialog.command.handler_full_name, - new_name: renameDialog.newName.trim(), - keep_original_alias: renameDialog.keepAlias + new_name: renameDialog.newName.trim() }); if (res.data.status === 'ok') { toast(tm('messages.renameSuccess'), 'success'); @@ -284,148 +280,148 @@ onMounted(async () => { - - - - - - - - - - + + + + + + + + - - + ]" + density="compact" + variant="outlined" + hide-details + /> + + - - - - - - - {{ t('core.status.loading') }} - - + + + + + + + {{ t('core.status.loading') }} + + - - - - - {{ item.effective_command }} - + + + + + {{ item.effective_command }} - + + - - {{ item.plugin_display_name || item.plugin }} - + + {{ item.plugin_display_name || item.plugin }} + - - - {{ item.description || '-' }} - - + + + {{ item.description || '-' }} + + - - - {{ getPermissionLabel(item.permission) }} - - + + + {{ getPermissionLabel(item.permission) }} + + - - + + > {{ getStatusInfo(item).text }} - - + + - - - - - mdi-play - {{ tm('tooltips.enable') }} - - - mdi-pause - {{ tm('tooltips.disable') }} - + + + + + mdi-play + {{ tm('tooltips.enable') }} + + + mdi-pause + {{ tm('tooltips.disable') }} + - - mdi-pencil - {{ tm('tooltips.rename') }} - + + mdi-pencil + {{ tm('tooltips.rename') }} + - - mdi-information - {{ tm('tooltips.viewDetails') }} - - - - + + mdi-information + {{ tm('tooltips.viewDetails') }} + + + + - - - mdi-console-line - {{ tm('empty.noCommands') }} - {{ tm('empty.noCommandsDesc') }} - - - - + + + mdi-console-line + {{ tm('empty.noCommands') }} + {{ tm('empty.noCommandsDesc') }} + + + + @@ -441,15 +437,8 @@ onMounted(async () => { :label="tm('dialogs.rename.newName')" variant="outlined" density="compact" - class="mb-4" autofocus /> -
{{ item.effective_command }}