feat: 页面配置首次编辑时默认初始化所有页面类型,删除不需要的比逐个添加更高效

This commit is contained in:
mediabot-pt
2026-07-08 13:24:37 +08:00
parent 0f69fecb8f
commit 3041763e44

View File

@@ -242,7 +242,11 @@ const editPage = async (row) => {
const r = await api.raw.get(url)
const data = r?.data || r
authType.value = data?.authType || 'NONE'
editorJson.value = JSON.stringify({ authType: authType.value, entries: data?.entries || [] }, null, 2)
const existing = data?.entries || []
// 无配置则默认初始化所有页面类型
const entries = existing.length ? existing
: pageKeys.value.map(k => ({ key: k.key, method: k.defaultMethod || 'GET', url: '' }))
editorJson.value = JSON.stringify({ authType: authType.value, entries }, null, 2)
} catch { editorJson.value = JSON.stringify({ authType:'NONE', entries:[] }, null, 2) }
originalJson.value = editorJson.value
if (!row.siteId.startsWith('default:')) fetchSnapshotStatus()