提交 | 用户 | 时间
|
fd2207
|
1 |
import defaultSettings from '@/settings' |
懒 |
2 |
|
|
3 |
const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo, dynamicTitle } = defaultSettings |
|
4 |
|
|
5 |
const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || '' |
|
6 |
const state = { |
|
7 |
title: '', |
|
8 |
theme: storageSetting.theme || '#409EFF', |
|
9 |
sideTheme: storageSetting.sideTheme || sideTheme, |
|
10 |
showSettings: showSettings, |
|
11 |
topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav, |
|
12 |
tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView, |
|
13 |
fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader, |
|
14 |
sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo, |
|
15 |
dynamicTitle: storageSetting.dynamicTitle === undefined ? dynamicTitle : storageSetting.dynamicTitle |
|
16 |
} |
|
17 |
const mutations = { |
|
18 |
CHANGE_SETTING: (state, { key, value }) => { |
|
19 |
if (state.hasOwnProperty(key)) { |
|
20 |
state[key] = value |
|
21 |
} |
|
22 |
} |
|
23 |
} |
|
24 |
|
|
25 |
const actions = { |
|
26 |
// 修改布局设置 |
|
27 |
changeSetting({ commit }, data) { |
|
28 |
commit('CHANGE_SETTING', data) |
|
29 |
}, |
|
30 |
// 设置网页标题 |
|
31 |
setTitle({ commit }, title) { |
|
32 |
state.title = title |
|
33 |
} |
|
34 |
} |
|
35 |
|
|
36 |
export default { |
|
37 |
namespaced: true, |
|
38 |
state, |
|
39 |
mutations, |
|
40 |
actions |
|
41 |
} |
|
42 |
|