feat(controlplane): 完成多页面管理台重构与平台权限控制

1. 重构控制面前端为多页面路由架构,拆分出概览/插件/账号/权限管理页面
2. 引入Element Plus组件库优化UI样式与交互
3. 新增平台登录权限校验,支持按账号授权HR/OA平台访问
4. 新增平台登出接口与个人中心功能
5. 完善账号管理、插件授权相关API与UI交互
6. 新增防火墙、启停、自启动脚本与部署文档
This commit is contained in:
2026-09-10 15:03:21 +08:00
parent c00c4423f0
commit 42c7cf24f2
47 changed files with 38994 additions and 632 deletions
@@ -0,0 +1,137 @@
<template>
<div>
<div class="page-head">
<div>
<h3>权限授权</h3>
<p>按账号勾选可用插件与可登录平台,保存时仅提交差异项</p>
</div>
<el-button :icon="Refresh" :loading="overviewBusy" @click="refresh">刷新</el-button>
</div>
<el-card shadow="never" class="block">
<el-form inline>
<el-form-item label="选择账号">
<el-select v-model="account" placeholder="选择账号…" style="width: 240px" filterable>
<el-option v-for="a in accounts" :key="a.account" :value="a.account"
:label="a.dept ? `${a.account} · ${a.dept}` : a.account" />
</el-select>
</el-form-item>
<el-form-item v-if="account">
<el-text type="info" size="small">
{{ account }} · 已授权 {{ checked.length }} 个插件 / {{ platChecked.length }} 个平台
</el-text>
</el-form-item>
</el-form>
</el-card>
<template v-if="account">
<el-card shadow="never" class="block">
<template #header>
<div class="card-head"><b>插件授权</b>
<el-button type="primary" size="small" :loading="saving" @click="saveGrant">保存插件授权</el-button>
</div>
</template>
<el-checkbox-group v-model="checked" v-if="plugins.length">
<el-checkbox v-for="p in plugins" :key="p.id" :value="p.id" class="ck">
{{ p.id }}<span class="dim">({{ p.name }})</span>
</el-checkbox>
</el-checkbox-group>
<el-empty description="暂无插件,请先在「插件管理」上传" :image-size="60" v-else />
</el-card>
<el-card shadow="never" class="block">
<template #header>
<div class="card-head"><b>平台授权</b>
<el-button type="primary" size="small" :loading="savingPlat" @click="savePlat">保存平台授权</el-button>
</div>
</template>
<el-checkbox-group v-model="platChecked">
<el-checkbox v-for="pf in PLATFORM_OPTS" :key="pf.id" :value="pf.id" class="ck">
{{ pf.label }}<span class="dim">({{ pf.id }})</span>
</el-checkbox>
</el-checkbox-group>
</el-card>
</template>
<el-empty v-else description="先在上方选择一个账号" :image-size="90" />
</div>
</template>
<script setup>
import { computed, onMounted, ref, watch } from 'vue'
import { Refresh } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import { overview, overviewBusy, loadOverview } from '../store'
import { adminGrant, adminPlatformGrant } from '../api'
const PLATFORM_OPTS = [
{ id: 'hr', label: 'HR 系统' },
{ id: 'oa', label: 'OA 系统' },
]
const plugins = computed(() => overview.value?.plugins || [])
const accounts = computed(() => overview.value?.accounts || [])
const account = ref('')
const checked = ref([])
const platChecked = ref([])
const saving = ref(false)
const savingPlat = ref(false)
let heldPlugins = new Set()
let heldPlatforms = new Set()
// 选中账号即自动载入其现有授权
watch(account, (acc) => {
const a = accounts.value.find(x => x.account === acc)
heldPlugins = new Set(a?.plugins || [])
heldPlatforms = new Set(a?.platforms || [])
checked.value = [...heldPlugins]
platChecked.value = [...heldPlatforms]
})
async function refresh() {
try { await loadOverview(true) } catch (e) { ElMessage.error('读取失败:' + (e.message || e)) }
}
async function saveGrant() {
const acc = account.value; if (!acc) return
const want = new Set(checked.value)
let n = 0
saving.value = true
for (const pid of new Set([...want, ...heldPlugins])) {
const g = want.has(pid)
if (g === heldPlugins.has(pid)) continue
try { await adminGrant({ account: acc, plugin_id: pid, granted: g }); n++ }
catch (e) { ElMessage.error(e.message || e) }
}
heldPlugins = want
saving.value = false
await refresh()
ElMessage.success(n ? `已更新 ${n} 项插件授权` : '插件授权无需变更')
}
async function savePlat() {
const acc = account.value; if (!acc) return
const want = new Set(platChecked.value)
let n = 0
savingPlat.value = true
for (const pf of new Set([...want, ...heldPlatforms])) {
const g = want.has(pf)
if (g === heldPlatforms.has(pf)) continue
try { await adminPlatformGrant({ account: acc, platform_id: pf, granted: g }); n++ }
catch (e) { ElMessage.error(e.message || e) }
}
heldPlatforms = want
savingPlat.value = false
await refresh()
ElMessage.success(n ? `已更新 ${n} 项平台授权` : '平台授权无需变更')
}
onMounted(refresh)
</script>
<style scoped>
.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.page-head h3 { margin: 0 0 4px; font-size: 17px; }
.page-head p { margin: 0; font-size: 12px; color: var(--el-text-color-secondary); }
.block { margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.ck { margin-right: 18px; }
.dim { color: var(--el-text-color-secondary); font-size: 12px; margin-left: 2px; }
</style>