fix: plugin config default value

This commit is contained in:
JellyBrick
2023-11-28 10:21:08 +09:00
parent 04d7b32d3f
commit 3e8a0ec49a
12 changed files with 44 additions and 91 deletions

View File

@ -11,8 +11,8 @@ import { restart } from '@/providers/app-controls';
const set = (key: string, value: unknown) => {
store.set(key, value);
};
const setPartial = (key: string, value: object) => {
const newValue = deepmerge(store.get(key) ?? {}, value);
const setPartial = (key: string, value: object, defaultValue?: object) => {
const newValue = deepmerge(defaultValue ?? {}, store.get(key) ?? {}, value);
store.set(key, newValue);
};

View File

@ -1,3 +1,5 @@
import { deepmerge } from 'deepmerge-ts';
import { allPlugins } from 'virtual:plugins';
import store from './store';
@ -10,7 +12,7 @@ export function getPlugins() {
}
export function isEnabled(plugin: string) {
const pluginConfig = (store.get('plugins') as Record<string, PluginConfig>)[plugin];
const pluginConfig = deepmerge(allPlugins[plugin].config ?? { enabled: false }, (store.get('plugins') as Record<string, PluginConfig>)[plugin] ?? {});
return pluginConfig !== undefined && pluginConfig.enabled;
}