diff --git a/package.json b/package.json index 4b16bcc..8383865 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "dc-admin": "link:", "nprogress": "^0.2.0", "pinia": "^2.1.7", - "pinia-plugin-persist": "^1.0.0", + "pinia-plugin-persistedstate": "^3.2.1", "vue": "^3.4.21", "vue-i18n": "10.0.0-alpha.3", "vue-router": "^4.3.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 869959f..d8dd739 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,9 +10,9 @@ dependencies: pinia: specifier: ^2.1.7 version: 2.1.7(typescript@5.4.3)(vue@3.4.21) - pinia-plugin-persist: - specifier: ^1.0.0 - version: 1.0.0(pinia@2.1.7)(vue@3.4.21) + pinia-plugin-persistedstate: + specifier: ^3.2.1 + version: 3.2.1(pinia@2.1.7) vue: specifier: ^3.4.21 version: 3.4.21(typescript@5.4.3) @@ -3842,19 +3842,12 @@ packages: hasBin: true dev: true - /pinia-plugin-persist@1.0.0(pinia@2.1.7)(vue@3.4.21): - resolution: {integrity: sha512-M4hBBd8fz/GgNmUPaaUsC29y1M09lqbXrMAHcusVoU8xlQi1TqgkWnnhvMikZwr7Le/hVyMx8KUcumGGrR6GVw==} + /pinia-plugin-persistedstate@3.2.1(pinia@2.1.7): + resolution: {integrity: sha512-MK++8LRUsGF7r45PjBFES82ISnPzyO6IZx3CH5vyPseFLZCk1g2kgx6l/nW8pEBKxxd4do0P6bJw+mUSZIEZUQ==} peerDependencies: - '@vue/composition-api': ^1.0.0 pinia: ^2.0.0 - vue: ^2.0.0 || >=3.0.0 - peerDependenciesMeta: - '@vue/composition-api': - optional: true dependencies: pinia: 2.1.7(typescript@5.4.3)(vue@3.4.21) - vue: 3.4.21(typescript@5.4.3) - vue-demi: 0.12.5(vue@3.4.21) dev: false /pinia@2.1.7(typescript@5.4.3)(vue@3.4.21): @@ -5137,21 +5130,6 @@ packages: fsevents: 2.3.3 dev: true - /vue-demi@0.12.5(vue@3.4.21): - resolution: {integrity: sha512-BREuTgTYlUr0zw0EZn3hnhC3I6gPWv+Kwh4MCih6QcAeaTlaIX0DwOVN0wHej7hSvDPecz4jygy/idsgKfW58Q==} - engines: {node: '>=12'} - hasBin: true - requiresBuild: true - peerDependencies: - '@vue/composition-api': ^1.0.0-rc.1 - vue: ^3.0.0-0 || ^2.6.0 - peerDependenciesMeta: - '@vue/composition-api': - optional: true - dependencies: - vue: 3.4.21(typescript@5.4.3) - dev: false - /vue-demi@0.14.7(vue@3.4.21): resolution: {integrity: sha512-EOG8KXDQNwkJILkx/gPcoL/7vH+hORoBaKgGe+6W7VFMvCYJfmF2dGbvgDroVnI8LU7/kTu8mbjRZGBU1z9NTA==} engines: {node: '>=12'} diff --git a/src/main.ts b/src/main.ts index e57ccea..5924220 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,13 +4,12 @@ import App from "@/App.vue"; import ArcoVue from "@arco-design/web-vue"; import router from "@/router/index"; import pinia from "@/store/index"; -import piniaPluginPersist from "pinia-plugin-persist"; import "virtual:svg-icons-register"; import "@arco-design/web-vue/dist/arco.css"; // 额外引入图标库 import ArcoVueIcon from "@arco-design/web-vue/es/icon"; +// 引入i18n import i18n from "@/lang/index"; -pinia.use(piniaPluginPersist); const app = createApp(App); app.use(ArcoVue, { componentPrefix: "arco" diff --git a/src/store/config/config.ts b/src/store/config/config.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/store/index.ts b/src/store/index.ts index 860adb0..85f5b14 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,9 +1,11 @@ // https://pinia.vuejs.org/zh/ // store/index.js import { createPinia } from "pinia"; +import piniaPluginPersistedstate from "pinia-plugin-persistedstate"; // 创建 const pinia = createPinia(); +pinia.use(piniaPluginPersistedstate); // 导出 export default pinia; diff --git a/src/store/modules/theme-config.ts b/src/store/modules/theme-config.ts index 7802fef..61ed9f5 100644 --- a/src/store/modules/theme-config.ts +++ b/src/store/modules/theme-config.ts @@ -4,7 +4,7 @@ import { defineStore } from "pinia"; * 全局配置 * @methods setCollapsed 设置菜单折叠 */ -export const useThemeConfig = defineStore("themeConfig", { +export const useThemeConfig = defineStore("theme-config", { state: (): any => ({ collapsed: false, // 是否折叠菜单 refreshPage: true, // 刷新页面 @@ -12,7 +12,7 @@ export const useThemeConfig = defineStore("themeConfig", { }), actions: { // 折叠菜单 - async setCollapsed(data: boolean) { + setCollapsed(data: boolean) { this.collapsed = data; }, // 刷新页面 @@ -25,7 +25,6 @@ export const useThemeConfig = defineStore("themeConfig", { } }, persist: { - enabled: true, // 开启数据缓存-默认缓存全部数据 - key: "themeConfig" + key: "theme-config" } }); diff --git a/src/store/modules/user-info.ts b/src/store/modules/user-info.ts index 3e6dce4..30cb2ef 100644 --- a/src/store/modules/user-info.ts +++ b/src/store/modules/user-info.ts @@ -5,7 +5,7 @@ import { defineStore } from "pinia"; * @methods setToken 设置token * @methods logOut 退出登录 */ -export const useUserInfoStore = defineStore("userInfo", { +export const useUserInfoStore = defineStore("user-info", { state: (): any => ({ account: { username: "", @@ -26,7 +26,6 @@ export const useUserInfoStore = defineStore("userInfo", { } }, persist: { - enabled: true, // 开启数据缓存-默认缓存全部数据 - key: "userInfo" + key: "user-info" } }); diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index 6425636..ddc9fd3 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -5,4 +5,4 @@ declare module "*.vue" { export default component; } -declare module "pinia-plugin-persist"; +declare module "vue-i18n";