refactor: 统一所有页面按钮文案,合并上传逻辑到保存

1. Sites.vue: '保存' → '保存预览版'
2. SitePages.vue: '保存' → '保存预览版',移除上传按钮和uploadPages函数
3. AccessResultCheck.vue: 两处'保存' → '保存预览版'
4. SitePagesController: savePages/saveDefaultPages 直接包含CDN上传,移除 /upload 端点
This commit is contained in:
mediabot-pt
2026-07-07 18:02:22 +08:00
parent 51e9341748
commit 45f16f2b54
4 changed files with 20 additions and 58 deletions

View File

@@ -49,7 +49,7 @@
</el-select>
<el-button size="small" @click="revertScript">回滚</el-button>
<el-button v-if="hasUnsavedChanges" size="small" @click="resetScript" type="warning">重置</el-button>
<el-button size="small" type="primary" @click="savePreview" :loading="savingPreview" v-if="snapshotStatus">保存</el-button>
<el-button size="small" type="primary" @click="savePreview" :loading="savingPreview" v-if="snapshotStatus">保存预览版</el-button>
<el-button size="small" type="danger" @click="deleteScript" :loading="deleting">删除</el-button>
<template v-if="selectedConfig?.status==='pending'">
<el-button size="small" type="success" @click="approveConfig" :loading="approving">通过</el-button>
@@ -60,7 +60,7 @@
<el-button size="small" type="danger" @click="discardDraftSnapshot" :loading="discardingDraft" v-if="snapshotStatus?.draft.exists">丢弃预览版</el-button>
<el-tag v-if="hasUnsavedChanges" size="small" type="danger" effect="dark">未保存</el-tag>
</template>
<el-button v-if="!scriptExpanded && selectedConfigId" size="small" type="primary" @click="savePreview" :loading="savingPreview">保存</el-button>
<el-button v-if="!scriptExpanded && selectedConfigId" size="small" type="primary" @click="savePreview" :loading="savingPreview">保存预览版</el-button>
</div>
<template v-if="scriptExpanded">
<div style="flex:1;min-height:0;border-radius:4px;overflow:hidden">

View File

@@ -52,9 +52,10 @@
<el-tag v-if="hasUnsavedChanges" size="small" type="danger" effect="dark">未保存</el-tag>
</div>
<div style="display:flex;gap:8px">
<el-button v-if="!isDefaultEditor && snapshotStatus" size="small" type="primary" @click="savePreview" :loading="savingPreview">保存</el-button>
<el-button v-if="!isDefaultEditor && snapshotStatus" size="small" type="primary" @click="savePreview" :loading="savingPreview">保存预览版</el-button>
<el-button v-if="hasUnsavedChanges" size="small" @click="resetEditor" type="warning">重置</el-button>
<el-button size="small" @click="uploadPages" :loading="uploading">上传</el-button>
<el-button v-if="!isDefaultEditor && snapshotStatus?.draft.exists" size="small" type="success" @click="publishSnapshot" :loading="publishing">发布正式版</el-button>
<el-button v-if="!isDefaultEditor && snapshotStatus?.draft.exists" size="small" type="danger" @click="discardDraft" :loading="discardingDraft">丢弃预览版</el-button>
<el-button size="small" type="danger" @click="deletePages" :loading="deleting">删除</el-button>
@@ -123,7 +124,7 @@
<script setup>
import api from '../api'; import { Refresh } from '@element-plus/icons-vue'
const loading = ref(false), saving = ref(false), uploading = ref(false), deleting = ref(false), savingPreview = ref(false), publishing = ref(false), discardingDraft = ref(false)
const loading = ref(false), saving = ref(false), deleting = ref(false), savingPreview = ref(false), publishing = ref(false), discardingDraft = ref(false)
const sites = ref([]), pagesMap = ref({}), sitesList = ref([])
const editSiteId = ref(''), editorJson = ref('{}'), originalJson = ref('')
const snapshotStatus = ref(null)
@@ -282,20 +283,6 @@ const deletePages = async () => {
finally { deleting.value = false }
}
const uploadPages = async () => {
uploading.value = true
try {
if (editSiteId.value.startsWith('default:')) {
const type = editSiteId.value.replace('default:','')
await api.raw.put('/admin/default-pages/'+type+'/upload', { entries: parsed.value })
} else {
await api.raw.put('/admin/site-pages/'+editSiteId.value+'/upload', { entries: parsed.value, authType: authType.value })
}
ElMessage.success('已上传到云存储')
} catch { ElMessage.error('上传失败') }
finally { uploading.value = false }
}
const savePages = async () => {
saving.value = true
try {

View File

@@ -64,7 +64,7 @@
<div style="display:flex;gap:8px">
<el-button size="small" @click="resetEditor" v-if="hasUnsavedChanges" type="warning">重置</el-button>
<el-button size="small" @click="editSiteId=''">返回列表</el-button>
<el-button size="small" type="primary" @click="savePreview" :loading="savingPreview">保存</el-button>
<el-button size="small" type="primary" @click="savePreview" :loading="savingPreview">保存预览版</el-button>
<el-button size="small" @click="discardDraft" :loading="discarding" v-if="snapshotStatus?.draft.exists" type="danger">丢弃预览版</el-button>
<el-button size="small" type="success" @click="publishSite" :loading="publishing">发布正式版</el-button>
</div>