feat: 快照改为预览版/正式版两阶段发布 - 新增 saveDraft 接口手动保存草稿快照 - 新增 getDraftBundleJson 方法读取预览版(Caffeine缓存) - SnapshotController 支持 ?preview=true 参数读取 draft - 前端编辑页改为'保存草稿'+'发布正式版'两个按钮 - AdminController 新增单站点 save-draft/publish 接口 - 复用 populateSnapshotFields 消除重复代码
This commit is contained in:
@@ -56,8 +56,8 @@
|
||||
<h2 style="margin:0">站点编辑: {{ editSiteId }}</h2>
|
||||
<div style="display:flex;gap:8px">
|
||||
<el-button size="small" @click="editSiteId=''">返回列表</el-button>
|
||||
<el-button size="small" type="primary" @click="saveSite" :loading="saving">保存</el-button>
|
||||
<el-button size="small" @click="publishAll" :loading="publishing">发布</el-button>
|
||||
<el-button size="small" @click="saveDraft" :loading="savingDraft">保存草稿</el-button>
|
||||
<el-button size="small" type="success" @click="publishSite" :loading="publishing">发布正式版</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:flex;gap:12px;flex:1;min-height:0">
|
||||
@@ -107,7 +107,7 @@
|
||||
<script setup>
|
||||
import api from '../api'
|
||||
|
||||
const loading = ref(false), saving = ref(false), publishing = ref(false), pendingCount = ref(0)
|
||||
const loading = ref(false), saving = ref(false), savingDraft = ref(false), publishing = ref(false), pendingCount = ref(0)
|
||||
const sites = ref([]), editSiteId = ref(''), editorJson = ref('{}'), jsonError = ref(false)
|
||||
const form = reactive({ siteId:'', namesStr:'', urlsStr:'', tagsStr:'', desc:'', siteType:'nexusphp', status:'active' })
|
||||
let syncing = false
|
||||
@@ -154,11 +154,20 @@ const newSite = () => {
|
||||
editorJson.value = JSON.stringify({siteId:'',names:[''],urls:[''],siteType:'nexusphp',status:'active'}, null, 2)
|
||||
}
|
||||
|
||||
const publishAll = async () => {
|
||||
const saveDraft = async () => {
|
||||
savingDraft.value = true
|
||||
try {
|
||||
await api.raw.post('/admin/sites/' + editSiteId.value + '/save-draft')
|
||||
ElMessage.success('草稿已保存(预览版)')
|
||||
} catch { ElMessage.error('保存草稿失败') }
|
||||
finally { savingDraft.value = false }
|
||||
}
|
||||
|
||||
const publishSite = async () => {
|
||||
publishing.value = true
|
||||
try {
|
||||
await api.raw.post('/admin/sites/publish')
|
||||
ElMessage.success('已发布到云存储')
|
||||
await api.raw.post('/admin/sites/' + editSiteId.value + '/publish')
|
||||
ElMessage.success('已发布为正式版')
|
||||
} catch { ElMessage.error('发布失败') }
|
||||
finally { publishing.value = false }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user