Bang Hu
1 天以前 8a709ba6db50831048f9c3e2452ea6dc6c3de36f
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
34
35
36
37
38
39
40
41
// 用户信息状态管理
import {update} from 'lodash'
import {defineStore} from 'pinia'
import {CommonInfo} from '@/stores/interface'
 
interface State {
    activeMenu: string
}
 
export const useCommonInfo = defineStore('commonInfo', {
    state: (): CommonInfo => {
        return {
            areaSource: [], // 省市区数据源
            activeMenu: '',
        }
    },
    // 开启数据缓存
    persist: {
        storage: localStorage  
    },
    actions: {
        // 更新areaSource
        updateAreaSource(areaSource: []) {
            this.areaSource = areaSource
        },
        // 更新活跃状态的menu
        updateActiveMenu(activeIndex: string) {
            this.activeMenu = activeIndex;
        },
    },
    getters: {
        // 获取省市区
        getAreaSource: (state) => {
            return state.areaSource
        },
        // 获取活跃状态menu的activeindex
        getActiveMenu: (state) => {
            return state.activeMenu;
        },
    }
})