mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-12 06:57:13 +08:00
feat: 新增网站配置修改功能
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
@@ -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">
|
||||
|
Reference in New Issue
Block a user