【更新】兼容formStyle

pull/98/head
xlzy 2023-03-23 17:00:11 +08:00
parent 2c6ec39122
commit 1ea621bf5a
2 changed files with 38 additions and 50 deletions

View File

@ -78,15 +78,15 @@
<a-form-item label="菜单排他展开"> <a-form-item label="菜单排他展开">
<a-switch :checked="sideUniqueOpen" @change="toggleState('sideUniqueOpen')" /> <a-switch :checked="sideUniqueOpen" @change="toggleState('sideUniqueOpen')" />
</a-form-item> </a-form-item>
<a-form-item label="表单风格"> <a-form-item label="表单风格">
<a-select <a-select
v-model:value="formStyle" :value="formStyle"
style="width: 80px" class="w-[80px]"
size="small" size="small"
:options="xnFormStyleOptions" :options="xnFormStyleOptions"
@change="formStyleChange" @change="formStyleChange"
/> />
</a-form-item> </a-form-item>
</a-form> </a-form>
<a-alert <a-alert
message="以上配置可实时预览,开发者可在 config/index.js 中配置默认值,不建议在生产环境下开放布局设置" message="以上配置可实时预览,开发者可在 config/index.js 中配置默认值,不建议在生产环境下开放布局设置"
@ -101,7 +101,7 @@
import { ThemeModeEnum } from '../../utils/enum' import { ThemeModeEnum } from '../../utils/enum'
import { globalStore } from '@/store' import { globalStore } from '@/store'
import { mapState, mapStores } from 'pinia' import { mapState, mapStores } from 'pinia'
import tool from '@/utils/tool' import tool from '@/utils/tool'
const toolDataNameMap = { const toolDataNameMap = {
menuIsCollapse: 'MENU_COLLAPSE', menuIsCollapse: 'MENU_COLLAPSE',
@ -147,16 +147,16 @@
style: 'snowy-setting-layout-menu-doublerow' style: 'snowy-setting-layout-menu-doublerow'
} }
], ],
xnFormStyleOptions: [ xnFormStyleOptions: [
{ {
label: '抽屉', label: '抽屉',
value: 'drawer' value: 'drawer'
}, },
{ {
label: '对话框', label: '对话框',
value: 'modal' value: 'modal'
} }
], ],
colorList colorList
} }
}, },
@ -172,7 +172,8 @@
'breadcrumbOpen', 'breadcrumbOpen',
'moduleUnfoldOpen', 'moduleUnfoldOpen',
'topHanderThemeColorOpen', 'topHanderThemeColorOpen',
'topHanderThemeColorSpread' 'topHanderThemeColorSpread',
'formStyle'
]) ])
}, },
mounted() {}, mounted() {},
@ -186,31 +187,31 @@
toggleState(stateName) { toggleState(stateName) {
this.globalStore.toggleConfig(stateName) this.globalStore.toggleConfig(stateName)
const toolDataName = toolDataNameMap[stateName] const toolDataName = toolDataNameMap[stateName]
tool.data.set(`SNOWY_${toolDataName}`, this.globalStore[stateName]) tool.data.set(`SNOWY_${toolDataName}`, this.globalStore[stateName])
}, },
// //
setSideStyle(value) { setSideStyle(value) {
this.globalStore.setTheme(value) this.globalStore.setTheme(value)
this.sideStyle = value this.sideStyle = value
tool.data.set('SNOWY_THEME', value) tool.data.set('SNOWY_THEME', value)
}, },
// //
layoutStyle(value) { layoutStyle(value) {
this.globalStore.setLayout(value) this.globalStore.setLayout(value)
tool.data.set('SNOWY_LAYOUT', value) tool.data.set('SNOWY_LAYOUT', value)
this.layout = value this.layout = value
}, },
// //
tagColor(value) { tagColor(value) {
this.globalStore.themeColor = value this.globalStore.themeColor = value
tool.data.set('SNOWY_THEME_COLOR', value) tool.data.set('SNOWY_THEME_COLOR', value)
this.globalStore.setThemeColor(value) this.globalStore.setThemeColor(value)
}, },
// //
formStyleChange(value) { formStyleChange(value) {
tool.data.set('SNOWY_FORM_STYLE', value) tool.data.set('SNOWY_FORM_STYLE', value)
this.$store.commit('SET_formStyle', value) this.globalStore.setFormStyle(value)
} }
} }
}) })
</script> </script>

View File

@ -42,6 +42,8 @@ export const globalStore = defineStore({
theme: getCacheConfig('SNOWY_THEME'), theme: getCacheConfig('SNOWY_THEME'),
// 主题颜色 // 主题颜色
themeColor: toolDataGet('SNOWY_THEME_COLOR') || config.COLOR, themeColor: toolDataGet('SNOWY_THEME_COLOR') || config.COLOR,
// 整体表单风格
formStyle: getCacheConfig('SNOWY_FORM_STYLE'),
// 用户信息 // 用户信息
userInfo: toolDataGet('USER_INFO') || {}, userInfo: toolDataGet('USER_INFO') || {},
// 系统配置 // 系统配置
@ -72,23 +74,8 @@ export const globalStore = defineStore({
toggleConfig(key) { toggleConfig(key) {
this[key] = !this[key] this[key] = !this[key]
}, },
toggle_SideUniqueOpen() { setFormStyle(key) {
this.sideUniqueOpen = !this.sideUniqueOpen this.formStyle = key
},
toggle_LayoutTagsOpen() {
this.layoutTagsOpen = !this.layoutTagsOpen
},
toggle_BreadcrumbOpen() {
this.breadcrumbOpen = !this.breadcrumbOpen
},
toggle_TopHanderThemeColorOpen() {
this.topHanderThemeColorOpen = !this.topHanderThemeColorOpen
},
toggle_TopHanderThemeColorSpread() {
this.topHanderThemeColorSpread = !this.topHanderThemeColorSpread
},
toggle_ModuleUnfoldOpen() {
this.moduleUnfoldOpen = !this.moduleUnfoldOpen
}, },
setUserInfo(key) { setUserInfo(key) {
this.userInfo = key this.userInfo = key