yirongjin
2025-07-23 c2da0b81321e66e3c3706d6833ad4c92c62d0935
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
export default {
    namespaced: true,
    state: () => ({
        theme:'',
        lang:'',
        collapse:false,
        activeSubpages:[],
        visibleSubpage:'',
        currentFullMenuPath:[],
        menuTabs:{
            uid:'',
            tabs:[]
        },
        subRefreshKey:{}
    }),
    mutations: {
        setCurrentLang(state,val){
            localStorage.setItem('_lang',val);
            state.lang = val;
        },
        setCollapse(state,val){
            state.collapse = val;
        },
        setActiveSubpages(state,arr){
            state.activeSubpages = arr;
        },
        setVisibleSubpage(state,val){
            if (val!==state.visibleSubpage){
                state.visibleSubpage = val;
            }
        },
        setCurrentFullMenuPath(state,arr){
            state.currentFullMenuPath = arr;
        },
        setMenuTabs(state,obj){
            state.menuTabs = obj;
            localStorage.setItem('__menu_tabs',JSON.stringify(obj));
        },
        setSubRefreshKey(state,obj){
            state.subRefreshKey = obj;
        }
    },
    actions: {
        
    },
    getters: {
        getCurrentLang(state){
            let res = state.lang;
            if (!res) {
                res = localStorage.getItem('_lang');
                if (!res) {
                    res = 'zh_CN';
                    localStorage.setItem('_lang',res);
                    state.lang = res;
                }
            }
            return res
        },
        getCollapse(state){
            return state.collapse
        },
        getActiveSubpages(state){
            return state.activeSubpages
        },
        getVisibleSubpage(state){
            return state.visibleSubpage;
        },
        getCurrentFullMenuPath(state){
            return state.currentFullMenuPath;
        },
        getMenuTabs(state){
            let res = state.menuTabs;
            if (!res || !res.uid) {
                let temp = localStorage.getItem('__menu_tabs');
                if (temp) {
                    try{
                        res = JSON.parse(temp);
                        state.menuTabs = res;
                    }catch(e){
                        //TODO handle the exception
                    }
                }
            }
            return res
        },
        getSubRefreshKey(state){
            return state.subRefreshKey;
        }
    }
}