Quellcode durchsuchen

feat: 添加useKeepAliveStore

wanggaokun vor 4 Wochen
Ursprung
Commit
19d8246315

+ 2 - 0
package.json

@@ -30,6 +30,7 @@
     "nprogress": "^0.2.0",
     "pinia": "^3.0.3",
     "pinia-plugin-persistedstate": "^4.4.1",
+    "sortablejs": "^1.15.6",
     "vue": "^3.5.17",
     "vue-eslint-parser": "^10.2.0",
     "vue-router": "^4.5.1"
@@ -41,6 +42,7 @@
     "@types/node": "^24.0.13",
     "@types/node-forge": "^1.3.13",
     "@types/nprogress": "^0.2.3",
+    "@types/sortablejs": "^1.15.8",
     "@vitejs/plugin-vue": "^6.0.0",
     "@vitejs/plugin-vue-jsx": "^5.0.1",
     "@vue/eslint-config-prettier": "^10.2.0",

+ 16 - 0
pnpm-lock.yaml

@@ -29,6 +29,9 @@ importers:
       pinia-plugin-persistedstate:
         specifier: ^4.4.1
         version: 4.4.1(pinia@3.0.3(typescript@5.8.3)(vue@3.5.17(typescript@5.8.3)))
+      sortablejs:
+        specifier: ^1.15.6
+        version: 1.15.6
       vue:
         specifier: ^3.5.17
         version: 3.5.17(typescript@5.8.3)
@@ -57,6 +60,9 @@ importers:
       '@types/nprogress':
         specifier: ^0.2.3
         version: 0.2.3
+      '@types/sortablejs':
+        specifier: ^1.15.8
+        version: 1.15.8
       '@vitejs/plugin-vue':
         specifier: ^6.0.0
         version: 6.0.0(vite@7.0.4(@types/node@24.0.13)(jiti@2.4.2)(sass@1.89.2)(yaml@2.8.0))(vue@3.5.17(typescript@5.8.3))
@@ -887,6 +893,9 @@ packages:
   '@types/nprogress@0.2.3':
     resolution: {integrity: sha512-k7kRA033QNtC+gLc4VPlfnue58CM1iQLgn1IMAU8VPHGOj7oIHPp9UlhedEnD/Gl8evoCjwkZjlBORtZ3JByUA==}
 
+  '@types/sortablejs@1.15.8':
+    resolution: {integrity: sha512-b79830lW+RZfwaztgs1aVPgbasJ8e7AXtZYHTELNXZPsERt4ymJdjV4OccDbHQAvHrCcFpbF78jkm0R6h/pZVg==}
+
   '@types/svgo@2.6.4':
     resolution: {integrity: sha512-l4cmyPEckf8moNYHdJ+4wkHvFxjyW6ulm9l4YGaOxeyBWPhBOT0gvni1InpFPdzx1dKf/2s62qGITwxNWnPQng==}
 
@@ -3264,6 +3273,9 @@ packages:
     resolution: {integrity: sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==}
     engines: {node: '>=0.10.0'}
 
+  sortablejs@1.15.6:
+    resolution: {integrity: sha512-aNfiuwMEpfBM/CN6LY0ibyhxPfPbyFeBTYJKCvzkJ2GkUpazIt3H+QIPAMHwqQ7tMKaHz1Qj+rJJCqljnf4p3A==}
+
   source-map-js@1.2.1:
     resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
     engines: {node: '>=0.10.0'}
@@ -4499,6 +4511,8 @@ snapshots:
 
   '@types/nprogress@0.2.3': {}
 
+  '@types/sortablejs@1.15.8': {}
+
   '@types/svgo@2.6.4':
     dependencies:
       '@types/node': 24.0.13
@@ -7143,6 +7157,8 @@ snapshots:
     transitivePeerDependencies:
       - supports-color
 
+  sortablejs@1.15.6: {}
+
   source-map-js@1.2.1: {}
 
   source-map-resolve@0.5.3:

+ 0 - 0
src/layouts/components/AppTabs/index.vue


+ 1 - 1
src/stores/index.ts

@@ -8,5 +8,5 @@ export const setupPinia = (app: App<Element>) => {
 pinia.use(piniaPluginPersistedstate)
 export * from './modules/auth'
 export * from './modules/user'
-export * from './modules/setting'
+export * from './modules/keepAlive'
 export { pinia }

+ 27 - 0
src/stores/modules/keepAlive.ts

@@ -0,0 +1,27 @@
+import { pinia } from '../index'
+export const useKeepAliveStore = defineStore('eco-keep-alive', {
+  state: () => ({
+    keepAliveName: [] as string[]
+  }),
+  getters: {
+    getKeepAliveName: state => state.keepAliveName
+  },
+  actions: {
+    addKeepAliveName(name: string) {
+      if (!this.keepAliveName.includes(name)) {
+        this.keepAliveName.push(name)
+      }
+    },
+    removeKeepAliveName(name: string) {
+      this.keepAliveName = this.keepAliveName.filter(item => item !== name)
+    },
+    setKeepAliveName(keepAliveNames: string[] = []) {
+      this.keepAliveName = keepAliveNames
+    }
+  },
+  persist: true
+})
+
+export const useKeepAliveStoreWithOut = () => {
+  return useKeepAliveStore(pinia)
+}

+ 0 - 26
src/stores/modules/setting.ts

@@ -1,26 +0,0 @@
-import { SettingState } from '@/stores/interface'
-import { LayoutTypeEnum } from '@/enums/LayoutTypeEnum'
-import { DEFAULT_SETTING } from '@/constants'
-export const useSettingStore = defineStore('eco-setting', {
-  state: (): SettingState => ({
-    layout: LayoutTypeEnum.CLASSIC, // mix | classic | transverse
-    breadcrumb: true,
-    breadcrumbIcon: true,
-    footer: true,
-    isDark: false,
-    primary: DEFAULT_SETTING.PRIMARY,
-    // 侧边栏反转
-    asideInverted: false,
-    // 头部反转
-    headerInverted: false,
-    showTaps: DEFAULT_SETTING.SHOW_TAPS,
-    tagsViewIcon: DEFAULT_SETTING.TAPS_VIEW_ICON
-  }),
-  getters: {},
-  actions: {
-    setGlobalState(...args: ObjToKeyValArray<SettingState>) {
-      this.$patch({ [args[0]]: args[1] })
-    }
-  },
-  persist: true
-})

+ 1 - 0
src/types/auto-components.d.ts

@@ -13,6 +13,7 @@ declare module 'vue' {
     AppLogo: typeof import('./../layouts/components/AppLogo/index.vue')['default']
     AppMain: typeof import('./../layouts/components/AppMain/index.vue')['default']
     AppMenu: typeof import('./../layouts/components/AppMenu/index.vue')['default']
+    AppTabs: typeof import('./../layouts/components/AppTabs/index.vue')['default']
     AppTools: typeof import('./../layouts/components/AppTools/index.vue')['default']
     AppTransverse: typeof import('./../layouts/container/AppTransverse/index.vue')['default']
     ColSetting: typeof import('./../components/ProTable/ColSetting.vue')['default']