Skip to content

Commit

Permalink
refa: revert 0badd5e
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jun 12, 2024
1 parent 7bdf3cf commit 2c9d267
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/client/app/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function (ctx: Context) {
component: Settings,
})

ctx.schema.component({
ctx.schema({
type: 'string',
role: 'theme',
component: Theme,
Expand Down
13 changes: 6 additions & 7 deletions packages/client/client/plugins/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface SettingOptions extends Ordered {
export let useStorage = <T extends object>(key: string, version?: number, fallback?: () => T): RemovableRef<T> => {
const initial = fallback ? fallback() : {} as T
initial['__version__'] = version
const storage = useLocalStorage('koishi.console.' + key, initial)
const storage = useLocalStorage('cordis.webui.' + key, initial)
if (storage.value['__version__'] !== version) {
storage.value = initial
}
Expand Down Expand Up @@ -62,8 +62,8 @@ export default class SettingService extends Service {
constructor(ctx: Context) {
super(ctx, '$setting', true)
ctx.mixin('$setting', {
'schema': 'schema.component',
'settings': 'settings',
settings: 'settings',
extendSchema: 'schema',
})

ctx.internal.settings = reactive({})
Expand Down Expand Up @@ -112,10 +112,9 @@ export default class SettingService extends Service {
ctx.effect(() => watch(schema, update))
}

schema(extension: SchemaBase.Extension) {
const caller = this[Context.current]
extension.component = caller.wrapComponent(extension.component)
return caller.effect(() => {
extendSchema(extension: SchemaBase.Extension) {
extension.component = this.ctx.wrapComponent(extension.component)
return this.ctx.effect(() => {
SchemaBase.extensions.add(extension)
return () => SchemaBase.extensions.delete(extension)
})
Expand Down

0 comments on commit 2c9d267

Please sign in to comment.