feat: 脚本编辑器加历史版本下拉,可查看任意已发布版本的脚本
This commit is contained in:
@@ -44,7 +44,10 @@
|
||||
Groovy 脚本
|
||||
</span>
|
||||
<template v-if="scriptExpanded && selectedConfigId">
|
||||
<el-button size="small" @click="revertScript">回滚</el-button>
|
||||
<el-select v-model="historyVersion" size="small" style="width:140px" placeholder="历史版本" clearable @change="loadHistoryScript">
|
||||
<el-option v-for="v in allConfigVersions" :key="v.id" :label="'v'+v.version+' '+v.status" :value="v.id" />
|
||||
</el-select>
|
||||
<el-button size="small" @click="revertScript">回滚当前</el-button>
|
||||
<el-button size="small" type="primary" @click="saveScript" :loading="saving">保存</el-button>
|
||||
</template>
|
||||
<el-button v-if="!scriptExpanded && selectedConfigId" size="small" type="primary" @click="saveScript" :loading="saving">保存</el-button>
|
||||
@@ -137,7 +140,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)
|
||||
const loading = ref(false), parseLoading = ref(false), scriptExpanded = ref(true), historyVersion = ref(null)
|
||||
const selectedConfigId = ref(null), selectedConfig = ref(null)
|
||||
const scriptContent = ref(''), saving = ref(false), approving = ref(false), rejecting = ref(false)
|
||||
const allConfigVersions = ref([]), allResults = ref([])
|
||||
@@ -205,6 +208,12 @@ const loadScript = async () => {
|
||||
|
||||
watch(selectedConfig, (v) => { if (v) loadScript() })
|
||||
|
||||
const loadHistoryScript = async (configId) => {
|
||||
if (!configId) return
|
||||
try { const r = await api.adminConfigs.getScript(configId); scriptContent.value = r.data?.script || '' }
|
||||
catch { ElMessage.error('加载失败') }
|
||||
}
|
||||
|
||||
const revertScript = async () => {
|
||||
if (!selectedConfig.value) return
|
||||
try { await ElMessageBox.confirm('确认回滚?未保存的修改将丢失。','回滚脚本',{confirmButtonText:'确认',type:'warning'}) } catch{return}
|
||||
|
||||
Reference in New Issue
Block a user