theme 模块
Former-commit-id: 5a60f7a68cfa3c9effbf33aee1a0bf606cb7a045 [formerly 5a60f7a68cfa3c9effbf33aee1a0bf606cb7a045 [formerly 5a60f7a68cfa3c9effbf33aee1a0bf606cb7a045 [formerly 5a60f7a68cfa3c9effbf33aee1a0bf606cb7a045 [formerly afdd5cb7b4d018f68b61257181f089438a12fa44 [formerly 6fdb6e759e339cd17c8d76d09d50b902fce8b74d]]]]] Former-commit-id: 6e388aa8ce29cec9d8901ed1b11d8fe11a0cf2d4 Former-commit-id: c6c36e452f960cb9b24d73d65b28907e40c621b4 Former-commit-id: 7685d8e053d9f26643092bf32e74844d6cf89446 [formerly 8cfb43881c4ed2ac4facf1bd95ff6ac901dc41ba] Former-commit-id: 8493ae32e3635ee733b09d558eb9049154883ebf Former-commit-id: 728960b5d4f3ebf00130d78edb964beb3321fe59 Former-commit-id: 978d3701efedbcce3d5c694eaed1d34537cdf561 Former-commit-id: 4fd5476f29dd398a103a12d0f820e4d70750c97d Former-commit-id: 2580f2041c87b19410c4bff2a99ec6a94727e766
This commit is contained in:
@@ -1 +1 @@
|
||||
e0ff5bbbd75335a8ba226e4922c3653e3627d0c8
|
||||
e2e9f9e3f236b74d6b87a1b9a3865b19b4afc9fb
|
||||
@@ -37,7 +37,7 @@ export default {
|
||||
this.commit('d2admin/util/dbValueSetByUser', {
|
||||
dbName: 'sys',
|
||||
path: 'menu.asideCollapse',
|
||||
value: collapse
|
||||
value: state.asideCollapse
|
||||
})
|
||||
},
|
||||
/**
|
||||
|
||||
60
src/store/modules/d2admin/modules/theme.js
Normal file
60
src/store/modules/d2admin/modules/theme.js
Normal file
@@ -0,0 +1,60 @@
|
||||
import list from '@/assets/style/theme/list.js'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
// 主题
|
||||
list,
|
||||
// 现在激活的主题 这应该是一个名字 不是对象
|
||||
activeName: list[0].name
|
||||
},
|
||||
getters: {
|
||||
/**
|
||||
* @description 返回当前的主题信息 不是一个名字 而是当前激活主题的所有数据
|
||||
* @param {Object} state vuex state
|
||||
*/
|
||||
activeSetting (state) {
|
||||
return state.list.find(theme => theme.name === state.activeName)
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
/**
|
||||
* @description 激活一个主题(应用到dom上)
|
||||
* @param {Object} state vuex state
|
||||
* @param {String} themeValue 需要激活的主题名称
|
||||
*/
|
||||
set (state, themeName) {
|
||||
// 检查这个主题在主题列表里是否存在
|
||||
state.activeName = state.list.find(e => e.name === themeName) ? themeName : state.list[0].name
|
||||
// 将 vuex 中的主题应用到 dom
|
||||
this.commit('d2admin/theme/dom')
|
||||
// 持久化
|
||||
this.commit('d2admin/util/dbValueSetByUser', {
|
||||
dbName: 'sys',
|
||||
path: 'theme.activeName',
|
||||
value: state.activeName
|
||||
})
|
||||
},
|
||||
/**
|
||||
* @description 从数据库加载主题设置
|
||||
* @param {Object} state vuex state
|
||||
*/
|
||||
async load (state) {
|
||||
// store 赋值
|
||||
state.activeName = await this.dispatch('d2admin/util/dbValueGetByUser', {
|
||||
dbName: 'sys',
|
||||
path: 'theme.activeName',
|
||||
defaultValue: state.list[0].name
|
||||
})
|
||||
// 更新到页面
|
||||
this.commit('d2admin/theme/dom')
|
||||
},
|
||||
/**
|
||||
* @description 将 vuex 中的主题应用到 dom
|
||||
* @param {Object} state vuex state
|
||||
*/
|
||||
dom (state) {
|
||||
document.body.className = `theme-${state.activeName}`
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ export default {
|
||||
* @param {Object} state vuex state
|
||||
* @param {*} info info
|
||||
*/
|
||||
infoSet (state, info) {
|
||||
set (state, info) {
|
||||
// store 赋值
|
||||
state.info = info
|
||||
// 持久化
|
||||
@@ -26,7 +26,7 @@ export default {
|
||||
* @description 从数据库取用户数据
|
||||
* @param {Object} state vuex state
|
||||
*/
|
||||
async infoLoad (state) {
|
||||
async load (state) {
|
||||
// store 赋值
|
||||
state.info = await this.dispatch('d2admin/util/dbValueGetByUser', {
|
||||
dbName: 'sys',
|
||||
|
||||
Reference in New Issue
Block a user