Skip to content

Commit a85c438

Browse files
committed
feat: add setting drawer
1 parent 5005af1 commit a85c438

File tree

9 files changed

+262
-37
lines changed

9 files changed

+262
-37
lines changed

config/themePluginConfig.js

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
export default {
2+
theme: [
3+
{
4+
key: 'dark',
5+
fileName: 'dark.css',
6+
theme: 'dark'
7+
},
8+
{
9+
key: '#F5222D',
10+
fileName: '#F5222D.css',
11+
modifyVars: {
12+
'@primary-color': '#F5222D'
13+
}
14+
},
15+
{
16+
key: '#FA541C',
17+
fileName: '#FA541C.css',
18+
modifyVars: {
19+
'@primary-color': '#FA541C'
20+
}
21+
},
22+
{
23+
key: '#FAAD14',
24+
fileName: '#FAAD14.css',
25+
modifyVars: {
26+
'@primary-color': '#FAAD14'
27+
}
28+
},
29+
{
30+
key: '#13C2C2',
31+
fileName: '#13C2C2.css',
32+
modifyVars: {
33+
'@primary-color': '#13C2C2'
34+
}
35+
},
36+
{
37+
key: '#52C41A',
38+
fileName: '#52C41A.css',
39+
modifyVars: {
40+
'@primary-color': '#52C41A'
41+
}
42+
},
43+
{
44+
key: '#2F54EB',
45+
fileName: '#2F54EB.css',
46+
modifyVars: {
47+
'@primary-color': '#2F54EB'
48+
}
49+
},
50+
{
51+
key: '#722ED1',
52+
fileName: '#722ED1.css',
53+
modifyVars: {
54+
'@primary-color': '#722ED1'
55+
}
56+
},
57+
58+
{
59+
key: '#F5222D',
60+
theme: 'dark',
61+
fileName: 'dark-#F5222D.css',
62+
modifyVars: {
63+
'@primary-color': '#F5222D'
64+
}
65+
},
66+
{
67+
key: '#FA541C',
68+
theme: 'dark',
69+
fileName: 'dark-#FA541C.css',
70+
modifyVars: {
71+
'@primary-color': '#FA541C'
72+
}
73+
},
74+
{
75+
key: '#FAAD14',
76+
theme: 'dark',
77+
fileName: 'dark-#FAAD14.css',
78+
modifyVars: {
79+
'@primary-color': '#FAAD14'
80+
}
81+
},
82+
{
83+
key: '#13C2C2',
84+
theme: 'dark',
85+
fileName: 'dark-#13C2C2.css',
86+
modifyVars: {
87+
'@primary-color': '#13C2C2'
88+
}
89+
},
90+
{
91+
key: '#52C41A',
92+
theme: 'dark',
93+
fileName: 'dark-#52C41A.css',
94+
modifyVars: {
95+
'@primary-color': '#52C41A'
96+
}
97+
},
98+
{
99+
key: '#2F54EB',
100+
theme: 'dark',
101+
fileName: 'dark-#2F54EB.css',
102+
modifyVars: {
103+
'@primary-color': '#2F54EB'
104+
}
105+
},
106+
{
107+
key: '#722ED1',
108+
theme: 'dark',
109+
fileName: 'dark-#722ED1.css',
110+
modifyVars: {
111+
'@primary-color': '#722ED1'
112+
}
113+
}
114+
]
115+
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
"postinstall": "opencollective-postinstall"
1313
},
1414
"dependencies": {
15-
"@ant-design-vue/pro-layout": "^0.2.5",
15+
"@ant-design-vue/pro-layout": "^0.2.7",
1616
"@antv/data-set": "^0.10.2",
17-
"ant-design-vue": "1.5.3",
17+
"ant-design-vue": "1.5.5",
1818
"axios": "^0.19.0",
1919
"core-js": "^3.1.2",
2020
"enquire.js": "^2.1.6",

src/components/GlobalHeader/RightContent.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ export default {
1616
SelectLang
1717
},
1818
props: {
19+
topMenu: {
20+
type: Boolean,
21+
required: true
22+
},
1923
theme: {
2024
type: String,
21-
default: 'light'
25+
required: true
2226
}
2327
},
2428
data () {
@@ -30,7 +34,10 @@ export default {
3034
},
3135
computed: {
3236
wrpCls () {
33-
return { 'ant-pro-global-header-index-right': true, [`ant-pro-global-header-index-${this.theme}`]: true }
37+
return {
38+
'ant-pro-global-header-index-right': true,
39+
[`ant-pro-global-header-index-${this.topMenu && this.theme || 'light'}`]: true
40+
}
3441
}
3542
},
3643
mounted () {

src/layouts/BasicLayout.vue

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@
33
title="Ant Design Pro"
44
:menus="menus"
55
:collapsed="collapsed"
6-
:theme="theme"
7-
:layout="layout"
8-
:contentWidth="contentWidth"
9-
:auto-hide-header="autoHideHeader"
106
:mediaQuery="query"
117
:isMobile="isMobile"
128
:handleMediaQuery="handleMediaQuery"
139
:handleCollapse="handleCollapse"
1410
:logo="logoRender"
1511
:i18nRender="i18nRender"
12+
v-bind="settings"
1613
>
14+
<setting-drawer :settings="settings" @change="handleSettingChange" />
1715
<template v-slot:rightContentRender>
18-
<right-content />
16+
<right-content :top-menu="settings.layout === 'topmenu'" :theme="settings.theme" />
1917
</template>
2018
<template v-slot:footerRender>
2119
<global-footer />
@@ -25,37 +23,46 @@
2523
</template>
2624

2725
<script>
26+
import { SettingDrawer } from '@ant-design-vue/pro-layout'
2827
import { i18nRender } from '@/locales'
2928
import { mapState } from 'vuex'
29+
import { SIDEBAR_TYPE, TOGGLE_MOBILE_TYPE } from '@/store/mutation-types'
30+
3031
import RightContent from '@/components/GlobalHeader/RightContent'
3132
import GlobalFooter from '@/components/GlobalFooter'
32-
3333
import LogoSvg from '../assets/logo.svg?inline'
34-
import { SIDEBAR_TYPE, TOGGLE_MOBILE_TYPE } from '@/store/mutation-types'
3534
3635
export default {
3736
name: 'BasicLayout',
3837
components: {
38+
SettingDrawer,
3939
RightContent,
40-
GlobalFooter,
41-
LogoSvg
40+
GlobalFooter
4241
},
4342
data () {
4443
return {
4544
// base
4645
menus: [],
4746
// 侧栏收起状态
4847
collapsed: false,
49-
// 自动隐藏头部栏
50-
autoHideHeader: false,
48+
settings: {
49+
// 布局类型
50+
layout: 'sidemenu', // 'sidemenu', 'topmenu'
51+
// 定宽: true / 流式: false
52+
contentWidth: true,
53+
// 主题 'dark' | 'light'
54+
theme: 'dark',
55+
// 主色调
56+
primaryColor: '#1890ff',
57+
fixedHeader: false,
58+
fixSiderbar: false,
59+
60+
hideHintAlert: false,
61+
hideCopyButton: false
62+
},
5163
// 媒体查询
5264
query: {},
53-
// 布局类型
54-
layout: 'sidemenu', // 'sidemenu', 'topmenu'
55-
// 定宽: true / 流式: false
56-
contentWidth: true,
57-
// 主题 'dark' | 'light'
58-
theme: 'dark',
65+
5966
// 是否手机模式
6067
isMobile: false
6168
}
@@ -104,6 +111,23 @@ export default {
104111
handleCollapse (val) {
105112
this.collapsed = val
106113
},
114+
handleSettingChange ({ type, value }) {
115+
console.log('type', type, value)
116+
type && (this.settings[type] = value)
117+
switch (type) {
118+
case 'contentWidth':
119+
this.settings[type] = value === 'Fixed'
120+
break
121+
case 'layout':
122+
if (value === 'sidemenu') {
123+
this.settings.contentWidth = false
124+
} else {
125+
this.settings.fixSiderbar = false
126+
this.settings.contentWidth = true
127+
}
128+
break
129+
}
130+
},
107131
logoRender () {
108132
return <LogoSvg />
109133
}

src/locales/lang/en-US.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,27 @@ const locale = {
1313
'menu.dashboard': 'Dashboard',
1414
'menu.dashboard.analysis': 'Analysis',
1515
'menu.dashboard.monitor': 'Monitor',
16-
'menu.dashboard.workplace': 'Workplace'
16+
'menu.dashboard.workplace': 'Workplace',
17+
18+
'app.setting.pagestyle': 'Page style setting',
19+
'app.setting.pagestyle.light': 'Light style',
20+
'app.setting.pagestyle.dark': 'Dark style',
21+
'app.setting.pagestyle.realdark': 'RealDark style',
22+
'app.setting.themecolor': 'Theme Color',
23+
'app.setting.navigationmode': 'Navigation Mode',
24+
'app.setting.content-width': 'Content Width',
25+
'app.setting.fixedheader': 'Fixed Header',
26+
'app.setting.fixedsidebar': 'Fixed Sidebar',
27+
'app.setting.sidemenu': 'Side Menu Layout',
28+
'app.setting.topmenu': 'Top Menu Layout',
29+
'app.setting.content-width.fixed': 'Fixed',
30+
'app.setting.content-width.fluid': 'Fluid',
31+
'app.setting.othersettings': 'Other Settings',
32+
'app.setting.weakmode': 'Weak Mode',
33+
'app.setting.copy': 'Copy Setting',
34+
'app.setting.loading': 'Loading theme',
35+
'app.setting.copyinfo': 'copy success,please replace defaultSettings in src/models/setting.js',
36+
'app.setting.production.hint': 'Setting panel shows in development environment only, please manually modify'
1737
}
1838

1939
export default {

src/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import store from './store/'
99
import i18n from './locales'
1010
import { VueAxios } from './utils/request'
1111
import ProLayout, { PageHeaderWrapper } from '@ant-design-vue/pro-layout'
12+
import themePluginConfig from '../config/themePluginConfig'
1213

1314
// mock
1415
// WARNING: `mockjs` NOT SUPPORT `IE` PLEASE DO NOT USE IN `production` ENV.
@@ -27,6 +28,8 @@ Vue.use(VueAxios)
2728
Vue.component('pro-layout', ProLayout)
2829
Vue.component('page-header-wrapper', PageHeaderWrapper)
2930

31+
window.umi_plugin_ant_themeVar = themePluginConfig.theme
32+
3033
new Vue({
3134
router,
3235
store,

src/views/list/search/SearchLayout.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@
1818
</template>
1919

2020
<script>
21+
const getActiveKey = (path) => {
22+
switch (path) {
23+
case '/list/search/article':
24+
return '1'
25+
case '/list/search/project':
26+
return '2'
27+
case '/list/search/application':
28+
return '3'
29+
default:
30+
return '1'
31+
}
32+
}
2133
export default {
2234
name: 'SearchLayout',
2335
data () {
@@ -31,6 +43,13 @@ export default {
3143
search: true
3244
}
3345
},
46+
created () {
47+
this.tabActiveKey = getActiveKey(this.$route.path)
48+
49+
this.$watch('$route', (val) => {
50+
this.tabActiveKey = getActiveKey(val.path)
51+
})
52+
},
3453
methods: {
3554
handleTabChange (key) {
3655
this.tabActiveKey = key

src/views/profile/advanced/Advanced.vue

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,30 @@
4343

4444
<a-card :bordered="false" title="流程进度">
4545
<a-steps :direction="isMobile && 'vertical' || 'horizontal'" :current="1" progressDot>
46-
<a-step title="创建项目">
46+
<a-step>
47+
<template v-slot:title>
48+
<span>创建项目</span>
49+
</template>
50+
<template v-slot:description>
51+
<div class="antd-pro-pages-profile-advanced-style-stepDescription">
52+
曲丽丽<a-icon type="dingding" style="margin-left: 8px;" />
53+
<div>2016-12-12 12:32</div>
54+
</div>
55+
</template>
4756
</a-step>
48-
<a-step title="部门初审">
49-
</a-step>
50-
<a-step title="财务复核">
51-
</a-step>
52-
<a-step title="完成">
57+
<a-step>
58+
<template v-slot:title>
59+
<span>部门初审</span>
60+
</template>
61+
<template v-slot:description>
62+
<div class="antd-pro-pages-profile-advanced-style-stepDescription">
63+
周毛毛<a-icon type="dingding" style="color: rgb(0, 160, 233); margin-left: 8px;" />
64+
<div><a>催一下</a></div>
65+
</div>
66+
</template>
5367
</a-step>
68+
<a-step title="财务复核" />
69+
<a-step title="完成" />
5470
</a-steps>
5571
</a-card>
5672

0 commit comments

Comments
 (0)