|
140 | 140 | </div>
|
141 | 141 | <a-divider />
|
142 | 142 | <div :style="{ marginBottom: '24px' }">
|
143 |
| - <a-alert type="warning"> |
| 143 | + <a-button |
| 144 | + @click="doCopy" |
| 145 | + icon="copy" |
| 146 | + block |
| 147 | + >拷贝设置</a-button> |
| 148 | + <a-alert type="warning" :style="{ marginTop: '24px' }"> |
144 | 149 | <span slot="message">
|
145 | 150 | 配置栏只在开发环境用于预览,生产环境不会展现,请手动修改配置文件
|
146 | 151 | <a href="https://github.com/sendya/ant-design-pro-vue/blob/master/src/defaultSettings.js" target="_blank">src/defaultSettings.js</a>
|
|
161 | 166 | import SettingItem from '@/components/setting/SettingItem'
|
162 | 167 | import config from '@/defaultSettings'
|
163 | 168 | import { updateTheme, updateColorWeak, colorList } from '@/components/tools/setting'
|
164 |
| - import { mixin, mixinDevice } from '@/utils/mixin.js' |
| 169 | + import { mixin, mixinDevice } from '@/utils/mixin' |
165 | 170 |
|
166 | 171 | export default {
|
167 | 172 | components: {
|
|
173 | 178 | return {
|
174 | 179 | visible: true,
|
175 | 180 | colorList,
|
| 181 | + baseConfig: Object.assign({}, config) |
176 | 182 | }
|
177 | 183 | },
|
178 | 184 | watch: {
|
|
202 | 208 | this.visible = !this.visible
|
203 | 209 | },
|
204 | 210 | onColorWeak (checked) {
|
| 211 | + this.baseConfig.colorWeak = checked |
205 | 212 | this.$store.dispatch('ToggleWeak', checked)
|
206 | 213 | updateColorWeak(checked)
|
207 | 214 | },
|
208 | 215 | handleMenuTheme (theme) {
|
| 216 | + this.baseConfig.navTheme = theme |
209 | 217 | this.$store.dispatch('ToggleTheme', theme)
|
210 | 218 | },
|
| 219 | + doCopy () { |
| 220 | + const text = `export default { |
| 221 | + primaryColor: '${this.baseConfig.primaryColor}', // primary color of ant design |
| 222 | + navTheme: '${this.baseConfig.navTheme}', // theme for nav menu |
| 223 | + layout: '${this.baseConfig.layout}', // nav menu position: sidemenu or topmenu |
| 224 | + contentWidth: '${this.baseConfig.contentWidth}', // layout of content: Fluid or Fixed, only works when layout is topmenu |
| 225 | + fixedHeader: ${this.baseConfig.fixedHeader}, // sticky header |
| 226 | + fixSiderbar: ${this.baseConfig.fixSiderbar}, // sticky siderbar |
| 227 | + autoHideHeader: ${this.baseConfig.autoHideHeader}, // auto hide header |
| 228 | + colorWeak: ${this.baseConfig.colorWeak}, |
| 229 | + // vue-ls options |
| 230 | + storageOptions: { |
| 231 | + namespace: 'pro__', |
| 232 | + name: 'ls', |
| 233 | + storage: 'local', |
| 234 | + } |
| 235 | +}` |
| 236 | + this.$copyText(text).then(message => { |
| 237 | + console.log('copy', message) |
| 238 | + this.$message.success('复制完毕') |
| 239 | + }).catch(err => { |
| 240 | + console.log('copy.err', err) |
| 241 | + this.$message.error('复制失败') |
| 242 | + }) |
| 243 | + }, |
211 | 244 | handleLayout (mode) {
|
| 245 | + this.baseConfig.layout = mode |
212 | 246 | this.$store.dispatch('ToggleLayoutMode', mode)
|
213 | 247 | // 因为顶部菜单不能固定左侧菜单栏,所以强制关闭
|
214 | 248 | //
|
215 | 249 | this.handleFixSiderbar(false)
|
216 | 250 | },
|
217 | 251 | handleContentWidthChange (type) {
|
| 252 | + this.baseConfig.contentWidth = type |
218 | 253 | this.$store.dispatch('ToggleContentWidth', type)
|
219 | 254 | },
|
220 | 255 | changeColor (color) {
|
| 256 | + this.baseConfig.primaryColor = color |
221 | 257 | if (this.primaryColor !== color) {
|
222 | 258 | this.$store.dispatch('ToggleColor', color)
|
223 | 259 | updateTheme(color)
|
224 | 260 | }
|
225 | 261 | },
|
226 | 262 | handleFixedHeader (fixed) {
|
| 263 | + this.baseConfig.fixedHeader = fixed |
227 | 264 | this.$store.dispatch('ToggleFixedHeader', fixed)
|
228 | 265 | },
|
229 | 266 | handleFixedHeaderHidden (autoHidden) {
|
| 267 | + this.baseConfig.autoHideHeader = autoHidden |
230 | 268 | this.$store.dispatch('ToggleFixedHeaderHidden', autoHidden)
|
231 | 269 | },
|
232 | 270 | handleFixSiderbar (fixed) {
|
233 | 271 | if (this.layoutMode === 'topmenu') {
|
| 272 | + this.baseConfig.fixSiderbar = false |
234 | 273 | this.$store.dispatch('ToggleFixSiderbar', false)
|
235 | 274 | return
|
236 | 275 | }
|
| 276 | + this.baseConfig.fixSiderbar = fixed |
237 | 277 | this.$store.dispatch('ToggleFixSiderbar', fixed)
|
238 | 278 | }
|
239 | 279 | },
|
|
0 commit comments