init: 初始系统模板

This commit is contained in:
TsMask
2023-09-05 14:38:23 +08:00
parent a5bc16ae4f
commit 1075c8ae4f
130 changed files with 22531 additions and 1 deletions

26
src/hooks/useI18n.ts Normal file
View File

@@ -0,0 +1,26 @@
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { localSet } from '@/utils/cache-local-utils';
import { CACHE_LOCAL_I18N } from '@/constants/cache-keys-constants';
export default function useLocale() {
//实例化i18n
const i18n = useI18n();
// 获取当前语言设置
const currentLocale = computed(() => {
return i18n.locale.value;
});
// 切换语言
const changeLocale = (value: string) => {
i18n.locale.value = value;
localSet(CACHE_LOCAL_I18N, value);
};
return {
currentLocale,
changeLocale,
t: i18n.t,
};
}