feat: 删除站点自定义脚本回退默认模板

This commit is contained in:
mediabot-pt
2026-07-06 00:11:40 +08:00
parent 3e7467c401
commit d04dcdec4f
2 changed files with 24 additions and 1 deletions

View File

@@ -43,6 +43,7 @@
</el-select>
<el-button size="small" @click="revertScript">回滚</el-button>
<el-button size="small" type="primary" @click="saveScript" :loading="saving">保存</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>
<el-button size="small" type="danger" @click="rejectConfig" :loading="rejecting">拒绝</el-button>
@@ -147,7 +148,7 @@ import { Loading } from '@element-plus/icons-vue'
const route = useRoute()
const siteId = route.params.siteId
const loading = ref(false), parseLoading = ref(false), scriptExpanded = ref(true), historyVersion = ref(null), urlFilter = ref('')
const loading = ref(false), parseLoading = ref(false), scriptExpanded = ref(true), historyVersion = ref(null), urlFilter = ref(''), deleting = ref(false)
const selectedConfigId = ref(null), selectedConfig = ref(null)
const scriptContent = ref(''), saving = ref(false), approving = ref(false), rejecting = ref(false)
const allConfigVersions = ref([]), allResults = ref([])
@@ -297,6 +298,14 @@ const deleteResult = async (page) => {
catch { ElMessage.error('删除失败') }
}
const deleteScript = async () => {
try { await ElMessageBox.confirm('确认删除自定义脚本?删除后站点将使用默认模板','确认',{type:'warning',confirmButtonText:'确认删除'}) } catch { return }
deleting.value = true
try { await api.raw.delete('/admin/configs/'+siteId+'/script'); ElMessage.success('已删除,将使用默认模板'); loadConfigs() }
catch(e) { ElMessage.error(e.response?.data?.message||'删除失败') }
finally { deleting.value = false }
}
const approveConfig = async () => {
if (!selectedConfig.value) return
const label = selectedConfig.value.status==='pending' ? '确认审批?版本号将自动+1' : '确认发布脚本?版本号将+1'