✨ add internationalization / dynamic themes
This commit is contained in:
37
src/store/modules/langStore.ts
Normal file
37
src/store/modules/langStore.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import {defineStore} from 'pinia';
|
||||
import {ref} from 'vue';
|
||||
import pinia from "@/store/pinia.ts";
|
||||
|
||||
export const langStore = defineStore(
|
||||
'lang',
|
||||
() => {
|
||||
const lang = ref<string>('');
|
||||
|
||||
function setLang(value: string) {
|
||||
lang.value = value;
|
||||
}
|
||||
|
||||
function getLang() {
|
||||
return lang.value;
|
||||
}
|
||||
|
||||
return {
|
||||
lang,
|
||||
setLang,
|
||||
getLang,
|
||||
};
|
||||
},
|
||||
{
|
||||
// 开启数据持久化
|
||||
persistedState: {
|
||||
key: 'lang',
|
||||
storage: localStorage,
|
||||
includePaths: ["lang"],
|
||||
overwrite: true,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
export function useLangStoreWithOut() {
|
||||
return langStore(pinia);
|
||||
}
|
Reference in New Issue
Block a user