naive-ui/demo/util-composables.js

28 lines
587 B
JavaScript
Raw Normal View History

2020-09-27 22:27:25 +08:00
import {
toRef,
inject
} from 'vue'
2020-11-14 20:38:30 +08:00
export function useSiteDisplayMode () {
return toRef(inject('SiteProvider'), 'displayMode')
2020-09-27 22:27:25 +08:00
}
export function useSiteTheme () {
return toRef(inject('SiteProvider'), 'theme')
}
export function useSiteLang () {
return toRef(inject('SiteProvider'), 'lang')
}
2020-10-07 20:45:51 +08:00
export const i18n = function (data) {
const configProvider = inject('NConfigProvider', null)
return {
2020-10-08 04:14:14 +08:00
locale: toRef(configProvider, 'inheritedLanguage'),
2020-10-07 20:45:51 +08:00
t (key) {
const { inheritedLanguage } = configProvider
return data[inheritedLanguage][key]
}
}
}