fix: 🐛 修复系统配置页保存配置的bug
This commit is contained in:
@@ -19,7 +19,7 @@ export const useConfigStore = defineStore('config', {
|
||||
this.error = null
|
||||
try {
|
||||
const response = await configApi.getAllConfigs()
|
||||
this.configs = response.data
|
||||
this.configs = response.data || {}
|
||||
return response
|
||||
} catch (error) {
|
||||
this.error = error
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
label-width="80px"
|
||||
class="login-form-inner"
|
||||
>
|
||||
<el-form-item label="管理员账号" prop="username">
|
||||
<el-form-item label="账号" prop="username">
|
||||
<el-input
|
||||
v-model="loginForm.username"
|
||||
placeholder="请输入管理员账号"
|
||||
|
||||
@@ -254,6 +254,12 @@ const loadSystemConfig = async () => {
|
||||
// 将获取到的配置映射到表单中
|
||||
if (response && response.success && response.data) {
|
||||
const configData = response.data
|
||||
|
||||
// 处理布尔值转换
|
||||
if (configData.maintenance_mode !== undefined) {
|
||||
configData.maintenance_mode = configData.maintenance_mode === 'true' || configData.maintenance_mode === true
|
||||
}
|
||||
|
||||
Object.assign(configForm, configData)
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -267,7 +273,9 @@ const handleSaveConfig = async () => {
|
||||
try {
|
||||
// 遍历配置表单,逐个保存配置项
|
||||
for (const [key, value] of Object.entries(configForm)) {
|
||||
await configStore.updateConfig({ key, value })
|
||||
// 处理布尔值转换为字符串
|
||||
const saveValue = typeof value === 'boolean' ? value.toString() : value
|
||||
await configStore.updateConfig({ key, value: saveValue })
|
||||
}
|
||||
|
||||
ElMessage.success('配置保存成功')
|
||||
|
||||
Reference in New Issue
Block a user