Skip to content

Commit a4794e8

Browse files
committed
fix: account custom page
1 parent c89883d commit a4794e8

File tree

5 files changed

+69
-39
lines changed

5 files changed

+69
-39
lines changed

src/components/layout/LayoutFooter.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
<div class="footer">
33
<div class="links">
44
<a href="#">Pro 首页</a>
5-
<a href="#"><a-icon type="github"/></a>
6-
<a href="#">Ant Design</a>
5+
<a href="https://github.com/ant-design/ant-design-pro"><a-icon type="github"/></a>
6+
<a href="https://ant.design/">Ant Design</a>
7+
<a href="https://vuecomponent.github.io/ant-design-vue/docs/vue/introduce-cn/">Vue Antd</a>
78
</div>
89
<div class="copyright">
910
Copyright <a-icon type="copyright" /> 2018 <span>白鹭学园技术组出品</span>

src/components/layout/LayoutMain.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<sider-menu
55
:menus="menus"
6-
:theme="menuTheme"
6+
:theme="theme"
77
v-if="menuMode === 'inline'"
88
:mode="menuMode"
99
:collapsed="!siderOpen || collapsed"
@@ -54,7 +54,8 @@
5454
},
5555
computed: {
5656
...mapState({
57-
siderOpen: state => state.app.sidebar.opened
57+
siderOpen: state => state.app.sidebar.opened,
58+
theme: state => state.app.theme
5859
})
5960
},
6061
methods: {

src/store/getters.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const getters = {
22
device: state => state.app.device,
3+
theme: state => state.app.theme,
34
token: state => state.user.token,
45
avatar: state => state.user.avatar,
56
nickname: state => state.user.name,

src/store/modules/app.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
1-
import Cookies from 'js-cookie'
1+
import { getStore, setStore } from "@/utils/storage"
2+
3+
let theme = getStore('_DEFAULT_THEME')
24

35
const app = {
46
state: {
57
sidebar: {
6-
opened: !+Cookies.get('sidebarStatus'),
8+
opened: !+getStore('sidebarStatus'),
79
withoutAnimation: false
810
},
9-
device: 'desktop'
11+
device: 'desktop',
12+
theme: !theme ? 'dark' : theme
1013
},
1114
mutations: {
1215
TOGGLE_SIDEBAR: state => {
1316
if (state.sidebar.opened) {
14-
Cookies.set('sidebarStatus', 1)
17+
setStore('sidebarStatus', 1)
1518
} else {
16-
Cookies.set('sidebarStatus', 0)
19+
setStore('sidebarStatus', 0)
1720
}
1821
state.sidebar.opened = !state.sidebar.opened
1922
state.sidebar.withoutAnimation = false
2023
},
2124
CLOSE_SIDEBAR: (state, withoutAnimation) => {
22-
Cookies.set('sidebarStatus', 1)
25+
setStore('sidebarStatus', 1)
2326
state.sidebar.opened = false
2427
state.sidebar.withoutAnimation = withoutAnimation
2528
},
2629
TOGGLE_DEVICE: (state, device) => {
2730
state.device = device
31+
},
32+
TOGGLE_THEME: (state, theme) => {
33+
setStore('_DEFAULT_THEME', theme)
34+
state.theme = theme
2835
}
2936
},
3037
actions: {
@@ -36,6 +43,9 @@ const app = {
3643
},
3744
ToggleDevice({ commit }, device) {
3845
commit('TOGGLE_DEVICE', device)
46+
},
47+
ToggleTheme({ commit }, theme) {
48+
commit('TOGGLE_THEME', theme)
3949
}
4050
}
4151
}

src/views/account/settings/Custom.vue

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,27 @@
1-
<template>
2-
<a-list
3-
itemLayout="horizontal"
4-
:dataSource="data"
5-
>
6-
<a-list-item slot="renderItem" slot-scope="item, index" :key="index">
7-
<a-list-item-meta>
8-
<a slot="title" href="https://vuecomponent.github.io/ant-design-vue/">{{ item.title }}</a>
9-
<span slot="description">
10-
<span class="security-list-description">{{ item.description }}</span>
11-
<span v-if="item.value"> : </span>
12-
<span class="security-list-value">{{ item.value }}</span>
13-
</span>
14-
</a-list-item-meta>
15-
<template v-if="item.actions">
16-
<a slot="actions" @click="item.actions.callback">{{ item.actions.title }}</a>
17-
</template>
1+
<script>
2+
import { mapState } from "vuex"
3+
import ASwitch from 'ant-design-vue/es/switch'
4+
import AList from "ant-design-vue/es/list"
5+
import AListItem from "ant-design-vue/es/list/Item"
186
19-
</a-list-item>
20-
</a-list>
21-
</template>
7+
const Meta = AListItem.Meta
228
23-
<script>
249
export default {
25-
name: "Security",
10+
components: {
11+
AListItem,
12+
AList,
13+
ASwitch,
14+
Meta
15+
},
2616
data () {
2717
return {
28-
theme: 'dark',
29-
30-
data: [
31-
{ title: '主题色' , description: '设置全局主题色', value: this.theme, actions: { title: '修改', callback: () => { this.$message.info('This is a normal message'); } } },
32-
]
3318
}
3419
},
20+
computed: {
21+
...mapState({
22+
theme: state => state.app.theme
23+
})
24+
},
3525
filters: {
3626
themeFilter(theme) {
3727
const themeMap = {
@@ -43,12 +33,39 @@
4333
},
4434
methods: {
4535
onChange (checked) {
36+
37+
console.log('click:', checked)
4638
if (checked) {
47-
this.theme = 'dark'
39+
this.$store.dispatch('ToggleTheme', 'dark')
4840
} else {
49-
this.theme = 'light'
41+
this.$store.dispatch('ToggleTheme', 'light')
5042
}
5143
}
44+
},
45+
render () {
46+
return (
47+
<AList itemLayout="horizontal">
48+
<AListItem>
49+
<Meta>
50+
<a slot="title">风格配色</a>
51+
<span slot="description">
52+
整体风格配色设置
53+
</span>
54+
</Meta>
55+
<div slot="actions">
56+
<ASwitch checkedChildren="暗色" unCheckedChildren="白色" defaultChecked={this.theme === 'dark' && true || false} onChange={this.onChange} />
57+
</div>
58+
</AListItem>
59+
<AListItem>
60+
<Meta>
61+
<a slot="title">主题色</a>
62+
<span slot="description">
63+
页面风格配色: <a></a>
64+
</span>
65+
</Meta>
66+
</AListItem>
67+
</AList>
68+
)
5269
}
5370
}
5471
</script>

0 commit comments

Comments
 (0)