From 466541f94a9006596e31d3f359b15397b99c9e82 Mon Sep 17 00:00:00 2001 From: Shigma Date: Thu, 25 Jan 2024 22:45:59 +0800 Subject: [PATCH] feat(commands): support set alias args --- plugins/commands/client/command.vue | 114 +++++++++++++++++++++------- plugins/commands/src/index.ts | 6 ++ 2 files changed, 92 insertions(+), 28 deletions(-) diff --git a/plugins/commands/client/command.vue b/plugins/commands/client/command.vue index 73a686f2..bde94a95 100644 --- a/plugins/commands/client/command.vue +++ b/plugins/commands/client/command.vue @@ -13,30 +13,29 @@
-

名称设置

+

+ 别名设置 + 添加 +

- - - - - - + +
{{ name }}
+ {{ name }} + {{ stringify(alias) ? `(${stringify(alias)})` : '' }} + {{ index > 0 ? '设为默认' : '显示名称' }} - + {{ command.initial.aliases[name] ? '禁用' : '删除' }} 恢复
-

- 添加别名 -

选项:{{ option.syntax }} - - + +
+ +
+
+ +
@@ -67,9 +88,11 @@ @@ -161,4 +211,12 @@ async function onEnter() { color: var(--k-color-disabled); } +tr { + transition: var(--color-transition); +} + +tr:hover { + background-color: var(--el-fill-color); +} + diff --git a/plugins/commands/src/index.ts b/plugins/commands/src/index.ts index 5d48e942..74c6843e 100644 --- a/plugins/commands/src/index.ts +++ b/plugins/commands/src/index.ts @@ -10,6 +10,7 @@ declare module '@koishijs/console' { 'command/update'(name: string, config: Pick): void 'command/teleport'(name: string, parent: string): void 'command/aliases'(name: string, aliases: Dict): void + 'command/parse'(name: string, source: string): Argv } } @@ -375,6 +376,11 @@ export class CommandManager { this.remove(name) this.refresh() }, { authority: 4 }) + + ctx.console.addListener('command/parse', (name, source) => { + const command = this.ctx.$commander.get(name) + return command.parse(source) + }) }) } }