Skip to content

Commit 9bd5709

Browse files
committed
refactor: clear components
1 parent 54e9e63 commit 9bd5709

File tree

20 files changed

+4333
-4315
lines changed

20 files changed

+4333
-4315
lines changed

src/components/GlobalFooter/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<global-footer class="footer custom-render">
33
<template v-slot:links>
4+
<a href="https://www.github.com/vueComponent/pro-layout" target="_blank">Pro Layout</a>
45
<a href="https://www.github.com/vueComponent/ant-design-vue-pro" target="_blank">Github</a>
56
<a href="https://www.github.com/sendya/" target="_blank">@Sendya</a>
67
</template>

src/components/SettingDrawer/SettingDrawer.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,18 +171,15 @@
171171
</template>
172172

173173
<script>
174-
import { DetailList } from '@/components'
175174
import SettingItem from './SettingItem'
176175
import config from '@/config/defaultSettings'
177176
import { updateTheme, updateColorWeak, colorList } from './settingConfig'
178-
import { mixin, mixinDevice } from '@/utils/mixin'
179177
180178
export default {
181179
components: {
182-
DetailList,
183180
SettingItem
184181
},
185-
mixins: [mixin, mixinDevice],
182+
mixins: [],
186183
data () {
187184
return {
188185
visible: false,

src/components/SettingDrawer/settingConfig.js

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { message } from 'ant-design-vue/es'
1+
import message from 'ant-design-vue/es/message'
22
// import defaultSettings from '../defaultSettings';
33
import themeColor from './themeColor.js'
44

55
// let lessNodesAppended
6-
76
const colorList = [
87
{
98
key: '薄暮', color: '#F5222D'
@@ -33,72 +32,13 @@ const colorList = [
3332

3433
const updateTheme = newPrimaryColor => {
3534
const hideMessage = message.loading('正在切换主题!', 0)
36-
themeColor.changeColor(newPrimaryColor).finally(t => {
35+
themeColor.changeColor(newPrimaryColor).finally(() => {
3736
setTimeout(() => {
3837
hideMessage()
3938
}, 10)
4039
})
4140
}
4241

43-
/*
44-
const updateTheme = primaryColor => {
45-
// Don't compile less in production!
46-
/* if (process.env.NODE_ENV === 'production') {
47-
return;
48-
} * /
49-
// Determine if the component is remounted
50-
if (!primaryColor) {
51-
return
52-
}
53-
const hideMessage = message.loading('正在编译主题!', 0)
54-
function buildIt () {
55-
if (!window.less) {
56-
return
57-
}
58-
setTimeout(() => {
59-
window.less
60-
.modifyVars({
61-
'@primary-color': primaryColor
62-
})
63-
.then(() => {
64-
hideMessage()
65-
})
66-
.catch(() => {
67-
message.error('Failed to update theme')
68-
hideMessage()
69-
})
70-
}, 200)
71-
}
72-
if (!lessNodesAppended) {
73-
// insert less.js and color.less
74-
const lessStyleNode = document.createElement('link')
75-
const lessConfigNode = document.createElement('script')
76-
const lessScriptNode = document.createElement('script')
77-
lessStyleNode.setAttribute('rel', 'stylesheet/less')
78-
lessStyleNode.setAttribute('href', '/color.less')
79-
lessConfigNode.innerHTML = `
80-
window.less = {
81-
async: true,
82-
env: 'production',
83-
javascriptEnabled: true
84-
};
85-
`
86-
lessScriptNode.src = 'https://gw.alipayobjects.com/os/lib/less.js/3.8.1/less.min.js'
87-
lessScriptNode.async = true
88-
lessScriptNode.onload = () => {
89-
buildIt()
90-
lessScriptNode.onload = null
91-
}
92-
document.body.appendChild(lessStyleNode)
93-
document.body.appendChild(lessConfigNode)
94-
document.body.appendChild(lessScriptNode)
95-
lessNodesAppended = true
96-
} else {
97-
buildIt()
98-
}
99-
}
100-
*/
101-
10242
const updateColorWeak = colorWeak => {
10343
// document.body.className = colorWeak ? 'colorWeak' : '';
10444
const app = document.body.querySelector('#app')

src/config/router.config.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// eslint-disable-next-line
22
import { UserLayout, BasicLayout, BlankLayout } from '@/layouts'
33
import { bxAnaalyse } from '@/core/icons'
4-
import PageView from '@/layouts/PageView'
54

65
const RouteView = {
76
name: 'RouteView',
@@ -92,7 +91,7 @@ export const asyncRouterMap = [
9291
{
9392
path: '/list/basic-list',
9493
name: 'BasicList',
95-
component: () => import('@/views/list/StandardList'),
94+
component: () => import('@/views/list/BasicList'),
9695
meta: { title: '标准列表', keepAlive: true, permission: [ 'table' ] }
9796
},
9897
{
@@ -217,7 +216,7 @@ export const asyncRouterMap = [
217216
{
218217
path: '/account/center',
219218
name: 'center',
220-
component: () => import('@/views/account/center/Index'),
219+
component: () => import('@/views/account/center'),
221220
meta: { title: '个人中心', keepAlive: true, permission: [ 'user' ] }
222221
},
223222
{
@@ -261,9 +260,10 @@ export const asyncRouterMap = [
261260
]
262261
}
263262
]
264-
},
263+
}
265264

266265
// other
266+
/*
267267
{
268268
path: '/other',
269269
name: 'otherPage',
@@ -323,6 +323,7 @@ export const asyncRouterMap = [
323323
}
324324
]
325325
}
326+
*/
326327
]
327328
},
328329
{

src/layouts/UserLayout.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@
3131

3232
<script>
3333
import RouteView from './RouteView'
34-
import { mixinDevice } from '@/utils/mixin'
3534
3635
export default {
3736
name: 'UserLayout',
3837
components: { RouteView },
39-
mixins: [mixinDevice],
38+
mixins: [],
4039
data () {
4140
return {}
4241
},

src/store/mutation-types.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ export const CONTENT_WIDTH_TYPE = {
1717
Fluid: 'Fluid',
1818
Fixed: 'Fixed'
1919
}
20+
21+
export const NAV_THEME = {
22+
LIGHT: 'light',
23+
DARK: 'dark'
24+
}

src/views/account/center/Index.vue renamed to src/views/account/center/index.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<a-card :bordered="false">
66
<div class="account-center-avatarHolder">
77
<div class="avatar">
8-
<img :src="avatar()">
8+
<img :src="avatar">
99
</div>
10-
<div class="username">{{ nickname() }}</div>
10+
<div class="username">{{ nickname }}</div>
1111
<div class="bio">海纳百川,有容乃大</div>
1212
</div>
1313
<div class="account-center-detail">
@@ -33,14 +33,14 @@
3333
<a-tag
3434
:key="tag"
3535
:closable="index !== 0"
36-
:afterClose="() => handleTagClose(tag)"
36+
:close="() => handleTagClose(tag)"
3737
>{{ `${tag.slice(0, 20)}...` }}</a-tag>
3838
</a-tooltip>
3939
<a-tag
4040
v-else
4141
:key="tag"
4242
:closable="index !== 0"
43-
:afterClose="() => handleTagClose(tag)"
43+
:close="() => handleTagClose(tag)"
4444
>{{ tag }}</a-tag>
4545
</template>
4646
<a-input
@@ -136,12 +136,13 @@ export default {
136136
noTitleKey: 'app'
137137
}
138138
},
139+
computed: {
140+
...mapGetters(['nickname', 'avatar'])
141+
},
139142
mounted () {
140143
this.getTeams()
141144
},
142145
methods: {
143-
...mapGetters(['nickname', 'avatar']),
144-
145146
getTeams () {
146147
this.$http.get('/workplace/teams').then(res => {
147148
this.teams = res.result

src/views/account/settings/Custom.vue

Lines changed: 40 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,52 @@
1+
<template>
2+
<a-list itemLayout="horizontal">
3+
<a-list-item>
4+
<a-list-item-meta>
5+
<template v-slot:title>
6+
<a>风格配色</a>
7+
</template>
8+
<template v-slot:description>
9+
<span>
10+
整体风格配色设置
11+
</span>
12+
</template>
13+
</a-list-item-meta>
14+
<template v-slot:actions>
15+
<a-switch checkedChildren="暗色" unCheckedChildren="白色" :defaultChecked="navTheme === 'dark' && true || false" @change="onChange" />
16+
</template>
17+
</a-list-item>
18+
<a-list-item>
19+
<a-list-item-meta>
20+
<template v-slot:title>
21+
<a>主题色</a>
22+
</template>
23+
<template v-slot:description>
24+
<span>
25+
页面风格配色: <a>{{ colorFilter(primaryColor) }}</a>
26+
</span>
27+
</template>
28+
</a-list-item-meta>
29+
</a-list-item>
30+
</a-list>
31+
</template>
132
<script>
233
import { colorList } from '@/components/SettingDrawer/settingConfig'
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'
6-
import { mixin } from '@/utils/mixin'
34+
import { baseMixin } from '@/store/app-mixin'
35+
import { NAV_THEME, TOGGLE_NAV_THEME } from '@/store/mutation-types'
736
8-
const Meta = AListItem.Meta
37+
const themeMap = {
38+
'dark': '暗色',
39+
'light': '白色'
40+
}
941
1042
export default {
11-
components: {
12-
AListItem,
13-
AList,
14-
ASwitch,
15-
Meta
16-
},
17-
mixins: [mixin],
43+
mixins: [baseMixin],
1844
data () {
1945
return {
2046
}
2147
},
2248
filters: {
2349
themeFilter (theme) {
24-
const themeMap = {
25-
'dark': '暗色',
26-
'light': '白色'
27-
}
2850
return themeMap[theme]
2951
}
3052
},
@@ -36,40 +58,11 @@ export default {
3658
3759
onChange (checked) {
3860
if (checked) {
39-
this.$store.dispatch('ToggleTheme', 'dark')
61+
this.$store.commit(TOGGLE_NAV_THEME, NAV_THEME.DARK)
4062
} else {
41-
this.$store.dispatch('ToggleTheme', 'light')
63+
this.$store.commit(TOGGLE_NAV_THEME, NAV_THEME.LIGHT)
4264
}
4365
}
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.navTheme === '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 domPropsInnerHTML={ this.colorFilter(this.primaryColor) }/>
64-
</span>
65-
</Meta>
66-
</AListItem>
67-
</AList>
68-
)
6966
}
7067
}
7168
</script>
72-
73-
<style scoped>
74-
75-
</style>

src/views/account/settings/Index.vue

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template>
22
<div class="page-header-index-wide">
33
<a-card :bordered="false" :bodyStyle="{ padding: '16px 0', height: '100%' }" :style="{ height: '100%' }">
4-
<div class="account-settings-info-main" :class="device">
4+
<div class="account-settings-info-main" :class="{ 'mobile': isMobile }">
55
<div class="account-settings-info-left">
66
<a-menu
7-
:mode="device == 'mobile' ? 'horizontal' : 'inline'"
8-
:style="{ border: '0', width: device == 'mobile' ? '560px' : 'auto'}"
7+
:mode="isMobile ? 'horizontal' : 'inline'"
8+
:style="{ border: '0', width: isMobile ? '560px' : 'auto'}"
99
:selectedKeys="selectedKeys"
1010
type="inner"
1111
@openChange="onOpenChange"
@@ -49,15 +49,14 @@
4949
</template>
5050

5151
<script>
52-
import { PageView, RouteView } from '@/layouts'
53-
import { mixinDevice } from '@/utils/mixin.js'
52+
import { RouteView } from '@/layouts'
53+
import { baseMixin } from '@/store/app-mixin'
5454
5555
export default {
5656
components: {
57-
RouteView,
58-
PageView
57+
RouteView
5958
},
60-
mixins: [mixinDevice],
59+
mixins: [baseMixin],
6160
data () {
6261
return {
6362
// horizontal inline

0 commit comments

Comments
 (0)