diff --git a/plugins/config/client/components/forks.vue b/plugins/config/client/components/forks.vue index 22ceac0d..fa410680 100644 --- a/plugins/config/client/components/forks.vue +++ b/plugins/config/client/components/forks.vue @@ -24,7 +24,17 @@ - 添加新配置 + + + 此插件目前存在 {{ plugins.forks[shortname]?.length }} 份配置。 + + + 此插件尚未被配置。 + + + + 添加新配置 + @@ -36,7 +46,7 @@ import { store, send, router } from '@koishijs/client' import { dialogFork, plugins, getStatus, removeItem, Tree } from './utils' const shortname = computed(() => dialogFork.value?.replace(/(koishi-|^@koishijs\/)plugin-/, '')) -const local = computed(() => store.packages[dialogFork.value]) +const local = computed(() => store.packages?.[dialogFork.value]) function getLabel(tree: Tree) { return `${tree.label ? `${tree.label} ` : ''}[${tree.path}]` @@ -107,7 +117,10 @@ async function configure(key?: string) { } .el-dialog__footer { - text-align: left; + display: flex; + justify-content: space-between; + align-items: center; + font-size: 0.9em; } } diff --git a/plugins/config/client/index.ts b/plugins/config/client/index.ts index e62e127b..451df544 100644 --- a/plugins/config/client/index.ts +++ b/plugins/config/client/index.ts @@ -1,7 +1,7 @@ -import { Context } from '@koishijs/client' +import { Context, router, send } from '@koishijs/client' import { defineComponent, h, resolveComponent } from 'vue' import type {} from '@koishijs/plugin-config' -import { type } from './components/utils' +import { dialogFork, plugins, type } from './components/utils' import Settings from './components/index.vue' import Forks from './components/forks.vue' import Select from './components/select.vue' @@ -11,6 +11,13 @@ import './icons' export * from './components/utils' +declare module '@koishijs/client' { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + interface Events { + 'config/dialog-fork'(name: string): void + } +} + export default (ctx: Context) => { ctx.slot({ type: 'global', @@ -36,6 +43,20 @@ export default (ctx: Context) => { component: Forks, }) + ctx.on('config/dialog-fork', (name) => { + const shortname = name.replace(/(koishi-|^@koishijs\/)plugin-/, '') + const forks = plugins.value.forks[shortname] + if (!forks.length) { + const key = Math.random().toString(36).slice(2, 8) + send('manager/unload', '', shortname + ':' + key, {}) + router.push('/plugins/' + key) + } else if (forks.length === 1) { + router.push('/plugins/' + forks[0]) + } else { + dialogFork.value = name + } + }) + ctx.page({ path: '/plugins/:name*', name: '插件配置', diff --git a/plugins/market/client/components/install.vue b/plugins/market/client/components/install.vue index a88ef4c7..b1533835 100644 --- a/plugins/market/client/components/install.vue +++ b/plugins/market/client/components/install.vue @@ -5,8 +5,8 @@ class="install-panel" destroy-on-close> - - {{ active.replace(/(koishi-|^@koishijs\/)plugin-/, '') + (workspace ? ' (工作区)' : '') }} + + {{ active + (workspace ? ' (工作区)' : '') }} @@ -46,28 +46,13 @@ - - 点击以前往配置页面: - - - {{ path }} - ({{ active ? '运行中' : '闲置' }}) - - - 添加新配置 - - - - - 你尚未配置此插件,点击立即配置。 - - 批量操作模式 取消 + 配置 移除 添加 @@ -86,11 +71,13 @@