@@ -1,30 +1,102 @@
< script setup lang = "ts" >
import { CheckCircle2 , Save } from "lucide-vue-next" ;
import { CheckCircle2 , Plus , Save , Trash2 } from "lucide-vue-next" ;
defineProps < { ctx : any } > ( ) ;
< / script >
< template >
< section class = "split wide-split " >
< section class = "panel editor-panel " >
< div class = "section-head" >
< section class = "panel page-stack " >
< div class = "section-head " >
< div >
< h2 > { { ctx . activeLegacyLabel } } < / h2 >
< div class = "b utton-row" >
< button class = "btn ghost" @click ="ctx.validateLegacy(ctx.activeLegacyName)" > < CheckCircle2 :size = "16" / > 校验 < / button >
< button class = "btn primary" @click ="ctx.saveLegacy(ctx.activeLegacyName)" > < Save :size = "16" / > 保存发布 < / button >
< / div >
< p class = "m uted" > 以当前兼容 JSON 为基板 , 表单保存会合并进原 JSON , 未知字段保留 。 < / p >
< / div >
< div class = "button-row" >
< button class = "btn ghost" @click ="ctx.validateLegacy(ctx.activeLegacyName)" > < CheckCircle2 :size = "16" / > 校验 < / button >
< button class = "btn primary" @click ="ctx.saveLegacy(ctx.activeLegacyName)" > < Save :size = "16" / > 保存发布 < / button >
< / div >
< / div >
< div class = "tabs" >
< button : class = "{ active: ctx.legacyDrafts[ctx.activeLegacyName].tab === 'form' }" @click ="ctx.legacyDrafts[ctx.activeLegacyName].tab = 'form'" > 可视化表单 < / button >
< button : class = "{ active: ctx.legacyDrafts[ctx.activeLegacyName].tab === 'raw' }" @click ="ctx.legacyDrafts[ctx.activeLegacyName].tab = 'raw'" > Raw JSON < / button >
< button : class = "{ active: ctx.legacyDrafts[ctx.activeLegacyName].tab === 'preview' }" @click ="ctx.legacyDrafts[ctx.activeLegacyName].tab = 'preview'" > 预览 < / button >
< button : class = "{ active: ctx.legacyDrafts[ctx.activeLegacyName].tab === 'history' }" @click ="ctx.legacyDrafts[ctx.activeLegacyName].tab = 'history'" > 历史版本 < / button >
< / div >
< section v-if = "ctx.legacyDrafts[ctx.activeLegacyName].tab === 'form' && ctx.activeLegacyName === 'update-info'" class="form-grid" >
< label > 版本号 < input v-model = "ctx.legacyDrafts['update-info'].form.app_version" / > < / label >
< label > 标题 < input v-model = "ctx.legacyDrafts['update-info'].form.title" / > < / label >
< label class = "wide" > 公告 < textarea v-model = "ctx.legacyDrafts['update-info'].form.message" rows="3" > < / textarea > < / label >
< label class = "wide" > 下载地址 < input v-model = "ctx.legacyDrafts['update-info'].form.download_url" / > < / label >
< label > 包 SHA256 < input v-model = "ctx.legacyDrafts['update-info'].form.package_sha256" / > < / label >
< label > 包大小 < input v-model = "ctx.legacyDrafts['update-info'].form.package_size" type="number" / > < / label >
< label class = "wide" > 发布说明 < textarea v-model = "ctx.legacyDrafts['update-info'].form.release_notes" rows="4" > < / textarea > < / label >
< label class = "wide" > 发布说明 Markdown < textarea v-model = "ctx.legacyDrafts['update-info'].form.release_notes_md" rows="5" > < / textarea > < / label >
< label class = "wide" > 更新说明 JSON < textarea v-model = "ctx.legacyDrafts['update-info'].form.update_notes" class="code-editor mini-editor" > < / textarea > < / label >
< label class = "wide" > 上次更新说明 JSON < textarea v-model = "ctx.legacyDrafts['update-info'].form.last_update_notes" class="code-editor mini-editor" > < / textarea > < / label >
< div class = "wide button-row" >
< button class = "btn ghost" @click ="ctx.addUpdateMirror" > < Plus :size = "16" / > 新增镜像字段到底稿 < / button >
< button class = "btn" @click ="ctx.updateLegacyRawFromForm('update-info')" > 生成预览 JSON < / button >
< / div >
< / section >
< section v-else-if = "ctx.legacyDrafts[ctx.activeLegacyName].tab === 'form'" class="page-stack" >
< div class = "form-grid" >
< label > 布局版本 < input v-model = "ctx.legacyDrafts['media-types'].form.layout_version" / > < / label >
< label > 更新时间 < input v-model = "ctx.legacyDrafts['media-types'].form.last_updated" / > < / label >
< label class = "wide" > UI 配置 JSON < textarea v-model = "ctx.legacyDrafts['media-types'].form.ui_config" class="code-editor mini-editor" > < / textarea > < / label >
< / div >
< div class = "button-row" >
< button class = "btn ghost" @click ="ctx.addMediaCategory('media-types')" > < Plus :size = "16" / > 新增分类 < / button >
< button class = "btn" @click ="ctx.updateLegacyRawFromForm('media-types')" > 生成预览 JSON < / button >
< / div >
< section v-for = "(cat, cIndex) in ctx.legacyDrafts['media-types'].form.categories" :key="cIndex" class="nested-card" >
< div class = "section-head" >
< h3 > 分类 { { cIndex + 1 } } < / h3 >
< button class = "btn ghost compact" @click ="ctx.removeItem(ctx.legacyDrafts['media-types'].form.categories, cIndex)" > < Trash2 :size = "14" / > 删除 < / button >
< / div >
< div class = "form-grid" >
< label > ID < input v-model = "cat.id" / > < / label >
< label > 名称 < input v-model = "cat.name" / > < / label >
< label class = "checkbox" > < input v-model = "cat.enabled" type="checkbox" / > 启用分类 < / label >
< / div >
< div class = "button-row" >
< button class = "btn ghost compact" @click ="ctx.addMediaSubcategory(cat)" > < Plus :size = "14" / > 新增子接口 < / button >
< / div >
< section v-for = "(sub, sIndex) in cat.subcategories" :key="sIndex" class="nested-card inner" >
< div class = "section-head" >
< h3 > { { sub . name || "子接口" } } < / h3 >
< button class = "btn ghost compact" @click ="ctx.removeItem(cat.subcategories, sIndex)" > < Trash2 :size = "14" / > 删除 < / button >
< / div >
< div class = "form-grid" >
< label > ID < input v-model = "sub.id" / > < / label >
< label > 名称 < input v-model = "sub.name" / > < / label >
< label class = "wide" > 接口 URL < input v-model = "sub.api_url" / > < / label >
< label > 缩略图 < input v-model = "sub.thumbnail_url" / > < / label >
< label > 刷新间隔 < input v -model .number = " sub.refresh_interval " type = "number" / > < / label >
< label > 格式 < input v-model = "sub.supported_formats" placeholder="json, xml" / > < / label >
< label class = "checkbox" > < input v-model = "sub.downloadable" type="checkbox" / > 可下载 < / label >
< label class = "wide" > 描述 < textarea v-model = "sub.description" rows="2" > < / textarea > < / label >
< / div >
< / section >
< / section >
< / section >
< section v-else-if = "ctx.legacyDrafts[ctx.activeLegacyName].tab === 'raw'" class="page-stack" >
< textarea v-model = "ctx.legacyDrafts[ctx.activeLegacyName].raw" class="code-editor" > < / textarea >
< label > 保存备注 < input v-model = "ctx.legacyDrafts[ctx.activeLegacyName].note" / > < / label >
< / section >
< aside class = "panel page-stack" >
< h2 > 预览与历史 < / h2 >
< pre class = "json-preview" > { { ctx . pretty ( ctx . legacyDrafts [ ctx . activeLegacyName ] . preview ) } } < / pre >
< div class = "revision-list" >
< button v-for = "revision in ctx.legacyDocuments[ctx.activeLegacyName]?.revisions || []" :key="revision.id" @click="ctx.restoreLegacy(ctx.activeLegacyName, revision.id)" >
# {{ revision.id }} {{ revision.createdAt }} < small > { { revision . note || "无备注" } } < / small >
< / button >
< / div >
< / aside >
< section v-else-if = "ctx.legacyDrafts[ctx.activeLegacyName].tab === 'preview'" >
< pre class = "json-preview tall " > { { ctx . pretty ( ctx . legacyDrafts [ ctx . activeLegacyName ] . preview ) } } < / pre >
< / section >
< section v-else class = "revision-list" >
< button v-for = "revision in ctx.legacyDocuments[ctx.activeLegacyName]?.revisions || []" :key="revision.id" @click="ctx.restoreLegacy(ctx.activeLegacyName, revision.id)" >
# {{ revision.id }} {{ revision.createdAt }} < small > { { revision . note || "无备注" } } < / small >
< / button >
< div v-if = "(ctx.legacyDocuments[ctx.activeLegacyName]?.revisions || []).length === 0" class="empty-state compact" > 暂无历史版本 。 < / div >
< / section >
< / section >
< / template >