优化系统设置支持按模块独立提交配置
This commit is contained in:
parent
49b174027f
commit
72d4651545
@ -19,17 +19,29 @@ const requestFields = {
|
||||
],
|
||||
};
|
||||
|
||||
export function settingsPayload(current, targetSection) {
|
||||
|
||||
const tabSectionMap = {
|
||||
service: ["server", "web", "paths"],
|
||||
acme: ["acme"],
|
||||
dns: ["dns"],
|
||||
notification: ["notification"],
|
||||
};
|
||||
|
||||
export function settingsPayload(current, targetTabOrSection) {
|
||||
const payload = {};
|
||||
let targetSections = null;
|
||||
if (targetTabOrSection) {
|
||||
targetSections = tabSectionMap[targetTabOrSection] || [targetTabOrSection];
|
||||
}
|
||||
for (const [section, fields] of Object.entries(requestFields)) {
|
||||
if (targetSection && targetSection !== section) continue;
|
||||
if (targetSections && !targetSections.includes(section)) continue;
|
||||
const source = current[section] || {};
|
||||
payload[section] = Object.fromEntries(
|
||||
fields.filter((field) => source[field] !== undefined)
|
||||
.map((field) => [field, source[field]]),
|
||||
);
|
||||
}
|
||||
if (!targetSection || targetSection === "dns") {
|
||||
if (!targetSections || targetSections.includes("dns")) {
|
||||
const dns = current.dns || {};
|
||||
payload.dns = { provider: dns.provider };
|
||||
if (dns.credential_ref && dns.verification_token) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user