fix: pinia未持久化问题
This commit is contained in:
parent
14afa2e92c
commit
612d9b1e6c
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
@ -1,5 +1,9 @@
|
|||||||
lockfileVersion: '6.0'
|
lockfileVersion: '6.0'
|
||||||
|
|
||||||
|
settings:
|
||||||
|
autoInstallPeers: true
|
||||||
|
excludeLinksFromLockfile: false
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
dc-admin:
|
dc-admin:
|
||||||
specifier: 'link:'
|
specifier: 'link:'
|
||||||
@ -5303,7 +5307,3 @@ packages:
|
|||||||
resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==}
|
resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==}
|
||||||
engines: {node: '>=12.20'}
|
engines: {node: '>=12.20'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
settings:
|
|
||||||
autoInstallPeers: true
|
|
||||||
excludeLinksFromLockfile: false
|
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { createI18n } from "vue-i18n";
|
import { createI18n } from "vue-i18n";
|
||||||
import zhCN from "@/lang/modules/zhCN";
|
import zhCN from "@/lang/modules/zhCN";
|
||||||
import enUS from "@/lang/modules/enUS";
|
import enUS from "@/lang/modules/enUS";
|
||||||
import pinia from "@/store/index";
|
// import pinia from "@/store/index";
|
||||||
import { storeToRefs } from "pinia";
|
// import { storeToRefs } from "pinia";
|
||||||
import { useThemeConfig } from "@/store/modules/theme-config";
|
// import { useThemeConfig } from "@/store/modules/theme-config";
|
||||||
const themeStore = useThemeConfig(pinia);
|
// const themeStore = useThemeConfig(pinia);
|
||||||
const { language } = storeToRefs(themeStore);
|
// const { language } = storeToRefs(themeStore);
|
||||||
/* 这里必须是messages名称 */
|
/* 这里必须是messages名称 */
|
||||||
const messages = {
|
const messages = {
|
||||||
"zh-CN": zhCN,
|
"zh-CN": zhCN,
|
||||||
@ -15,7 +15,7 @@ const messages = {
|
|||||||
const i18n = createI18n({
|
const i18n = createI18n({
|
||||||
legacy: false, // Composition API模式需要设为false
|
legacy: false, // Composition API模式需要设为false
|
||||||
globalInjection: true, // 全局生效: $
|
globalInjection: true, // 全局生效: $
|
||||||
locale: language.value, // 默认语言
|
locale: "zh-CN", // 默认语言
|
||||||
messages // 数据源
|
messages // 数据源
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
11
src/main.ts
11
src/main.ts
@ -1,21 +1,26 @@
|
|||||||
import { createApp } from "vue";
|
import { createApp } from "vue";
|
||||||
import "@/style.css";
|
import "@/style.css";
|
||||||
import App from "@/App.vue";
|
import App from "@/App.vue";
|
||||||
|
// arco-design
|
||||||
import ArcoVue from "@arco-design/web-vue";
|
import ArcoVue from "@arco-design/web-vue";
|
||||||
|
// vue-router
|
||||||
import router from "@/router/index";
|
import router from "@/router/index";
|
||||||
|
// pinia
|
||||||
import pinia from "@/store/index";
|
import pinia from "@/store/index";
|
||||||
import "virtual:svg-icons-register";
|
// arco-css
|
||||||
import "@arco-design/web-vue/dist/arco.css";
|
import "@arco-design/web-vue/dist/arco.css";
|
||||||
// 额外引入图标库
|
// 额外引入图标库
|
||||||
import ArcoVueIcon from "@arco-design/web-vue/es/icon";
|
import ArcoVueIcon from "@arco-design/web-vue/es/icon";
|
||||||
|
// 注册全局svg
|
||||||
|
import "virtual:svg-icons-register";
|
||||||
// 引入i18n
|
// 引入i18n
|
||||||
import i18n from "@/lang/index";
|
import i18n from "@/lang/index";
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
app.use(ArcoVue, {
|
app.use(ArcoVue, {
|
||||||
componentPrefix: "arco"
|
componentPrefix: "arco"
|
||||||
});
|
});
|
||||||
app.use(i18n);
|
|
||||||
app.use(ArcoVueIcon);
|
|
||||||
app.use(pinia);
|
app.use(pinia);
|
||||||
|
app.use(ArcoVueIcon);
|
||||||
app.use(router);
|
app.use(router);
|
||||||
|
app.use(i18n);
|
||||||
app.mount("#app");
|
app.mount("#app");
|
||||||
|
|||||||
@ -25,8 +25,5 @@ export const useThemeConfig = defineStore("theme-config", {
|
|||||||
this.language = data;
|
this.language = data;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
persist: {
|
persist: true
|
||||||
key: "theme-config",
|
|
||||||
storage: localStorage
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -25,8 +25,5 @@ export const useUserInfoStore = defineStore("user-info", {
|
|||||||
this.token = "";
|
this.token = "";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
persist: {
|
persist: true
|
||||||
key: "user-info",
|
|
||||||
storage: localStorage
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user