feat: 页面配置key改为枚举下拉框+自动填method
This commit is contained in:
@@ -61,8 +61,12 @@
|
||||
<div style="flex:1;overflow:auto;min-height:0">
|
||||
<div style="font-size:13px;font-weight:500;margin-bottom:4px">双向可视化</div>
|
||||
<el-table :data="parsed" stripe border style="font-size:13px" :row-style="{height:'42px'}" v-if="parsed.length">
|
||||
<el-table-column prop="key" label="key" width="100">
|
||||
<template #default="s"><el-input v-model="s.row.key" size="small" @input="syncToJson"/></template>
|
||||
<el-table-column prop="key" label="key" width="120">
|
||||
<template #default="s">
|
||||
<el-select v-model="s.row.key" size="small" @change="onKeyChange(s.row)" filterable>
|
||||
<el-option v-for="k in pageKeys" :key="k.key" :label="k.key+' - '+k.label" :value="k.key" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="label" label="名称" width="110">
|
||||
<template #default="s"><el-input v-model="s.row.label" size="small" @input="syncToJson"/></template>
|
||||
@@ -91,6 +95,18 @@ const loading = ref(false), saving = ref(false), uploading = ref(false), deletin
|
||||
const editSiteId = ref(''), editorJson = ref('[]')
|
||||
const defaultTypes = ['nexusphp','mtorrent','gazelle','unit3d']
|
||||
const isDefaultEditor = computed(() => editSiteId.value.startsWith('default:'))
|
||||
const pageKeys = ref([])
|
||||
|
||||
const loadPageKeys = async () => {
|
||||
try { const r = await api.raw.get('/admin/page-keys'); pageKeys.value = r?.data || r || [] }
|
||||
catch {}
|
||||
}
|
||||
|
||||
const onKeyChange = (row) => {
|
||||
const pk = pageKeys.value.find(k => k.key === row.key)
|
||||
if (pk?.defaultMethod) row.method = pk.defaultMethod
|
||||
syncToJson()
|
||||
}
|
||||
const fmt = (t) => t ? (t.substring(0,19)||'').replace('T',' ') : '-'
|
||||
const parsed = computed(() => { try { return JSON.parse(editorJson.value) } catch { return [] } })
|
||||
const resolveUrl = (url) => url?.replace('{base}', sitesList.value.find(s=>s.siteId===editSiteId.value)?.urls?.[0] || '{base}') || ''
|
||||
@@ -157,5 +173,5 @@ const savePages = async () => {
|
||||
} catch { ElMessage.error('保存失败') }
|
||||
finally { saving.value = false }
|
||||
}
|
||||
onMounted(fetchAll)
|
||||
onMounted(() => { fetchAll(); loadPageKeys() })
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user