feat(ECR-025): OpsCMS FeedSlot 只读并 Closed

栏目位目录(ops_feed_slots + /cms),复用 admin.cms.read。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-08 03:08:40 +08:00
co-authored by Cursor
parent f51b2524c5
commit e32466357d
26 changed files with 661 additions and 4 deletions
+65 -3
View File
@@ -3,12 +3,18 @@ import { onMounted, ref } from 'vue'
import { adminApi } from '@/api/client'
type Banner = Awaited<ReturnType<typeof adminApi.banners>>['items'][number]
type FeedSlot = Awaited<ReturnType<typeof adminApi.feedSlots>>['items'][number]
const loading = ref(false)
const error = ref('')
const items = ref<Banner[]>([])
const selected = ref<Banner | null>(null)
const slotsLoading = ref(false)
const slotsError = ref('')
const slots = ref<FeedSlot[]>([])
const selectedSlot = ref<FeedSlot | null>(null)
async function load() {
loading.value = true
error.value = ''
@@ -22,6 +28,19 @@ async function load() {
}
}
async function loadSlots() {
slotsLoading.value = true
slotsError.value = ''
try {
const res = await adminApi.feedSlots()
slots.value = res.items || []
} catch (e) {
slotsError.value = e instanceof Error ? e.message : '加载失败'
} finally {
slotsLoading.value = false
}
}
async function openBanner(id: string) {
try {
selected.value = await adminApi.banner(id)
@@ -30,13 +49,24 @@ async function openBanner(id: string) {
}
}
onMounted(load)
async function openSlot(id: string) {
try {
selectedSlot.value = await adminApi.feedSlot(id)
} catch {
selectedSlot.value = null
}
}
onMounted(() => {
void load()
void loadSlots()
})
</script>
<template>
<section>
<h1>运营位 CMS</h1>
<p class="muted">Banner 只读目录 · UGC · 本切片不可发布</p>
<p class="muted">Banner / FeedSlot 只读 · UGC · 本切片不可发布</p>
<p v-if="loading" class="muted">加载中</p>
<p v-else-if="error" class="err">{{ error }}</p>
<div v-else class="layout">
@@ -59,7 +89,7 @@ onMounted(load)
</table>
</div>
<div class="card">
<h2>详情</h2>
<h2>横幅详情</h2>
<template v-if="selected">
<p>{{ selected.title }} · {{ selected.placement }}</p>
<p class="muted">链接 {{ selected.link_path || '—' }} · 排序 {{ selected.sort_order }}</p>
@@ -67,6 +97,37 @@ onMounted(load)
<p v-else class="muted">选择左侧横幅</p>
</div>
</div>
<p v-if="slotsLoading" class="muted gap">栏目位加载中</p>
<p v-else-if="slotsError" class="err gap">{{ slotsError }}</p>
<div v-else class="layout gap">
<div class="card">
<h2>栏目位 FeedSlot</h2>
<p v-if="!slots.length" class="muted">暂无</p>
<table v-else>
<thead>
<tr><th>代码</th><th>标题</th><th>slot_key</th><th>位置</th><th></th></tr>
</thead>
<tbody>
<tr v-for="s in slots" :key="s.id">
<td><code>{{ s.code }}</code></td>
<td>{{ s.title }}</td>
<td><code>{{ s.slot_key }}</code></td>
<td>{{ s.placement }}</td>
<td><button class="btn" type="button" @click="openSlot(s.id)">查看</button></td>
</tr>
</tbody>
</table>
</div>
<div class="card">
<h2>栏目位详情</h2>
<template v-if="selectedSlot">
<p>{{ selectedSlot.title }} · {{ selectedSlot.placement }}</p>
<p class="muted">slot_key {{ selectedSlot.slot_key }}</p>
</template>
<p v-else class="muted">选择左侧栏目位</p>
</div>
</div>
</section>
</template>
@@ -74,6 +135,7 @@ onMounted(load)
h1 { margin: 0 0 0.35rem; font-size: 1.35rem; }
h2 { margin: 0 0 0.6rem; font-size: 1.05rem; }
.layout { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1rem; margin-top: 1rem; }
.gap { margin-top: 1.5rem; }
code { font-size: 0.8rem; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
</style>