Skip to content

Commit dde01c1

Browse files
liyangworldsendya
authored andcommitted
fix: Copping global settings in the SettingDrawer is not always the current settings
1 parent db1b074 commit dde01c1

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

src/components/SettingDrawer/SettingDrawer.vue

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ export default {
186186
data () {
187187
return {
188188
visible: true,
189-
colorList,
190-
baseConfig: Object.assign({}, config)
189+
colorList
191190
}
192191
},
193192
watch: {
@@ -217,29 +216,27 @@ export default {
217216
this.visible = !this.visible
218217
},
219218
onColorWeak (checked) {
220-
this.baseConfig.colorWeak = checked
221219
this.$store.dispatch('ToggleWeak', checked)
222220
updateColorWeak(checked)
223221
},
224222
onMultiTab (checked) {
225-
this.baseConfig.multiTab = checked
226223
this.$store.dispatch('ToggleMultiTab', checked)
227224
},
228225
handleMenuTheme (theme) {
229-
this.baseConfig.navTheme = theme
230226
this.$store.dispatch('ToggleTheme', theme)
231227
},
232228
doCopy () {
229+
// get current settings from mixin or this.$store.state.app, pay attention to the property name
233230
const text = `export default {
234-
primaryColor: '${this.baseConfig.primaryColor}', // primary color of ant design
235-
navTheme: '${this.baseConfig.navTheme}', // theme for nav menu
236-
layout: '${this.baseConfig.layout}', // nav menu position: sidemenu or topmenu
237-
contentWidth: '${this.baseConfig.contentWidth}', // layout of content: Fluid or Fixed, only works when layout is topmenu
238-
fixedHeader: ${this.baseConfig.fixedHeader}, // sticky header
239-
fixSiderbar: ${this.baseConfig.fixSiderbar}, // sticky siderbar
240-
autoHideHeader: ${this.baseConfig.autoHideHeader}, // auto hide header
241-
colorWeak: ${this.baseConfig.colorWeak},
242-
multiTab: ${this.baseConfig.multiTab},
231+
primaryColor: '${this.primaryColor}', // primary color of ant design
232+
navTheme: '${this.navTheme}', // theme for nav menu
233+
layout: '${this.layoutMode}', // nav menu position: sidemenu or topmenu
234+
contentWidth: '${this.contentWidth}', // layout of content: Fluid or Fixed, only works when layout is topmenu
235+
fixedHeader: ${this.fixedHeader}, // sticky header
236+
fixSiderbar: ${this.fixSiderbar}, // sticky siderbar
237+
autoHideHeader: ${this.autoHideHeader}, // auto hide header
238+
colorWeak: ${this.colorWeak},
239+
multiTab: ${this.multiTab},
243240
production: process.env.NODE_ENV === 'production' && process.env.VUE_APP_PREVIEW !== 'true',
244241
// vue-ls options
245242
storageOptions: {
@@ -257,38 +254,30 @@ export default {
257254
})
258255
},
259256
handleLayout (mode) {
260-
this.baseConfig.layout = mode
261257
this.$store.dispatch('ToggleLayoutMode', mode)
262258
// 因为顶部菜单不能固定左侧菜单栏,所以强制关闭
263-
//
264259
this.handleFixSiderbar(false)
265260
},
266261
handleContentWidthChange (type) {
267-
this.baseConfig.contentWidth = type
268262
this.$store.dispatch('ToggleContentWidth', type)
269263
},
270264
changeColor (color) {
271-
this.baseConfig.primaryColor = color
272265
if (this.primaryColor !== color) {
273266
this.$store.dispatch('ToggleColor', color)
274267
updateTheme(color)
275268
}
276269
},
277270
handleFixedHeader (fixed) {
278-
this.baseConfig.fixedHeader = fixed
279271
this.$store.dispatch('ToggleFixedHeader', fixed)
280272
},
281273
handleFixedHeaderHidden (autoHidden) {
282-
this.baseConfig.autoHideHeader = autoHidden
283274
this.$store.dispatch('ToggleFixedHeaderHidden', autoHidden)
284275
},
285276
handleFixSiderbar (fixed) {
286277
if (this.layoutMode === 'topmenu') {
287-
this.baseConfig.fixSiderbar = false
288278
this.$store.dispatch('ToggleFixSiderbar', false)
289279
return
290280
}
291-
this.baseConfig.fixSiderbar = fixed
292281
this.$store.dispatch('ToggleFixSiderbar', fixed)
293282
}
294283
}

0 commit comments

Comments
 (0)