Skip to content

Commit

Permalink
fix(client): fix slot disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed May 29, 2023
1 parent eb3b7e5 commit 8eb3309
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/client/app/layout/menu-item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const props = defineProps<LegacyMenuItem>()
const ctx = useContext()
const disabled = computed(() => props.disabled ? toValue(props.disabled) : true)
const disabled = computed(() => props.disabled ? toValue(props.disabled) : false)
function toValue<T>(getter: MaybeGetter<T>): T {
if (typeof getter !== 'function') return getter
Expand Down
3 changes: 2 additions & 1 deletion packages/client/app/settings/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
<keep-alive>
<k-content :key="path">
<template v-for="item of ctx.internal.settings[path]">
<component v-if="item.component" :is="item.component" />
<template v-if="item.disabled?.()"></template>
<component v-else-if="item.component" :is="item.component" />
<k-form v-else-if="item.schema" :schema="item.schema" v-model="config" :initial="config" />
</template>
</k-content>
Expand Down
14 changes: 1 addition & 13 deletions packages/client/client/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { RemovableRef, useLocalStorage, usePreferredDark } from '@vueuse/core'
import { computed, reactive, watchEffect } from 'vue'
import { Config } from '.'

export let useStorage = <T extends object>(key: string, version: number, fallback?: () => T): RemovableRef<T> => {
const initial = fallback ? fallback() : {} as T
Expand Down Expand Up @@ -31,19 +32,6 @@ export function createStorage<T extends object>(key: string, version: number, fa
return reactive<T>(storage.value['data'])
}

export interface Config {
theme: Config.Theme
locale?: string
}

export namespace Config {
export interface Theme {
mode: 'auto' | 'dark' | 'light'
dark: string
light: string
}
}

export const config = useStorage<Config>('config', 1.1, () => ({
theme: {
mode: 'auto',
Expand Down
1 change: 1 addition & 0 deletions packages/client/client/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ interface SettingOptions {
id: string
title?: string
order?: number
disabled?: () => boolean
schema?: Schema
component?: Component
}
Expand Down
13 changes: 13 additions & 0 deletions packages/client/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ export default install

export interface ActionContext {}

export interface Config {
theme: Config.Theme
locale?: string
}

export namespace Config {
export interface Theme {
mode: 'auto' | 'dark' | 'light'
dark: string
light: string
}
}

export const root = new Context()

export const router = createRouter({
Expand Down
5 changes: 4 additions & 1 deletion packages/client/client/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ export const initTask = new Promise<void>((resolve) => {

await Promise.all(newValue.map(load))

if (!oldValue) resolve()
if (!oldValue) {
resolve()
if (!root.events.isActive) root.start()
}
}, { deep: true })
})

Expand Down

0 comments on commit 8eb3309

Please sign in to comment.