seatonwan9
2025-08-14 a0fc5b1e703769a8936fd8671ec9cdd9adfda20a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { defineStore } from 'pinia'
import store from '@/stores'
import { Permission } from '../interface'
 
export const usePermissionStore = defineStore('permission', {
    state: (): Permission => {
        return {
            buttonAuth: []
          }
    },
    getters: {
        getButtonAuth: (state) => {
            return state.buttonAuth
        },
    },
    actions: {
        async setPerms(permsList: any[]) {
            this.buttonAuth = permsList
        },
        // 清空缓存页面
        clearAllCachePage() {
            this.buttonAuth = []
        },
    },
    // 开启数据缓存,用于状态管理器的数据持久化
    persist: {
        storage: localStorage
    }
})
 
export function usePermissionStoreHook() {
return usePermissionStore(store);
}