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
| const state = () => {
| return {
| platformInfo: null,
| menuShrink: false,
| size: 'small',
| activeRoute: '',
| }
| }
|
| // getters
| const getters = {
| platformName(state) {
| return state?.platformInfo?.name
| },
| logo(state) {
| return state?.platformInfo?.logo
| },
| noAnswerTip(state) {
| return state?.platformInfo?.noAnswerTip
| },
| }
|
| // actions
| const actions = {
| async getPlatformInfo({ commit }) {
| const { code, data } = await this.$elBusHttp.request('api/ua/platform/info')
| if (code === 0) {
| commit('SET_PLATFORM_INFO', data)
| }
| },
| }
|
| // mutations
| const mutations = {
| SET_PLATFORM_INFO(state, platformInfo) {
| state.platformInfo = platformInfo
| },
| // 设置菜单的展开和收缩
| SET_MENU_SHRINK(state, shrink) {
| state.menuShrink = shrink
| },
| // 设置当前选中的路由
| SET_ACTIVE_ROUTE(state, route) {
| state.activeRoute = route
| },
| SET_SIZE(state, size) {
| this.$elBusCookie.set('size', size)
| state.size = size
| },
| }
|
| export default {
| namespaced: true,
| state,
| getters,
| actions,
| mutations,
| }
|
|