Skip to content

Commit 37a9b04

Browse files
committed
fix setting drawer
updated ant-design-vue ver to 1.1.6
1 parent 4dcb488 commit 37a9b04

File tree

7 files changed

+40
-26
lines changed

7 files changed

+40
-26
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"dependencies": {
1111
"@antv/data-set": "^0.8.9",
12-
"ant-design-vue": "^1.1.3",
12+
"ant-design-vue": "^1.1.6",
1313
"axios": "^0.18.0",
1414
"dayjs": "^1.7.5",
1515
"enquire.js": "^2.1.6",

src/components/layout/LayoutMain.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</a-layout-footer>
4040
</a-layout>
4141

42-
<setting-drawer ref="settingdw"></setting-drawer>
42+
<setting-drawer></setting-drawer>
4343
</a-layout>
4444
</template>
4545

@@ -82,9 +82,6 @@
8282
},
8383
mounted() {
8484
this.collapsed = this.sidebarOpened
85-
86-
// this.$refs.settingdw.showDrawer()
87-
// this.$refs.settingdw.onClose()
8885
},
8986
methods: {
9087
...mapActions(['setSidebar']),

src/components/tools/SettingDrawer.vue

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<template>
2-
<div>
2+
<div class="setting-drawer">
33
<a-drawer
44
width="300"
5-
:destroyOnClose="false"
65
placement="right"
76
:closable="false"
87
@close="onClose"
98
:visible="visible"
9+
:style="{}"
1010
>
1111
<div class="setting-drawer-index-content">
1212

@@ -45,16 +45,17 @@
4545
</div>
4646
</div>
4747
</div>
48+
<div class="setting-drawer-index-handle" @click="toggle">
49+
<a-icon type="setting" v-if="!visible"/>
50+
<a-icon type="close" v-else/>
51+
</div>
4852
</a-drawer>
49-
<div class="setting-drawer-index-handle" :style="{ right: visible && '283px' || '0' }" @click="toggle">
50-
<a-icon type="setting" v-if="!visible"/>
51-
<a-icon type="close" v-else/>
52-
</div>
5353
</div>
5454
</template>
5555

5656
<script>
5757
import DetailList from '@/components/tools/DetailList'
58+
import config from '@/defaultConfig'
5859
import { updateTheme } from '@/components/tools/setting'
5960
6061
import { mapState } from 'vuex'
@@ -100,7 +101,7 @@
100101
},
101102
data() {
102103
return {
103-
visible: false,
104+
visible: true,
104105
colorList,
105106
}
106107
},
@@ -112,8 +113,13 @@
112113
},
113114
mounted () {
114115
const vm = this
115-
116-
updateTheme(this.colorObj.color)
116+
setTimeout(() => {
117+
vm.visible = false
118+
}, 1)
119+
// 当主题色不是默认色时,才进行主题编译
120+
if (this.colorObj.color !== config.color.color) {
121+
updateTheme(this.colorObj.color)
122+
}
117123
},
118124
methods: {
119125
showDrawer() {
@@ -129,8 +135,10 @@
129135
this.$store.dispatch('ToggleTheme', theme)
130136
},
131137
changeColor(color) {
132-
updateTheme(color.color)
133-
this.$store.dispatch('ToggleColor', color)
138+
if (this.colorObj.color !== color.color) {
139+
this.$store.dispatch('ToggleColor', color)
140+
updateTheme(color.color)
141+
}
134142
}
135143
},
136144
}
@@ -198,7 +206,7 @@
198206
background: #1890ff;
199207
width: 48px;
200208
height: 48px;
201-
right: 0;
209+
right: 300px;
202210
display: flex;
203211
justify-content: center;
204212
align-items: center;

src/components/tools/setting.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ let lessNodesAppended;
55

66
const updateTheme = primaryColor => {
77
// Don't compile less in production!
8-
if (process.env.NODE_ENV === 'production') {
8+
/* if (process.env.NODE_ENV === 'production') {
99
return;
10-
}
10+
} */
1111
// Determine if the component is remounted
1212
if (!primaryColor) {
1313
return;

src/defaultConfig.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
color: {
3+
key: 'daybreak',
4+
color: '#1890FF'
5+
},
6+
theme: 'dark',
7+
colorWeak: false
8+
}

src/main.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import * as dayjs from 'dayjs' // 日期时间支持库
1414

1515
import '@/permission' // permission control
1616

17-
import {ACCESS_TOKEN, DEFAULT_COLOR, DEFAULT_THEME, SIDEBAR_TYPE} from "@/store/mutation-types"
17+
import { ACCESS_TOKEN, DEFAULT_COLOR, DEFAULT_THEME, SIDEBAR_TYPE } from "@/store/mutation-types"
18+
import config from '@/defaultConfig'
1819

1920
Vue.filter('dayjs', function(dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
2021
return dayjs(dataStr).format(pattern)
@@ -37,9 +38,9 @@ new Vue({
3738
router,
3839
store,
3940
mounted () {
40-
store.commit('SET_SIDEBAR_TYPE', Vue.ls.get(SIDEBAR_TYPE, true))
41-
store.commit('TOGGLE_THEME', Vue.ls.get(DEFAULT_THEME, 'dark'))
42-
store.commit('TOGGLE_COLOR', Vue.ls.get(DEFAULT_COLOR, { key: 'daybreak', color: '#1890FF' }))
41+
store.commit('SET_SIDEBAR_TYPE', Vue.ls.get(SIDEBAR_TYPE, false))
42+
store.commit('TOGGLE_THEME', Vue.ls.get(DEFAULT_THEME, config.theme))
43+
store.commit('TOGGLE_COLOR', Vue.ls.get(DEFAULT_COLOR, config.color))
4344
store.commit('SET_TOKEN', Vue.ls.get(ACCESS_TOKEN))
4445

4546
},

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,9 +1150,9 @@ ansi-styles@^3.2.1:
11501150
dependencies:
11511151
color-convert "^1.9.0"
11521152

1153-
ant-design-vue@^1.1.3:
1154-
version "1.1.3"
1155-
resolved "https://registry.yarnpkg.com/ant-design-vue/-/ant-design-vue-1.1.3.tgz#44d05c6d5991c4aca9202f44c4d7784d4f80403a"
1153+
ant-design-vue@^1.1.6:
1154+
version "1.1.6"
1155+
resolved "https://registry.yarnpkg.com/ant-design-vue/-/ant-design-vue-1.1.6.tgz#ec55979304fa995054528834713b8dad1e42861c"
11561156
dependencies:
11571157
add-dom-event-listener "^1.0.2"
11581158
array-tree-filter "^2.1.0"

0 commit comments

Comments
 (0)