feat: 页面配置默认初始化时带预设URL,初次编辑即可直接使用

sync → /index.php
signIn → /attendance.php
search → /torrents.php?search={keyword}
download → /download.php?id={id}
rss → /torrentrss.php?rows=10&search={keyword}&search_mode=1&linktype=dl&passkey={passkey}
detail → /details.php?id={id}
This commit is contained in:
mediabot-pt
2026-07-08 13:30:42 +08:00
parent 3041763e44
commit 2e8d2146c4

View File

@@ -137,6 +137,14 @@ const sites = ref([]), pagesMap = ref({}), sitesList = ref([])
const editSiteId = ref(''), editorJson = ref('{}'), originalJson = ref('')
const snapshotStatus = ref(null)
const authType = ref('NONE')
const defaultUrls = {
sync: '/index.php',
signIn: '/attendance.php',
search: '/torrents.php?search={keyword}',
download: '/download.php?id={id}',
rss: '/torrentrss.php?rows=10&search={keyword}&search_mode=1&linktype=dl&passkey={passkey}',
detail: '/details.php?id={id}',
}
const defaultTypes = ['nexusphp','mtorrent','gazelle','unit3d']
const isDefaultEditor = computed(() => editSiteId.value.startsWith('default:'))
const pageKeys = ref([])
@@ -243,9 +251,9 @@ const editPage = async (row) => {
const data = r?.data || r
authType.value = data?.authType || 'NONE'
const existing = data?.entries || []
// 无配置则默认初始化所有页面类型
// 无配置则默认初始化所有页面类型(带默认URL)
const entries = existing.length ? existing
: pageKeys.value.map(k => ({ key: k.key, method: k.defaultMethod || 'GET', url: '' }))
: pageKeys.value.map(k => ({ key: k.key, method: k.defaultMethod || 'GET', url: defaultUrls[k.key] || '' }))
editorJson.value = JSON.stringify({ authType: authType.value, entries }, null, 2)
} catch { editorJson.value = JSON.stringify({ authType:'NONE', entries:[] }, null, 2) }
originalJson.value = editorJson.value
@@ -299,7 +307,7 @@ const discardDraft = async () => {
const remove = (idx) => { parsed.value.splice(idx,1); syncToJson() }
const addEntryByKey = (k) => {
parsed.value.push({ key: k.key, method: k.defaultMethod || 'GET', url: '' })
parsed.value.push({ key: k.key, method: k.defaultMethod || 'GET', url: defaultUrls[k.key] || '' })
syncToJson()
}
const deletePages = async () => {