6 changed files with 28 additions and 7 deletions
@ -1,3 +1,12 @@ |
|||
import { ComputedRef, InjectionKey } from 'vue' |
|||
import { computed, ComputedRef, inject, InjectionKey, provide } from 'vue' |
|||
import { IConfig, defaultConfig } from './config' |
|||
|
|||
export const ConfigToken: InjectionKey<ComputedRef<{ locale: string }>> = Symbol('ConfigToken') |
|||
export const ConfigToken: InjectionKey<ComputedRef<IConfig>> = Symbol('ConfigToken') |
|||
|
|||
export function provideData(data: ComputedRef<IConfig>) { |
|||
provide(ConfigToken, data) |
|||
} |
|||
|
|||
export function useConfigData() { |
|||
return inject(ConfigToken, computed(() => (defaultConfig))) |
|||
} |
|||
|
|||
@ -0,0 +1,5 @@ |
|||
|
|||
import type { LanguagesType } from 'bolt-ui/locales' |
|||
|
|||
export interface IConfig { locale: LanguagesType } |
|||
export const defaultConfig: IConfig = { locale: 'zh' } |
|||
Binary file not shown.
Loading…
Reference in new issue