feat: 新增多插件 UI 支持及运行日志集中回传功能
本次提交包含多项功能更新: 1. 为多个插件(xq0002/0003/0004/0008/0010/0011/0020/0031_xq0032/0033/0035/0037/0045_xq0046/0047/0048)新增 UI 界面及配置支持 2. 新增运行日志集中回传功能,客户端自动上传运行日志到中心机集中存储 3. 新增插件分类字段支持,用于场景库分组管理 4. 优化 xq0034/0037/0048 等插件的功能及描述 5. 修复控制面响应兼容问题,支持新旧版本数据格式 6. 新增 xq0033 插件的状态存储模块,用于历史记录管理 7. 优化 CRM 登录窗口模式,支持全屏置顶
This commit is contained in:
@@ -5,7 +5,10 @@
|
||||
*/
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { fetchPlugins, uploadPlugin, patchPlugin, deletePlugin } from '@/api/business'
|
||||
import {
|
||||
fetchPlugins, uploadPlugin, patchPlugin, deletePlugin,
|
||||
fetchDictItems, addDictItem, updateDictItem, deleteDictItem
|
||||
} from '@/api/business'
|
||||
|
||||
const loading = ref(false)
|
||||
const list = ref<any[]>([])
|
||||
@@ -71,6 +74,91 @@ async function setStatus(row: any, status: string) {
|
||||
load()
|
||||
}
|
||||
|
||||
// ---- 分类维护(字典 plugin_category:在「分类管理」弹窗中增删改/排序) ----
|
||||
const DICT_KEY = 'plugin_category'
|
||||
const categories = ref<{ id: number; label: string }[]>([])
|
||||
|
||||
async function loadDict() {
|
||||
try {
|
||||
const r = await fetchDictItems(DICT_KEY)
|
||||
categories.value = r.items || []
|
||||
} catch {
|
||||
categories.value = []
|
||||
}
|
||||
}
|
||||
|
||||
/** 下拉选项:字典 + 当前值兜底(避免历史分类值被隐藏) */
|
||||
function categoryOptions(row: any): string[] {
|
||||
const labels = categories.value.map((c) => c.label)
|
||||
const cur = String(row.category || '').trim()
|
||||
return cur && !labels.includes(cur) ? [...labels, cur] : labels
|
||||
}
|
||||
|
||||
// ---- 场景分类字典管理弹窗 ----
|
||||
const dictOpen = ref(false)
|
||||
const dictSaving = ref(false)
|
||||
const newLabel = ref('')
|
||||
|
||||
function openDict() {
|
||||
newLabel.value = ''
|
||||
dictOpen.value = true
|
||||
loadDict()
|
||||
}
|
||||
|
||||
async function submitAddDict() {
|
||||
const label = newLabel.value.trim()
|
||||
if (!label) {
|
||||
ElMessage.warning('请输入分类名称')
|
||||
return
|
||||
}
|
||||
dictSaving.value = true
|
||||
try {
|
||||
await addDictItem(DICT_KEY, label)
|
||||
newLabel.value = ''
|
||||
await loadDict()
|
||||
} finally {
|
||||
dictSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function renameDictItem(it: { id: number; label: string }) {
|
||||
const { value } = await ElMessageBox.prompt('修改分类名称(已设置旧分类的插件不会自动跟随,需重新选择)', '重命名分类', {
|
||||
inputValue: it.label,
|
||||
inputPattern: /\S+/,
|
||||
inputErrorMessage: '名称不能为空'
|
||||
})
|
||||
await updateDictItem(DICT_KEY, it.id, { label: String(value).trim() })
|
||||
ElMessage.success('已重命名')
|
||||
await loadDict()
|
||||
}
|
||||
|
||||
async function moveDictItem(it: { id: number; label: string }, move: 'up' | 'down') {
|
||||
await updateDictItem(DICT_KEY, it.id, { move })
|
||||
await loadDict()
|
||||
}
|
||||
|
||||
async function removeDictItem(it: { id: number; label: string }) {
|
||||
await ElMessageBox.confirm(`从字典移除分类「${it.label}」?已设置该分类的插件不受影响。`, '删除确认', {
|
||||
type: 'warning'
|
||||
})
|
||||
await deleteDictItem(DICT_KEY, it.id)
|
||||
ElMessage.success('已删除')
|
||||
await loadDict()
|
||||
}
|
||||
|
||||
async function setCategory(row: any, val: string) {
|
||||
const prev = row.category || ''
|
||||
const next = String(val || '').trim()
|
||||
if (next === prev) return
|
||||
row.category = next
|
||||
try {
|
||||
await patchPlugin(row.id, { category: next })
|
||||
ElMessage.success(next ? `分类已更新为「${next}」` : '已清空分类')
|
||||
} catch {
|
||||
row.category = prev
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 强制更新 ----
|
||||
const forceOpen = ref(false)
|
||||
const forceSaving = ref(false)
|
||||
@@ -125,13 +213,17 @@ async function remove(row: any) {
|
||||
load()
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
onMounted(() => {
|
||||
load()
|
||||
loadDict()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="p-5 space-y-4">
|
||||
<ArtPageHeader title="插件管理" description="插件上传发布、版本管理与强制更新">
|
||||
<template #actions>
|
||||
<el-button @click="openDict"><ArtSvgIcon icon="ri:book-2-line" class="mr-1" />分类管理</el-button>
|
||||
<el-button type="primary" @click="openUpload"><ArtSvgIcon icon="ri:upload-2-line" class="mr-1" />上传发布</el-button>
|
||||
</template>
|
||||
</ArtPageHeader>
|
||||
@@ -155,7 +247,20 @@ onMounted(load)
|
||||
<el-table-column prop="id" label="插件ID" min-width="140" />
|
||||
<el-table-column prop="name" label="名称" min-width="160" />
|
||||
<el-table-column prop="latest_version" label="最新版本" width="110" />
|
||||
<el-table-column prop="category" label="分类" width="110" />
|
||||
<el-table-column prop="category" label="分类" width="150">
|
||||
<template #default="{ row }">
|
||||
<el-select
|
||||
:model-value="row.category || ''"
|
||||
size="small"
|
||||
clearable
|
||||
placeholder="未分类"
|
||||
style="width: 100%"
|
||||
@change="(v: string) => setCategory(row, v)"
|
||||
>
|
||||
<el-option v-for="c in categoryOptions(row)" :key="c" :label="c" :value="c" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusMap[row.status]?.type || 'info'" size="small">
|
||||
@@ -265,5 +370,34 @@ onMounted(load)
|
||||
<el-button type="primary" :loading="forceSaving" @click="submitForce">设置</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<!-- 场景分类字典管理弹窗 -->
|
||||
<el-dialog v-model="dictOpen" title="场景分类管理" width="460px">
|
||||
<div class="max-h-[320px] overflow-y-auto space-y-0.5">
|
||||
<div
|
||||
v-for="(it, i) in categories"
|
||||
:key="it.id"
|
||||
class="flex items-center gap-1 px-2 py-1.5 rounded-lg hover:bg-gray-50"
|
||||
>
|
||||
<span class="flex-1 text-sm">{{ it.label }}</span>
|
||||
<el-button link size="small" :disabled="i === 0" @click="moveDictItem(it, 'up')">上移</el-button>
|
||||
<el-button link size="small" :disabled="i === categories.length - 1" @click="moveDictItem(it, 'down')">下移</el-button>
|
||||
<el-button link size="small" type="primary" @click="renameDictItem(it)">重命名</el-button>
|
||||
<el-button link size="small" type="danger" @click="removeDictItem(it)">删除</el-button>
|
||||
</div>
|
||||
<div v-if="!categories.length" class="py-6 text-center text-sm text-gray-400">暂无分类,先在下方新增一个</div>
|
||||
</div>
|
||||
<div class="flex gap-2 mt-3">
|
||||
<el-input
|
||||
v-model="newLabel"
|
||||
placeholder="新分类名称(回车快速添加)"
|
||||
maxlength="64"
|
||||
@keyup.enter="submitAddDict"
|
||||
/>
|
||||
<el-button type="primary" :loading="dictSaving" @click="submitAddDict">新增</el-button>
|
||||
</div>
|
||||
<div class="px-1 mt-2 text-xs text-gray-400 leading-5">
|
||||
分类字典供插件列表下拉选择,执行机客户端场景库按分类分组展示;删除/重命名不影响已设置的插件。
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user