theme
Former-commit-id: 3fb5e37f648c98c9636ba8ac88f683e52cf8435e [formerly 3fb5e37f648c98c9636ba8ac88f683e52cf8435e [formerly 3fb5e37f648c98c9636ba8ac88f683e52cf8435e [formerly 3fb5e37f648c98c9636ba8ac88f683e52cf8435e [formerly 6f73a709ba4288f514deb2d74eb8603180b60b08 [formerly 28415f3ce8f01f9f26a0752a5f08d855bc4c56e2]]]]] Former-commit-id: f199fcac91cb1b3aeef843974db74d0f9d622699 Former-commit-id: eec00c4f5e48c1a19ac096d3a8900bbb7ae361db Former-commit-id: 9c7eb4c2f9115fda9b7d69e1c53444c99aeadb90 [formerly aac10159598f69b5c31ab136beb5ae11686ed2d6] Former-commit-id: d38da464fd9a05e1ec2defc27ac4d8d4bed05ec3 Former-commit-id: eadfd85257cb054017000aca8100e5e68b359e2d Former-commit-id: 9ce4b0a7b75a4ea9b9e24e96161a515bcadc6f04 Former-commit-id: ed40880ed8dda9601d859d5db5f19ab7bd42ade7 Former-commit-id: 3cbf4301dd98c44d8c4f1da0432922511ba9c7e3
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState, mapMutations } from 'vuex'
|
import { mapState, mapActions } from 'vuex'
|
||||||
export default {
|
export default {
|
||||||
name: 'd2-theme-list',
|
name: 'd2-theme-list',
|
||||||
data () {
|
data () {
|
||||||
@@ -36,7 +36,7 @@ export default {
|
|||||||
])
|
])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations('d2admin/theme', [
|
...mapActions('d2admin/theme', [
|
||||||
'set'
|
'set'
|
||||||
]),
|
]),
|
||||||
handleSelectTheme (name) {
|
handleSelectTheme (name) {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState, mapMutations } from 'vuex'
|
import { mapState, mapActions } from 'vuex'
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@@ -48,7 +48,7 @@ export default {
|
|||||||
])
|
])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations('d2admin/theme', [
|
...mapActions('d2admin/theme', [
|
||||||
'set'
|
'set'
|
||||||
]),
|
]),
|
||||||
handleSelectTheme (name) {
|
handleSelectTheme (name) {
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ export default {
|
|||||||
// DB -> store 加载用户名
|
// DB -> store 加载用户名
|
||||||
await dispatch('d2admin/user/load', null, { root: true })
|
await dispatch('d2admin/user/load', null, { root: true })
|
||||||
// DB -> store 加载主题
|
// DB -> store 加载主题
|
||||||
commit('d2admin/theme/load', null, { root: true })
|
await dispatch('d2admin/theme/load', null, { root: true })
|
||||||
// DB -> store 加载页面过渡效果设置
|
// DB -> store 加载页面过渡效果设置
|
||||||
commit('d2admin/transition/load', null, { root: true })
|
commit('d2admin/transition/load', null, { root: true })
|
||||||
// DB -> store 持久化数据加载上次退出时的多页列表
|
// DB -> store 持久化数据加载上次退出时的多页列表
|
||||||
|
|||||||
@@ -18,40 +18,50 @@ export default {
|
|||||||
return state.list.find(theme => theme.name === state.activeName)
|
return state.list.find(theme => theme.name === state.activeName)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mutations: {
|
actions: {
|
||||||
/**
|
/**
|
||||||
* @description 激活一个主题
|
* @description 激活一个主题
|
||||||
* @param {Object} state vuex state
|
* @param {Object} state vuex state
|
||||||
* @param {String} themeValue 需要激活的主题名称
|
* @param {String} themeValue 需要激活的主题名称
|
||||||
*/
|
*/
|
||||||
set (state, themeName) {
|
set ({ state, commit, dispatch }, themeName) {
|
||||||
// 检查这个主题在主题列表里是否存在
|
return new Promise(async resolve => {
|
||||||
state.activeName = state.list.find(e => e.name === themeName) ? themeName : state.list[0].name
|
// 检查这个主题在主题列表里是否存在
|
||||||
// 将 vuex 中的主题应用到 dom
|
state.activeName = state.list.find(e => e.name === themeName) ? themeName : state.list[0].name
|
||||||
this.commit('d2admin/theme/dom')
|
// 将 vuex 中的主题应用到 dom
|
||||||
// 持久化
|
commit('dom')
|
||||||
this.dispatch('d2admin/db/set', {
|
// 持久化
|
||||||
dbName: 'sys',
|
await dispatch('d2admin/db/set', {
|
||||||
path: 'theme.activeName',
|
dbName: 'sys',
|
||||||
value: state.activeName,
|
path: 'theme.activeName',
|
||||||
user: true
|
value: state.activeName,
|
||||||
|
user: true
|
||||||
|
}, { root: true })
|
||||||
|
// end
|
||||||
|
resolve()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* @description 从持久化数据加载主题设置
|
* @description 从持久化数据加载主题设置
|
||||||
* @param {Object} state vuex state
|
* @param {Object} state vuex state
|
||||||
*/
|
*/
|
||||||
async load (state) {
|
load ({ state, commit, dispatch }) {
|
||||||
// store 赋值
|
return new Promise(async resolve => {
|
||||||
state.activeName = await this.dispatch('d2admin/db/get', {
|
// store 赋值
|
||||||
dbName: 'sys',
|
state.activeName = await dispatch('d2admin/db/get', {
|
||||||
path: 'theme.activeName',
|
dbName: 'sys',
|
||||||
defaultValue: state.list[0].name,
|
path: 'theme.activeName',
|
||||||
user: true
|
defaultValue: state.list[0].name,
|
||||||
|
user: true
|
||||||
|
}, { root: true })
|
||||||
|
// 将 vuex 中的主题应用到 dom
|
||||||
|
commit('dom')
|
||||||
|
// end
|
||||||
|
resolve()
|
||||||
})
|
})
|
||||||
// 更新到页面
|
}
|
||||||
this.commit('d2admin/theme/dom')
|
},
|
||||||
},
|
mutations: {
|
||||||
/**
|
/**
|
||||||
* @description 将 vuex 中的主题应用到 dom
|
* @description 将 vuex 中的主题应用到 dom
|
||||||
* @param {Object} state vuex state
|
* @param {Object} state vuex state
|
||||||
|
|||||||
Reference in New Issue
Block a user