mirror of
https://github.com/iczer/vue-antd-admin
synced 2025-08-10 05:09:57 +08:00
添加一个配置项,当设置为true时从本地读取配置
This commit is contained in:
parent
5a65032772
commit
a1f2c1d880
1
.eslintignore
Normal file
1
.eslintignore
Normal file
@ -0,0 +1 @@
|
||||
src/
|
@ -21,6 +21,11 @@ export default {
|
||||
this.setHtmlTitle()
|
||||
this.setLanguage(this.lang)
|
||||
enquireScreen(isMobile => this.setDevice(isMobile))
|
||||
//设置为读取本地存储配置
|
||||
const loadLocalSetting = this.localSaveSetting
|
||||
if (loadLocalSetting) {
|
||||
this.$store.dispatch('setting/loadLocalSetting')
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.setWeekModeTheme(this.weekMode)
|
||||
@ -49,7 +54,7 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState('setting', ['theme', 'weekMode', 'lang'])
|
||||
...mapState('setting', ['theme', 'weekMode', 'lang', 'localSaveSetting'])
|
||||
},
|
||||
methods: {
|
||||
...mapMutations('setting', ['setDevice']),
|
||||
|
@ -98,13 +98,13 @@
|
||||
</a-list-item>
|
||||
</a-list>
|
||||
</setting-item>
|
||||
<a-alert
|
||||
<a-alert v-if="!localSaveSetting"
|
||||
style="max-width: 240px; margin: -16px 0 8px; word-break: break-all"
|
||||
type="warning"
|
||||
:message="$t('alert')"
|
||||
>
|
||||
</a-alert>
|
||||
<a-button id="copyBtn" :data-clipboard-text="copyConfig" @click="copyCode" style="width: 100%" icon="copy" >{{$t('copy')}}</a-button>
|
||||
<a-button id="copyBtn" :data-clipboard-text="copyConfig" @click="copyCode" style="width: 100%" icon="copy" >{{localSaveSetting?$t('save'):$t('copy')}}</a-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -132,7 +132,7 @@ export default {
|
||||
directions() {
|
||||
return this.animates.find(item => item.name == this.animate.name).directions
|
||||
},
|
||||
...mapState('setting', ['theme', 'layout', 'animate', 'animates', 'palettes', 'multiPage', 'weekMode', 'fixedHeader', 'fixedSideBar', 'hideSetting', 'pageWidth'])
|
||||
...mapState('setting', ['theme', 'layout', 'animate', 'animates', 'palettes', 'multiPage', 'weekMode', 'fixedHeader', 'fixedSideBar', 'hideSetting', 'pageWidth', 'localSaveSetting'])
|
||||
},
|
||||
watch: {
|
||||
'animate.name': function(val) {
|
||||
@ -157,11 +157,19 @@ export default {
|
||||
this.copyConfig = '// 自定义配置,参考 ./default/setting.config.js,需要自定义的属性在这里配置即可\n'
|
||||
this.copyConfig += 'module.exports = '
|
||||
this.copyConfig += formatConfig(config)
|
||||
|
||||
//如果设置保存在本地,则存到浏览器localStroge中
|
||||
if(this.localSaveSetting) {
|
||||
localStorage.setItem('localSetting',JSON.stringify(config))
|
||||
}
|
||||
|
||||
let clipboard = new Clipboard('#copyBtn')
|
||||
const _this = this
|
||||
clipboard.on('success', function () {
|
||||
_this.$message.success(`复制成功,覆盖文件 src/config/config.js 然后重启项目即可生效`)
|
||||
clipboard.on('success', () => {
|
||||
if(this.localSaveSetting) {
|
||||
this.$message.success(`保存配置成功`)
|
||||
} else {
|
||||
this.$message.success(`复制成功,覆盖文件 src/config/config.js 然后重启项目即可生效`)
|
||||
}
|
||||
clipboard.destroy()
|
||||
})
|
||||
},
|
||||
|
@ -34,7 +34,8 @@ module.exports = {
|
||||
direction: '动画方向'
|
||||
},
|
||||
alert: '拷贝配置后,直接覆盖文件 src/config/config.js 中的全部内容,然后重启即可。(注意:仅会拷贝与默认配置不同的项)',
|
||||
copy: '拷贝配置'
|
||||
copy: '拷贝配置',
|
||||
save: '保存配置'
|
||||
},
|
||||
HK: {
|
||||
theme: {
|
||||
@ -69,7 +70,8 @@ module.exports = {
|
||||
direction: '動畫方向'
|
||||
},
|
||||
alert: '拷貝配置后,直接覆蓋文件 src/config/config.js 中的全部內容,然後重啟即可。(注意:僅會拷貝與默認配置不同的項)',
|
||||
copy: '拷貝配置'
|
||||
copy: '拷貝配置',
|
||||
save: '保存配置'
|
||||
},
|
||||
US: {
|
||||
theme: {
|
||||
@ -105,7 +107,8 @@ module.exports = {
|
||||
direction: 'Direction'
|
||||
},
|
||||
alert: 'After copying the configuration code, directly cover all contents in the file src/config/config.js, then restart the server. (Note: only items that are different from the default configuration will be copied)',
|
||||
copy: 'Copy Setting'
|
||||
copy: 'Copy Setting',
|
||||
save: 'Save Setting'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ module.exports = {
|
||||
asyncRoutes: false, //异步加载路由,true:开启,false:不开启
|
||||
showPageTitle: true, //是否显示页面标题(PageLayout 布局中的页面标题),true:显示,false:不显示
|
||||
filterMenu: true, //根据权限过滤菜单,true:过滤,false:不过滤
|
||||
localSaveSetting:true, //是否将右侧设置保存在本地,设置为true的时候,将不显示拷贝设置而将设置保存在localStorage
|
||||
animate: { //动画设置
|
||||
disabled: false, //禁用动画,true:禁用,false:启用
|
||||
name: 'bounce', //动画效果,支持的动画效果可参考 ./animate.config.js
|
||||
|
@ -88,5 +88,33 @@ export default {
|
||||
setActivatedFirst(state, activatedFirst) {
|
||||
state.activatedFirst = activatedFirst
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
loadLocalSetting({commit}) {
|
||||
const localSetting = localStorage.getItem("localSetting")
|
||||
if (localSetting !== '' && localSetting != null) {
|
||||
let setting = {}
|
||||
try {
|
||||
setting = JSON.parse(localSetting)
|
||||
} catch ( e ) {
|
||||
console.log('json error')
|
||||
return false
|
||||
}
|
||||
for (let key in setting) {
|
||||
switch (key) {
|
||||
case 'theme' : commit('setTheme', setting.theme); break;
|
||||
case 'layout': commit('setLayout', setting.layout); break;
|
||||
case 'multiPage': commit('setMultiPage', setting.multiPage); break;
|
||||
case 'weekMode': commit('setWeekMode', setting.weekMode); break;
|
||||
case 'fixedHeader': commit('setFixedHeader', setting.fixedHeader); break;
|
||||
case 'fixedSideBar': commit('setFixedSideBar', setting.fixedSideBar); break;
|
||||
case 'pageWidth': commit('setPageWidth', setting.pageWidth); break;
|
||||
// case 'hideSetting': commit('setHideSetting', setting.hideSetting); break;
|
||||
case 'animate' : commit('setAnimate', setting.animate)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user