Skip to content

Commit

Permalink
fix(config): $if-disabled plugins should not be displayed, fix #249
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Nov 20, 2023
1 parent 0833aff commit 56be891
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 1 addition & 3 deletions plugins/config/client/components/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
<k-layout menu="config.tree" :menu-data="current">
<template #header>
<!-- root -->
<template v-if="!current.path">
{{ current.name }}
</template>
<template v-if="!current.path">全局设置</template>

<!-- group -->
<template v-else-if="current.children">
Expand Down
8 changes: 8 additions & 0 deletions plugins/config/src/shared/writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ export class ConfigWriter extends DataService<Context.Config & { $paths: Dict<nu
const value = plugins[key]
const name = key.split(':', 1)[0].replace(/^~/, '')

if (!this.loader.isTruthyLike(value?.$if)) {
// $if-disabled plugins should not be displayed
// https://github.com/koishijs/webui/issues/249
delete result[key]
continue
}

// handle plugin groups
const fork = ctx.scope[Loader.kRecord][key]
if (!fork) continue
Expand All @@ -104,6 +111,7 @@ export class ConfigWriter extends DataService<Context.Config & { $paths: Dict<nu
}

async reloadApp(config: any) {
delete config.$paths
const plugins = this.loader.config.plugins
this.loader.config = config
this.loader.config.plugins = plugins
Expand Down

0 comments on commit 56be891

Please sign in to comment.