From 242d7badf27b74eb4d1c878891ad5d62e64f2d9c Mon Sep 17 00:00:00 2001 From: Shigma Date: Sun, 12 Jun 2022 04:18:08 +0800 Subject: [PATCH] feat(manager): show warning for new forks of non-forkable plugin --- .../manager/client/settings/plugin.vue | 32 +++++++++++-------- .../frontend/manager/client/settings/utils.ts | 17 ++++++++-- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/plugins/frontend/manager/client/settings/plugin.vue b/plugins/frontend/manager/client/settings/plugin.vue index f04dcc32df..1875a11600 100644 --- a/plugins/frontend/manager/client/settings/plugin.vue +++ b/plugins/frontend/manager/client/settings/plugin.vue @@ -14,10 +14,10 @@ @@ -29,17 +29,17 @@ - - 尚未将当前插件列入依赖,点击添加。 + + 尚未将当前插件列入依赖,点击添加 @@ -66,11 +66,16 @@ ({{ local ? `${fulfilled ? '已' : '未'}启用` : '未安装,点击添加' }}) + + + 此插件已在运行且不可重用,启用可能会导致非预期的问题。 + + - + 此插件未声明配置项,这可能并非预期行为{{ hint }}。 - + @@ -112,13 +117,14 @@ const name = computed(() => { ].find(name => name in store.packages) }) -const data = computed(() => getMixedMeta(name.value)) +const local = computed(() => store.packages[name.value]) +const remote = computed(() => store.market[name.value]) const env = computed(() => envMap.value[name.value]) -const hint = computed(() => data.value.workspace ? ',请检查源代码' : ',请联系插件作者') +const hint = computed(() => local.value.workspace ? ',请检查源代码' : ',请联系插件作者') const hasUpdate = computed(() => { - if (!data.value.versions || data.value.workspace) return - return data.value.versions[0].version !== data.value.version + if (!remote.value?.versions || local.value.workspace) return + return remote.value.versions[0].version !== local.value.version }) function execute(event: 'unload' | 'reload') { diff --git a/plugins/frontend/manager/client/settings/utils.ts b/plugins/frontend/manager/client/settings/utils.ts index 4511118ef1..d03ba48a1f 100644 --- a/plugins/frontend/manager/client/settings/utils.ts +++ b/plugins/frontend/manager/client/settings/utils.ts @@ -23,7 +23,8 @@ export interface EnvInfo { impl: string[] deps: Dict using: Dict - invalid?: boolean + disabled?: boolean + type?: 'warning' console?: boolean } @@ -42,7 +43,7 @@ function getEnvInfo(name: string) { } const fulfilled = name in store.services - if (required && !fulfilled) result.invalid = true + if (required && !fulfilled) result.disabled = true result.using[name] = { name, required, fulfilled } if (!fulfilled) { result.using[name].available = Object.values(store.market || {}) @@ -74,13 +75,23 @@ function getEnvInfo(name: string) { if (name === '@koishijs/plugin-console') continue const available = name in store.packages const fulfilled = !!store.packages[name]?.id - if (!fulfilled) result.invalid = true + if (!fulfilled) result.disabled = true result.deps[name] = { name, required: true, fulfilled, local: available } for (const impl of getMixedMeta(name).manifest.service.implements) { delete result.using[impl] } } + // check reusability + if (local.id && !local.forkable) { + result.type = 'warning' + } + + // check schema + if (!local.schema) { + result.type = 'warning' + } + return result }