diff --git a/plugins/frontend/manager/client/index.ts b/plugins/frontend/manager/client/index.ts
index 4c462760da..f79505df63 100644
--- a/plugins/frontend/manager/client/index.ts
+++ b/plugins/frontend/manager/client/index.ts
@@ -36,7 +36,7 @@ export default (ctx: Context) => {
icon: 'cog',
order: 630,
authority: 4,
- fields: ['config', 'packages', 'services', 'dependencies'],
+ fields: ['config', 'packages', 'dependencies'],
component: Settings,
})
diff --git a/plugins/frontend/manager/client/settings/plugin.vue b/plugins/frontend/manager/client/settings/plugin.vue
index 1875a11600..d22841537a 100644
--- a/plugins/frontend/manager/client/settings/plugin.vue
+++ b/plugins/frontend/manager/client/settings/plugin.vue
@@ -14,15 +14,20 @@
停用插件
- 重载配置
+ 重载配置
- 启用插件
+ 启用插件
保存配置
+
+
+ 此插件已在运行且不可重用,启用可能会导致非预期的问题。
+
+
当前的插件版本不是最新,点击前往依赖管理。
@@ -35,21 +40,21 @@
-
+
此插件将会提供 {{ name }} 服务,但此服务已被其他插件实现。
-
- 此插件{{ local.id ? '提供了' : '将会提供' }} {{ name }} 服务。
+
+ 此插件{{ current.disabled ? '将会提供' : '提供了' }} {{ name }} 服务。
+ v-for="({ required, available }, name) in env.using" :key="name"
+ :type="deps[name] ? 'success' : required ? 'warning' : 'primary'">
{{ required ? '必需' : '可选' }}服务:{{ name }}
- {{ fulfilled ? '(已加载)' : '(未加载,启用下列任一插件可实现此服务)' }}
-
+ {{ deps[name] ? '(已加载)' : '(未加载,启用下列任一插件可实现此服务)' }}
+
-
(点击{{ name in store.packages ? '配置' : '添加' }})
@@ -58,19 +63,6 @@
-
-
- {{ required ? '必需' : '可选' }}依赖:
- ({{ local ? `${fulfilled ? '已' : '未'}启用` : '未安装,点击添加' }})
-
-
-
-
- 此插件已在运行且不可重用,启用可能会导致非预期的问题。
-
-
此插件未声明配置项,这可能并非预期行为{{ hint }}。
@@ -89,7 +81,6 @@
import { send, store, clone, router } from '@koishijs/client'
import { computed, ref, watch } from 'vue'
-import { getMixedMeta } from '../utils'
import { envMap, Tree } from './utils'
import KAlias from './alias.vue'
import KDepLink from './dep-link.vue'
@@ -104,6 +95,19 @@ watch(() => props.current.config, (value) => {
config.value = clone(value)
}, { immediate: true })
+const deps = computed(() => props.current.parent.config.$deps)
+
+const type = computed(() => {
+ if (env.value.warning && props.current.disabled) return 'warning'
+ for (const name in env.value.using) {
+ if (deps.value[name]) {
+ if (env.value.impl.includes(name)) return 'warning'
+ } else {
+ if (env.value.using[name].required) return 'warning'
+ }
+ }
+})
+
const name = computed(() => {
const { label, target: temporary } = props.current
const shortname = temporary || label
diff --git a/plugins/frontend/manager/client/settings/utils.ts b/plugins/frontend/manager/client/settings/utils.ts
index d03ba48a1f..a71945d4c9 100644
--- a/plugins/frontend/manager/client/settings/utils.ts
+++ b/plugins/frontend/manager/client/settings/utils.ts
@@ -2,29 +2,17 @@ import { Dict } from 'koishi'
import { computed } from 'vue'
import { MarketProvider } from '@koishijs/plugin-manager'
import { router, store } from '@koishijs/client'
-import { getMixedMeta } from '../utils'
import {} from '@koishijs/cli'
interface DepInfo {
- name: string
required: boolean
- fulfilled: boolean
-}
-
-interface ServiceDepInfo extends DepInfo {
- available?: string[]
-}
-
-interface PluginDepInfo extends DepInfo {
- local?: boolean
+ available: string[]
}
export interface EnvInfo {
impl: string[]
- deps: Dict
- using: Dict
- disabled?: boolean
- type?: 'warning'
+ using: Dict
+ warning?: boolean
console?: boolean
}
@@ -42,18 +30,14 @@ function getEnvInfo(name: string) {
return
}
- const fulfilled = name in store.services
- if (required && !fulfilled) result.disabled = true
- result.using[name] = { name, required, fulfilled }
- if (!fulfilled) {
- result.using[name].available = Object.values(store.market || {})
- .filter(data => isAvailable(name, data))
- .map(data => data.name)
- }
+ const available = Object.values(store.market || {})
+ .filter(data => isAvailable(name, data))
+ .map(data => data.name)
+ result.using[name] = { required, available }
}
const local = store.packages[name]
- const result: EnvInfo = { impl: [], using: {}, deps: {} }
+ const result: EnvInfo = { impl: [], using: {} }
// check implementations
for (const name of local.manifest.service.implements) {
@@ -69,27 +53,14 @@ function getEnvInfo(name: string) {
setService(name, false)
}
- // check dependencies
- for (const name in local.peerDependencies) {
- if (!name.includes('koishi-plugin-') || !name.startsWith('@koishijs/plugin-')) continue
- if (name === '@koishijs/plugin-console') continue
- const available = name in store.packages
- const fulfilled = !!store.packages[name]?.id
- 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'
+ result.warning = true
}
// check schema
if (!local.schema) {
- result.type = 'warning'
+ result.warning = true
}
return result
@@ -109,25 +80,26 @@ export interface Tree {
path: string
config?: any
target?: string
+ parent?: Tree
disabled?: boolean
children?: Tree[]
}
-function getTree(prefix: string, plugins: any): Tree[] {
+function getTree(parent: Tree, plugins: any): Tree[] {
const trees: Tree[] = []
for (let key in plugins) {
if (key.startsWith('$')) continue
const config = plugins[key]
- const node = { config } as Tree
+ const node = { config, parent } as Tree
if (key.startsWith('~')) {
node.disabled = true
key = key.slice(1)
}
node.label = key.split(':', 1)[0]
node.alias = key.slice(node.label.length + 1)
- node.id = node.path = prefix + key
+ node.id = node.path = parent.path + (parent.path ? '/' : '') + key
if (key.startsWith('group:')) {
- node.children = getTree(node.path + '/', config)
+ node.children = getTree(node, config)
}
trees.push(node)
}
@@ -141,8 +113,8 @@ export const plugins = computed(() => {
path: '',
alias: '',
config: store.config.plugins,
- children: getTree('', store.config.plugins),
}
+ root.children = getTree(root, store.config.plugins)
const paths: Dict = {
'@global': {
label: '全局设置',
diff --git a/plugins/frontend/manager/src/index.ts b/plugins/frontend/manager/src/index.ts
index 807d58fa59..d46789103a 100644
--- a/plugins/frontend/manager/src/index.ts
+++ b/plugins/frontend/manager/src/index.ts
@@ -5,14 +5,12 @@ import BotProvider from './bots'
import MarketProvider from './market'
import PackageProvider from './packages'
import AdapterProvider from './protocols'
-import ServiceProvider from './services'
import ConfigWriter from './writer'
export * from './bots'
export * from './market'
export * from './packages'
export * from './protocols'
-export * from './services'
export * from './writer'
export {
@@ -21,7 +19,6 @@ export {
MarketProvider,
PackageProvider,
AdapterProvider,
- ServiceProvider,
ConfigWriter,
}
@@ -33,7 +30,6 @@ declare module '@koishijs/plugin-console' {
market: MarketProvider
packages: PackageProvider
protocols: AdapterProvider
- services: ServiceProvider
config: ConfigWriter
}
}
@@ -58,7 +54,6 @@ export function apply(ctx: Context, config: Config) {
ctx.plugin(MarketProvider, config)
ctx.plugin(AdapterProvider)
ctx.plugin(PackageProvider)
- ctx.plugin(ServiceProvider)
ctx.plugin(ConfigWriter)
ctx.console.addEntry({
diff --git a/plugins/frontend/manager/src/services.ts b/plugins/frontend/manager/src/services.ts
deleted file mode 100644
index df9c11767e..0000000000
--- a/plugins/frontend/manager/src/services.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { DataService } from '@koishijs/plugin-console'
-import { Context, Dict } from 'koishi'
-
-class ServiceProvider extends DataService> {
- private cache: Dict
-
- constructor(ctx: Context) {
- super(ctx, 'services', { authority: 4 })
-
- ctx.on('internal/service', () => this.refresh())
- }
-
- async get(forced = false) {
- if (!forced && this.cache) return this.cache
- this.cache = {}
- for (const name of Context.Services) {
- const value = this.ctx[name]?.['ctx']?.state.uid
- if (this.ctx[name]) this.cache[name] = value ?? null
- }
- return this.cache
- }
-}
-
-export default ServiceProvider