feat: 脚本下载/编辑接口、前端Groovy编辑器、Groovy错误行号提取
This commit is contained in:
@@ -79,6 +79,8 @@ export default {
|
||||
pendingBySite: (siteId) => api.get(`/admin/configs/pending/${siteId}`),
|
||||
getContent: (configId) => api.get(`/admin/configs/${configId}/content`),
|
||||
updateContent: (configId, content) => api.put(`/admin/configs/${configId}/content`, { content }),
|
||||
getScript: (configId) => api.get(`/admin/configs/${configId}/script`),
|
||||
updateScript: (configId, script) => api.put(`/admin/configs/${configId}/script`, { script }),
|
||||
approve: (configId) => api.post(`/admin/reviews/${configId}/approve`),
|
||||
reject: (configId, comment) => api.post(`/admin/reviews/${configId}/reject`, null, { params: { comment: comment || '' } }),
|
||||
},
|
||||
|
||||
@@ -48,20 +48,33 @@
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<!-- 配置编辑弹窗 -->
|
||||
<el-dialog v-model="configVisible" title="适配配置" width="700px" :close-on-click-modal="false">
|
||||
<template v-if="editing">
|
||||
<el-input v-model="editContent" type="textarea" :rows="20" style="font-family:monospace;font-size:12px" />
|
||||
<div style="margin-top:10px;display:flex;gap:8px">
|
||||
<el-button type="primary" size="small" @click="saveEdit" :loading="saving">保存</el-button>
|
||||
<el-button size="small" @click="cancelEdit">取消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<pre v-else class="config-json" v-html="highlightedConfig"></pre>
|
||||
<!-- 配置/脚本弹窗 -->
|
||||
<el-dialog v-model="configVisible" title="适配配置" width="800px" :close-on-click-modal="false">
|
||||
<el-tabs v-model="configTab" type="card" size="small">
|
||||
<el-tab-pane label="配置JSON" name="config">
|
||||
<template v-if="editing">
|
||||
<el-input v-model="editContent" type="textarea" :rows="20" style="font-family:monospace;font-size:12px" />
|
||||
</template>
|
||||
<pre v-else class="config-json" v-html="highlightedConfig"></pre>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="Groovy 脚本" name="script">
|
||||
<div v-if="scriptLoading" style="text-align:center;padding:20px;color:#909399">加载中...</div>
|
||||
<template v-else>
|
||||
<el-input v-model="scriptContent" type="textarea" :rows="20" style="font-family:monospace;font-size:12px"
|
||||
placeholder="// Groovy 解析脚本 // 内置变量: content(页面内容), url(访问URL), jsoup, json, utils def doc = jsoup.parse(content) ..." />
|
||||
</template>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<template #footer>
|
||||
<el-button @click="configVisible=false">关闭</el-button>
|
||||
<template v-if="!editing && selectedConfig?.status==='pending'">
|
||||
<el-button type="primary" size="small" @click="startEdit">编辑</el-button>
|
||||
<template v-if="selectedConfig?.status==='pending'">
|
||||
<el-button v-if="configTab==='config'" type="primary" size="small" @click="editing? saveEdit() : startEdit()">
|
||||
{{ editing ? '保存' : '编辑' }}
|
||||
</el-button>
|
||||
<el-button v-if="configTab==='config' && editing" size="small" @click="cancelEdit">取消</el-button>
|
||||
<el-button v-if="configTab==='script'" type="primary" size="small" @click="saveScript" :loading="saving">
|
||||
保存脚本
|
||||
</el-button>
|
||||
</template>
|
||||
</template>
|
||||
</el-dialog>
|
||||
@@ -158,8 +171,12 @@ const selectedConfigId = ref(null)
|
||||
const selectedConfig = ref(null)
|
||||
const selectedConfigJson = ref('')
|
||||
const configVisible = ref(false)
|
||||
watch(configVisible, (v) => { if (v) { configTab.value='config'; loadScript() } })
|
||||
const configTab = ref('config')
|
||||
const editing = ref(false)
|
||||
const editContent = ref('')
|
||||
const scriptContent = ref('')
|
||||
const scriptLoading = ref(false)
|
||||
const saving = ref(false)
|
||||
const approving = ref(false)
|
||||
const rejecting = ref(false)
|
||||
@@ -259,6 +276,21 @@ const refresh = async () => {
|
||||
// 编辑
|
||||
const startEdit = () => { editContent.value=selectedConfigJson.value; editing.value=true }
|
||||
const cancelEdit = () => { editing.value=false }
|
||||
const loadScript = async () => {
|
||||
if (!selectedConfig.value) return
|
||||
scriptLoading.value = true
|
||||
try { const r = await api.adminConfigs.getScript(selectedConfig.value.id); scriptContent.value = r.data?.script || '' }
|
||||
catch { scriptContent.value = '' }
|
||||
finally { scriptLoading.value = false }
|
||||
}
|
||||
const saveScript = async () => {
|
||||
saving.value = true
|
||||
try {
|
||||
await api.adminConfigs.updateScript(selectedConfig.value.id, scriptContent.value)
|
||||
ElMessage.success('脚本已保存'); doBatchParse()
|
||||
} catch(e) { ElMessage.error(e.response?.data?.message||'保存失败') }
|
||||
finally { saving.value = false }
|
||||
}
|
||||
const saveEdit = async () => {
|
||||
saving.value = true
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user