Commit ad575cc0 by Sendya

update defaultConfig

parent cd20a57d
...@@ -14,36 +14,56 @@ ...@@ -14,36 +14,56 @@
<h3 class="setting-drawer-index-title">整体风格设置</h3> <h3 class="setting-drawer-index-title">整体风格设置</h3>
<div class="setting-drawer-index-blockChecbox"> <div class="setting-drawer-index-blockChecbox">
<div class="setting-drawer-index-item" @click="changeMenuTheme('dark')"> <a-tooltip>
<img src="https://gw.alipayobjects.com/zos/rmsportal/LCkqqYNmvBEbokSDscrm.svg" alt="dark"> <template slot="title">
<div class="setting-drawer-index-selectIcon" v-if="theme === 'dark'"> 暗色菜单风格
<a-icon type="check"/> </template>
<div class="setting-drawer-index-item" @click="changeMenuTheme('dark')">
<img src="https://gw.alipayobjects.com/zos/rmsportal/LCkqqYNmvBEbokSDscrm.svg" alt="dark">
<div class="setting-drawer-index-selectIcon" v-if="navTheme === 'dark'">
<a-icon type="check"/>
</div>
</div> </div>
</div> </a-tooltip>
<div class="setting-drawer-index-item" @click="changeMenuTheme('light')">
<img src="https://gw.alipayobjects.com/zos/rmsportal/jpRkZQMyYRryryPNtyIC.svg" alt="light"> <a-tooltip>
<div class="setting-drawer-index-selectIcon" v-if="theme !== 'dark'"> <template slot="title">
<a-icon type="check"/> 亮色菜单风格
</template>
<div class="setting-drawer-index-item" @click="changeMenuTheme('light')">
<img src="https://gw.alipayobjects.com/zos/rmsportal/jpRkZQMyYRryryPNtyIC.svg" alt="light">
<div class="setting-drawer-index-selectIcon" v-if="navTheme !== 'dark'">
<a-icon type="check"/>
</div>
</div> </div>
</div> </a-tooltip>
</div> </div>
</div> </div>
<div :style="{ marginBottom: '24px' }"> <div :style="{ marginBottom: '24px' }">
<h3 class="setting-drawer-index-title">主题色</h3> <h3 class="setting-drawer-index-title">主题色</h3>
<div> <div style="height: 20px">
<a-tooltip class="setting-drawer-theme-color-colorBlock" v-for="(item, index) in colorList" :key="index"> <a-tooltip class="setting-drawer-theme-color-colorBlock" v-for="(item, index) in colorList" :key="index">
<template slot='title'> <template slot='title'>
{{ item.key }} {{ item.key }}
</template> </template>
<a-tag :color="item.color" @click="changeColor(item)"> <a-tag :color="item.color" @click="changeColor(item.color)">
<a-icon type="check" v-if="item.color === colorObj.color"></a-icon> <a-icon type="check" v-if="item.color === primaryColor"></a-icon>
</a-tag> </a-tag>
</a-tooltip> </a-tooltip>
</div> </div>
</div> </div>
<a-divider />
<div :style="{ marginBottom: '24px' }">
<a-alert type="warning">
<span slot="message">
配置栏只在开发环境用于预览,生产环境不会展现,请手动修改配置文件
<a href="https://github.com/sendya/ant-design-pro-vue/blob/master/src/defaultConfig.js" target="_blank">src/defaultConfig.js</a>
</span>
</a-alert>
</div>
</div> </div>
<div class="setting-drawer-index-handle" @click="toggle"> <div class="setting-drawer-index-handle" @click="toggle">
<a-icon type="setting" v-if="!visible"/> <a-icon type="setting" v-if="!visible"/>
...@@ -62,35 +82,35 @@ ...@@ -62,35 +82,35 @@
const colorList = [ const colorList = [
{ {
key: 'dust', key: '薄暮',
color: '#F5222D', color: '#F5222D',
}, },
{ {
key: 'volcano', key: '火山',
color: '#FA541C', color: '#FA541C',
}, },
{ {
key: 'sunset', key: '日暮',
color: '#FAAD14', color: '#FAAD14',
}, },
{ {
key: 'cyan', key: '明青',
color: '#13C2C2', color: '#13C2C2',
}, },
{ {
key: 'green', key: '极光绿',
color: '#52C41A', color: '#52C41A',
}, },
{ {
key: 'daybreak', key: '拂晓蓝(默认)',
color: '#1890FF', color: '#1890FF',
}, },
{ {
key: 'geekblue', key: '极客蓝',
color: '#2F54EB', color: '#2F54EB',
}, },
{ {
key: 'purple', key: '酱紫',
color: '#722ED1', color: '#722ED1',
}, },
]; ];
...@@ -107,8 +127,8 @@ ...@@ -107,8 +127,8 @@
}, },
computed: { computed: {
...mapState({ ...mapState({
theme: state => state.app.theme, navTheme: state => state.app.theme,
colorObj: state => state.app.color, primaryColor: state => state.app.color,
}) })
}, },
mounted () { mounted () {
...@@ -117,8 +137,8 @@ ...@@ -117,8 +137,8 @@
vm.visible = false vm.visible = false
}, 1) }, 1)
// 当主题色不是默认色时,才进行主题编译 // 当主题色不是默认色时,才进行主题编译
if (this.colorObj.color !== config.color.color) { if (this.primaryColor !== config.primaryColor) {
updateTheme(this.colorObj.color) updateTheme(this.primaryColor)
} }
}, },
methods: { methods: {
...@@ -135,9 +155,9 @@ ...@@ -135,9 +155,9 @@
this.$store.dispatch('ToggleTheme', theme) this.$store.dispatch('ToggleTheme', theme)
}, },
changeColor(color) { changeColor(color) {
if (this.colorObj.color !== color.color) { if (this.primaryColor !== color) {
this.$store.dispatch('ToggleColor', color) this.$store.dispatch('ToggleColor', color)
updateTheme(color.color) updateTheme(color)
} }
} }
}, },
......
export default { export default {
color: { primaryColor: '#1890FF', // primary color of ant design
key: 'daybreak', navTheme: 'dark', // theme for nav menu
color: '#1890FF' colorWeak: false,
}, // vue-ls options
theme: 'dark', storageOptions: {
colorWeak: false namespace: 'pro__', // key prefix
name: 'ls', // name variable Vue.[ls] or this.[$ls],
storage: 'local', // storage name session, local, memory
}
} }
\ No newline at end of file
...@@ -21,15 +21,13 @@ Vue.filter('dayjs', function(dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') { ...@@ -21,15 +21,13 @@ Vue.filter('dayjs', function(dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
return dayjs(dataStr).format(pattern) return dayjs(dataStr).format(pattern)
}) })
const options = { Vue.filter('moment', function(dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
namespace: 'ant__', // key prefix return dayjs(dataStr).format(pattern)
name: 'ls', // name variable Vue.[ls] or this.[$ls], })
storage: 'local', // storage name session, local, memory
}
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.use(Storage, options) Vue.use(Storage, config.storageOptions)
Vue.use(Antd) Vue.use(Antd)
Vue.use(VueAxios, router) Vue.use(VueAxios, router)
Vue.use(Viser) Vue.use(Viser)
...@@ -39,10 +37,9 @@ new Vue({ ...@@ -39,10 +37,9 @@ new Vue({
store, store,
mounted () { mounted () {
store.commit('SET_SIDEBAR_TYPE', Vue.ls.get(SIDEBAR_TYPE, false)) store.commit('SET_SIDEBAR_TYPE', Vue.ls.get(SIDEBAR_TYPE, false))
store.commit('TOGGLE_THEME', Vue.ls.get(DEFAULT_THEME, config.theme)) store.commit('TOGGLE_THEME', Vue.ls.get(DEFAULT_THEME, config.navTheme))
store.commit('TOGGLE_COLOR', Vue.ls.get(DEFAULT_COLOR, config.color)) store.commit('TOGGLE_COLOR', Vue.ls.get(DEFAULT_COLOR, config.primaryColor))
store.commit('SET_TOKEN', Vue.ls.get(ACCESS_TOKEN)) store.commit('SET_TOKEN', Vue.ls.get(ACCESS_TOKEN))
}, },
render: h => h(App) render: h => h(App)
}).$mount('#app') }).$mount('#app')
...@@ -34,7 +34,7 @@ export const constantRouterMap = [ ...@@ -34,7 +34,7 @@ export const constantRouterMap = [
path: '/', path: '/',
component: Layout, component: Layout,
redirect: '/login', redirect: '/login',
name: '首页', name: 'home',
hidden: true hidden: true
} }
] ]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment