Files
37duAutomation/desktop/controlplane/frontend/src/views/FileSourceManageView.vue
T
puddy b32f8e8fe2 feat: 新增xq0031_xq0032 ERP报表导出插件,完成功能与基建更新
1. 新增xq0031_xq0032插件:包含前后端源码、打包脚本、配置文件与插件元数据
2. 新增内网文件服务器组件:exe、启停脚本、打包脚本与配置
3. 新增敏感凭证RSA加密下发能力与存储结构
4. 新增大文件源管理表与相关API
5. 优化登录流程与会话管理,新增Chrome自动化安装工具链
6. 清理废弃插件与示例代码
7. 更新版本号至1.1.3,完善安装包与.gitignore配置
2026-09-17 12:42:44 +08:00

186 lines
7.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="page">
<div class="page-head cp-rise">
<div>
<h3>大文件源 <span class="badge">File Sources</span></h3>
<p>内网大文件(壳子/Chrome 等)直链登记。中心机只存链接,文件本身走内网文件服务器</p>
</div>
<div class="head-actions">
<el-select v-model="filter" placeholder="按分类过滤" style="width: 150px" clearable @change="refresh">
<el-option v-for="c in categories" :key="c" :label="c" :value="c" />
</el-select>
<el-button :loading="busy" :icon="Refresh" @click="refresh">刷新</el-button>
<el-button type="primary" :icon="Plus" @click="openCreate">登记链接</el-button>
</div>
</div>
<div class="cp-card panel cp-rise">
<el-table :data="rows" v-loading="busy" size="default" style="width: 100%">
<el-table-column prop="category" label="分类" width="110">
<template #default="{ row }">
<el-tag :type="catType(row.category)" size="small" effect="light">{{ row.category }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="version" label="版本" width="90">
<template #default="{ row }"><span class="mono">{{ row.version }}</span></template>
</el-table-column>
<el-table-column prop="filename" label="文件" min-width="150" show-overflow-tooltip />
<el-table-column label="内网直链" min-width="260" show-overflow-tooltip>
<template #default="{ row }">
<span class="mono dim url">{{ row.url }}</span>
</template>
</el-table-column>
<el-table-column label="SHA256" width="120">
<template #default="{ row }">
<el-button v-if="row.sha256" link type="primary" @click="copy(row.sha256, 'SHA256')">
{{ row.sha256.slice(0, 8) }}…
</el-button>
<span v-else class="dim">—</span>
</template>
</el-table-column>
<el-table-column label="说明" min-width="140" show-overflow-tooltip>
<template #default="{ row }">{{ row.notes || '—' }}</template>
</el-table-column>
<el-table-column prop="updated_at" label="更新时间" width="160" />
<el-table-column label="启用" width="70" align="center">
<template #default="{ row }">
<el-switch :model-value="!!row.enabled" :loading="row._tog" @change="(v) => toggle(row, v)" />
</template>
</el-table-column>
<el-table-column label="操作" width="130" fixed="right">
<template #default="{ row }">
<el-button link type="primary" @click="copy(row.url, '链接')">复制</el-button>
<el-button link type="danger" :icon="Delete" @click="remove(row)">删除</el-button>
</template>
</el-table-column>
<template #empty>
<el-empty description="暂无登记的大文件源" :image-size="80" />
</template>
</el-table>
</div>
<el-dialog v-model="dlg" title="登记内网直链" width="560px">
<div class="form">
<div class="fitem">
<label>分类 <span class="dim">(shell / chrome / …)</span></label>
<el-input v-model="form.category" placeholder="如 chrome" />
</div>
<div class="fitem">
<label>版本</label>
<el-input v-model="form.version" placeholder="如 1.0.0" />
</div>
<div class="fitem">
<label>文件名</label>
<el-input v-model="form.filename" placeholder="如 ChromeStandaloneSetup64.exe" />
</div>
<div class="fitem">
<label>内网直链 url</label>
<el-input v-model="form.url" placeholder="http://内网IP:8802/files/..." />
</div>
<div class="fitem">
<label>SHA256 <span class="dim">(可选)</span></label>
<el-input v-model="form.sha256" placeholder="文件校验值,客户端下载后校验" />
</div>
<div class="fitem">
<label>说明 <span class="dim">(可选)</span></label>
<el-input v-model="form.notes" type="textarea" :rows="2" placeholder="备注" />
</div>
<p class="tip">同一 分类+版本 会覆盖旧记录;删除仅移除中心机登记,不影响内网文件服务器上的文件。</p>
</div>
<template #footer>
<el-button @click="dlg = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="save">保存</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup>
import { onMounted, ref } from 'vue'
import { Refresh, Plus, Delete } from '@element-plus/icons-vue'
import { ElMessage as message, ElMessageBox } from 'element-plus'
import { adminFileSources, adminFileSourceCreate, adminFileSourcePatch, adminFileSourceDelete } from '../api'
const CATS = ['shell', 'chrome']
const categories = CATS
const busy = ref(false)
const rows = ref([])
const filter = ref('')
const dlg = ref(false)
const saving = ref(false)
const form = ref({})
async function refresh() {
busy.value = true
try {
const r = await adminFileSources(filter.value || '')
rows.value = r.files || []
const seen = new Set(CATS)
;(r.files || []).forEach((f) => seen.add(f.category))
categories.length = 0
;[...seen].sort().forEach((c) => categories.push(c))
} catch (e) { message.error('读取失败:' + (e.message || e)) }
finally { busy.value = false }
}
function catType(c) {
return { shell: 'success', chrome: 'warning' }[c] || 'info'
}
function openCreate() {
form.value = { category: '', version: '', filename: '', url: '', sha256: '', notes: '', enabled: true }
dlg.value = true
}
async function save() {
if (!form.value.category || !form.value.category.trim()) return message.error('分类不能为空')
if (!form.value.url || !form.value.url.trim()) return message.error('内网直链不能为空')
saving.value = true
try {
const { enabled, ...rest } = form.value
const body = { ...rest, category: form.value.category.trim(), url: form.value.url.trim(), enabled: true }
await adminFileSourceCreate(body)
message.success('已登记')
dlg.value = false
await refresh()
} catch (e) { message.error('保存失败:' + (e.message || e)) }
finally { saving.value = false }
}
async function toggle(row, v) {
row._tog = true
try { await adminFileSourcePatch(row.id, { enabled: v }); row.enabled = v; message.success(v ? '已启用' : '已停用') }
catch (e) { message.error('操作失败:' + (e.message || e)) }
finally { row._tog = false }
}
async function remove(row) {
try {
await ElMessageBox.confirm(`删除「${row.category} ${row.version}」的登记?此操作仅移除中心机登记,不影响内网文件。`, '确认删除', { type: 'warning' })
} catch (_) { return }
try {
await adminFileSourceDelete(row.id)
message.success('已删除')
await refresh()
} catch (e) { message.error('删除失败:' + (e.message || e)) }
}
async function copy(text, what) {
try { await navigator.clipboard.writeText(text); message.success(what + '已复制') }
catch (_) { message.error('复制失败,请手动选择') }
}
onMounted(refresh)
</script>
<style scoped>
.panel { padding: 22px 24px 26px; }
.head-actions { display: flex; gap: 10px; align-items: center; }
.form { display: flex; flex-direction: column; gap: 14px; }
.fitem { display: flex; flex-direction: column; gap: 6px; }
.fitem label { font-size: 13px; font-weight: 700; color: var(--cp-ink-1); }
.fitem .dim { font-weight: 500; font-size: 12px; }
.dim { color: var(--cp-ink-3); }
.url { font-size: 12px; }
.tip { font-size: 12px; color: var(--cp-ink-3); margin: 0; }
</style>