feat: 新增交通银行数据导出插件及测试通道机制

This commit is contained in:
2026-11-05 15:20:34 +08:00
parent b976b80d9d
commit 4e8b3e7d43
230 changed files with 19827 additions and 1440 deletions
@@ -20,8 +20,8 @@ export function fetchPlugins(params: { page?: number; page_size?: number; q?: st
return request.get<{ items: any[]; total: number }>({ url: '/api/admin/plugins', params })
}
/** 上传发布插件包(multipart) */
export function uploadPlugin(file: File, params: { plugin_id: string; name?: string; version: string }) {
/** 上传发布插件包(multipart;channel=test 进测试通道,仅管理员可见) */
export function uploadPlugin(file: File, params: { plugin_id: string; name?: string; version: string; channel?: string }) {
const fd = new FormData()
fd.append('file', file)
return request.post<any>({ url: '/api/admin/pkg', data: fd, params, timeout: 300000 })
@@ -22,10 +22,12 @@ const authorizedCount = computed(() => stats.value.users?.authorized || 0)
const pluginStatus = computed(() => {
const plugins = overview.value.plugins || []
const published = plugins.filter((p: any) => p.status === 'published').length
const testing = plugins.filter((p: any) => p.status === 'testing').length
const disabled = plugins.filter((p: any) => p.status === 'disabled').length
const revoked = plugins.filter((p: any) => p.status === 'revoked').length
return [
{ name: '已发布', value: published },
{ name: '测试中', value: testing },
{ name: '已停用', value: disabled },
{ name: '已吊销', value: revoked }
]
@@ -17,6 +17,7 @@ const query = reactive({ page: 1, page_size: 10, q: '' })
const statusMap: Record<string, { label: string; type: any }> = {
published: { label: '已发布', type: 'success' },
testing: { label: '测试中', type: 'primary' },
disabled: { label: '已禁用', type: 'warning' },
revoked: { label: '已下架', type: 'danger' }
}
@@ -40,10 +41,10 @@ function search() {
// ---- 上传发布 ----
const uploadOpen = ref(false)
const uploading = ref(false)
const uploadForm = reactive({ plugin_id: '', name: '', version: '', file: null as File | null })
const uploadForm = reactive({ plugin_id: '', name: '', version: '', channel: 'test', file: null as File | null })
function openUpload() {
Object.assign(uploadForm, { plugin_id: '', name: '', version: '', file: null })
Object.assign(uploadForm, { plugin_id: '', name: '', version: '', channel: 'test', file: null })
uploadOpen.value = true
}
@@ -57,9 +58,10 @@ async function submitUpload() {
await uploadPlugin(uploadForm.file, {
plugin_id: uploadForm.plugin_id,
name: uploadForm.name,
version: uploadForm.version
version: uploadForm.version,
channel: uploadForm.channel
})
ElMessage.success('上传发布成功')
ElMessage.success(uploadForm.channel === 'test' ? '测试版已上传(仅管理员可见)' : '已直发正式版')
uploadOpen.value = false
load()
} finally {
@@ -74,6 +76,22 @@ async function setStatus(row: any, status: string) {
load()
}
// ---- 测试版转正:把在测版本提升为正式版,全量已授权账号生效 ----
async function promote(row: any) {
try {
await ElMessageBox.confirm(
`确认把测试版 v${row.test_version} 转正?转正后所有已授权账号下次同步即升级到该版本(不再单独打包)。`,
'测试版转正',
{ type: 'warning', confirmButtonText: '转正发布', cancelButtonText: '取消' }
)
} catch {
return
}
await patchPlugin(row.id, { status: 'published' })
ElMessage.success(`v${row.test_version} 已转正为正式版`)
load()
}
// ---- 分类维护(字典 plugin_category:在「分类管理」弹窗中增删改/排序) ----
const DICT_KEY = 'plugin_category'
const categories = ref<{ id: number; label: string }[]>([])
@@ -246,7 +264,15 @@ onMounted(() => {
<el-table v-loading="loading" :data="list" border stripe>
<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 label="正式版本" width="110">
<template #default="{ row }">{{ row.latest_version || '-' }}</template>
</el-table-column>
<el-table-column label="在测版本" width="110">
<template #default="{ row }">
<el-tag v-if="row.test_version" size="small" type="primary">{{ row.test_version }}</el-tag>
<span v-else class="text-gray-300 text-xs">-</span>
</template>
</el-table-column>
<el-table-column prop="category" label="分类" width="150">
<template #default="{ row }">
<el-select
@@ -297,7 +323,12 @@ onMounted(() => {
@click="setStatus(row, 'published')"
>启用</el-button>
<el-button
v-if="row.status === 'published'"
v-if="row.status === 'testing' && row.test_version"
link type="primary"
@click="promote(row)"
>转正</el-button>
<el-button
v-if="row.status === 'published' || row.status === 'testing'"
link type="warning"
@click="setStatus(row, 'disabled')"
>禁用</el-button>
@@ -338,6 +369,16 @@ onMounted(() => {
<el-form-item label="安装包" required>
<input type="file" accept=".zip" @change="(e: any) => (uploadForm.file = e.target.files[0] || null)" />
</el-form-item>
<el-form-item label="发布通道">
<el-radio-group v-model="uploadForm.channel">
<el-radio value="test">测试版(仅管理员可见)</el-radio>
<el-radio value="prod">正式版(立即全量生效)</el-radio>
</el-radio-group>
<div class="text-xs text-gray-400 leading-5 mt-1">
测试版发布后状态为「测试中」:管理员账号同步到新版本,其他账号继续用当前正式版。
人工验证通过后点列表里的「转正」即全量生效。
</div>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="uploadOpen = false">取消</el-button>