Commit a4794e8b by Sendya

fix: account custom page

parent c89883dc
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
<div class="footer"> <div class="footer">
<div class="links"> <div class="links">
<a href="#">Pro 首页</a> <a href="#">Pro 首页</a>
<a href="#"><a-icon type="github"/></a> <a href="https://github.com/ant-design/ant-design-pro"><a-icon type="github"/></a>
<a href="#">Ant Design</a> <a href="https://ant.design/">Ant Design</a>
<a href="https://vuecomponent.github.io/ant-design-vue/docs/vue/introduce-cn/">Vue Antd</a>
</div> </div>
<div class="copyright"> <div class="copyright">
Copyright <a-icon type="copyright" /> 2018 <span>白鹭学园技术组出品</span> Copyright <a-icon type="copyright" /> 2018 <span>白鹭学园技术组出品</span>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<sider-menu <sider-menu
:menus="menus" :menus="menus"
:theme="menuTheme" :theme="theme"
v-if="menuMode === 'inline'" v-if="menuMode === 'inline'"
:mode="menuMode" :mode="menuMode"
:collapsed="!siderOpen || collapsed" :collapsed="!siderOpen || collapsed"
...@@ -54,7 +54,8 @@ ...@@ -54,7 +54,8 @@
}, },
computed: { computed: {
...mapState({ ...mapState({
siderOpen: state => state.app.sidebar.opened siderOpen: state => state.app.sidebar.opened,
theme: state => state.app.theme
}) })
}, },
methods: { methods: {
......
const getters = { const getters = {
device: state => state.app.device, device: state => state.app.device,
theme: state => state.app.theme,
token: state => state.user.token, token: state => state.user.token,
avatar: state => state.user.avatar, avatar: state => state.user.avatar,
nickname: state => state.user.name, nickname: state => state.user.name,
......
import Cookies from 'js-cookie' import { getStore, setStore } from "@/utils/storage"
let theme = getStore('_DEFAULT_THEME')
const app = { const app = {
state: { state: {
sidebar: { sidebar: {
opened: !+Cookies.get('sidebarStatus'), opened: !+getStore('sidebarStatus'),
withoutAnimation: false withoutAnimation: false
}, },
device: 'desktop' device: 'desktop',
theme: !theme ? 'dark' : theme
}, },
mutations: { mutations: {
TOGGLE_SIDEBAR: state => { TOGGLE_SIDEBAR: state => {
if (state.sidebar.opened) { if (state.sidebar.opened) {
Cookies.set('sidebarStatus', 1) setStore('sidebarStatus', 1)
} else { } else {
Cookies.set('sidebarStatus', 0) setStore('sidebarStatus', 0)
} }
state.sidebar.opened = !state.sidebar.opened state.sidebar.opened = !state.sidebar.opened
state.sidebar.withoutAnimation = false state.sidebar.withoutAnimation = false
}, },
CLOSE_SIDEBAR: (state, withoutAnimation) => { CLOSE_SIDEBAR: (state, withoutAnimation) => {
Cookies.set('sidebarStatus', 1) setStore('sidebarStatus', 1)
state.sidebar.opened = false state.sidebar.opened = false
state.sidebar.withoutAnimation = withoutAnimation state.sidebar.withoutAnimation = withoutAnimation
}, },
TOGGLE_DEVICE: (state, device) => { TOGGLE_DEVICE: (state, device) => {
state.device = device state.device = device
},
TOGGLE_THEME: (state, theme) => {
setStore('_DEFAULT_THEME', theme)
state.theme = theme
} }
}, },
actions: { actions: {
...@@ -36,6 +43,9 @@ const app = { ...@@ -36,6 +43,9 @@ const app = {
}, },
ToggleDevice({ commit }, device) { ToggleDevice({ commit }, device) {
commit('TOGGLE_DEVICE', device) commit('TOGGLE_DEVICE', device)
},
ToggleTheme({ commit }, theme) {
commit('TOGGLE_THEME', theme)
} }
} }
} }
......
<template> <script>
<a-list import { mapState } from "vuex"
itemLayout="horizontal" import ASwitch from 'ant-design-vue/es/switch'
:dataSource="data" import AList from "ant-design-vue/es/list"
> import AListItem from "ant-design-vue/es/list/Item"
<a-list-item slot="renderItem" slot-scope="item, index" :key="index">
<a-list-item-meta>
<a slot="title" href="https://vuecomponent.github.io/ant-design-vue/">{{ item.title }}</a>
<span slot="description">
<span class="security-list-description">{{ item.description }}</span>
<span v-if="item.value"> : </span>
<span class="security-list-value">{{ item.value }}</span>
</span>
</a-list-item-meta>
<template v-if="item.actions">
<a slot="actions" @click="item.actions.callback">{{ item.actions.title }}</a>
</template>
</a-list-item> const Meta = AListItem.Meta
</a-list>
</template>
<script>
export default { export default {
name: "Security", components: {
AListItem,
AList,
ASwitch,
Meta
},
data () { data () {
return { return {
theme: 'dark',
data: [
{ title: '主题色' , description: '设置全局主题色', value: this.theme, actions: { title: '修改', callback: () => { this.$message.info('This is a normal message'); } } },
]
} }
}, },
computed: {
...mapState({
theme: state => state.app.theme
})
},
filters: { filters: {
themeFilter(theme) { themeFilter(theme) {
const themeMap = { const themeMap = {
...@@ -43,12 +33,39 @@ ...@@ -43,12 +33,39 @@
}, },
methods: { methods: {
onChange (checked) { onChange (checked) {
console.log('click:', checked)
if (checked) { if (checked) {
this.theme = 'dark' this.$store.dispatch('ToggleTheme', 'dark')
} else { } else {
this.theme = 'light' this.$store.dispatch('ToggleTheme', 'light')
} }
} }
},
render () {
return (
<AList itemLayout="horizontal">
<AListItem>
<Meta>
<a slot="title">风格配色</a>
<span slot="description">
整体风格配色设置
</span>
</Meta>
<div slot="actions">
<ASwitch checkedChildren="暗色" unCheckedChildren="白色" defaultChecked={this.theme === 'dark' && true || false} onChange={this.onChange} />
</div>
</AListItem>
<AListItem>
<Meta>
<a slot="title">主题色</a>
<span slot="description">
页面风格配色: <a></a>
</span>
</Meta>
</AListItem>
</AList>
)
} }
} }
</script> </script>
......
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