feat: 新增网站配置修改功能

This commit is contained in:
Bull-BCLS
2023-09-22 21:51:09 +08:00
parent b30f6c2eb0
commit dcc87cb63b
8 changed files with 217 additions and 24 deletions

View File

@@ -11,7 +11,7 @@ export interface BasicConfigRecord {
}
export interface DataRecord {
name: string;
name?: string;
code: string;
value: string;
description?: string;
@@ -30,6 +30,10 @@ export function list(params: ListParam) {
});
}
export function save(req: DataRecord[]) {
return axios.patch(`${BASE_URL}`, req);
}
export function resetValue(params: ListParam) {
return axios.patch(`${BASE_URL}/value`, params);
}

View File

@@ -164,6 +164,7 @@
DataRecord,
ListParam,
list,
save,
resetValue,
} from '@/api/system/config';
@@ -207,18 +208,49 @@
siteFavicon.value = dataList.value.find(
(option) => option.code === 'site_favicon'
);
form.value.site_title = siteTitle.value?.value;
form.value.site_copyright = siteCopyright.value?.value;
form.value = {
site_title: siteTitle.value?.value,
site_copyright: siteCopyright.value?.value,
site_logo: {
url: siteLogo.value?.value,
},
site_favicon: {
url: siteFavicon.value?.value,
},
};
logoFile.value.url = siteLogo.value?.value;
faviconFile.value.url = siteFavicon.value?.value;
};
getConfig();
/**
* 取消
*/
const handleCancel = () => {
isEdit.value = false;
};
/**
* 保存
*/
const handleSave = async () => {
isEdit.value = false;
const handleSave = () => {
proxy.$refs.formRef.validate((valid: any) => {
if (!valid) {
const optionList: DataRecord[] = Object.entries(form.value).map(
(item) => {
return {
code: item[0],
value: item[1]?.url || item[1],
};
}
);
save(optionList).then((res) => {
// siteConfigStore().save(data.form);
handleCancel();
proxy.$message.success(res.msg);
});
}
});
};
/**
@@ -315,14 +347,6 @@
const reset = () => {
proxy.$refs.formRef?.resetFields();
};
/**
* 取消
*/
const handleCancel = () => {
isEdit.value = false;
reset();
};
</script>
<style scoped lang="less">