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 924f572a18
commit 863f818740
47 changed files with 38994 additions and 632 deletions
@@ -0,0 +1,229 @@
<template>
<div class="mask" @click.self="emit('close')">
<aside class="profile">
<header class="head">
<div class="avatar" aria-hidden="true">
<img v-if="store.avatarUrl && !avatarFailed" :src="store.avatarUrl" alt="" @error="onAvatarError">
<span v-else>{{ store.current.slice(0, 1).toUpperCase() }}</span>
</div>
<div class="meta">
<div class="name-line">
<strong>{{ store.current }}</strong>
<em v-if="store.isAdmin" class="tag">管理员</em>
</div>
<span class="dept">{{ store.dept || '未设置部门' }}</span>
</div>
<button class="close" title="关闭" @click="emit('close')">✕</button>
</header>
<div class="body">
<!-- 分节:平台登录态 -->
<div class="sec">
<div class="sec-title">平台登录态</div>
<div v-for="p in store.platforms" :key="p.id" class="prow">
<i class="dot" :class="{ on: p.online }"></i>
<span class="pname">{{ p.label }}</span>
<span class="pstat">{{ p.online ? '已登录' : '未登录' }}</span>
<button class="btn mini" :disabled="busy === p.id" @click="relogin(p.id)">
{{ busy === p.id ? '处理中…' : '重新登录' }}
</button>
<button class="btn mini" :disabled="busy === p.id || !p.online" @click="logout(p.id)">登出</button>
</div>
</div>
<!-- 分节:我的插件 -->
<div class="sec">
<div class="sec-title">我的插件</div>
<div v-if="store.plugins.length" class="plist">
<div v-for="p in store.plugins" :key="p.id" class="prow flat">
<span class="pname">{{ p.name }}</span>
<span class="ver">v{{ p.version }}</span>
</div>
</div>
<p v-else class="empty">当前账号暂无可用插件</p>
</div>
<!-- 分节:修改密码 -->
<div class="sec">
<div class="sec-title">修改密码</div>
<input class="input" v-model="oldPwd" type="password" placeholder="旧密码">
<input class="input" v-model="newPwd" type="password" placeholder="新密码">
<input class="input" v-model="againPwd" type="password" placeholder="确认新密码">
<button class="btn primary block" :disabled="pwdBusy" @click="changePwd">
{{ pwdBusy ? '提交中…' : '保存新密码' }}
</button>
<p v-if="pwdMsg" class="msg" :class="{ ok: pwdOk }">{{ pwdMsg }}</p>
</div>
</div>
<transition name="fade">
<div v-if="tipMsg" class="tip">{{ tipMsg }}</div>
</transition>
</aside>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { store, log, clearAvatarCache } from '../store'
import { loginPlatform, logoutPlatform, adminPassword } from '../api'
const emit = defineEmits(['close'])
// 头像:复用全局 store 的在线头像(带 localStorage 缓存);加载失败时清除缓存并回退首字符色块
const avatarFailed = ref(false)
function onAvatarError() {
avatarFailed.value = true
clearAvatarCache()
}
const busy = ref('')
// 面板内轻提示:已登录再点击等操作反馈
const tipMsg = ref('')
let tipTimer = null
function tip(m) {
tipMsg.value = m
if (tipTimer) clearTimeout(tipTimer)
tipTimer = setTimeout(() => (tipMsg.value = ''), 2000)
}
async function relogin(id) {
if (busy.value) return
const p = store.platforms.find((x) => x.id === id)
if (p?.online) {
tip(`${p.label} 已登录`)
return
}
busy.value = id
try {
const r = await loginPlatform(id)
if (p) {
p.online = !!r.online
log('INFO', `平台 ${p.label} 登录成功`)
}
} catch (e) {
log('ERROR', `平台 ${(store.platforms.find((x) => x.id === id) || {}).label || id} 登录失败:${e.message || e}`)
alert('登录失败:' + (e.message || e))
} finally {
busy.value = ''
}
}
async function logout(id) {
busy.value = id
try {
const r = await logoutPlatform(id)
const p = store.platforms.find((x) => x.id === id)
if (p) {
p.online = !!r.online
log('INFO', `平台 ${p.label} 已登出`)
}
} catch (e) {
log('ERROR', `平台 ${(store.platforms.find((x) => x.id === id) || {}).label || id} 登出失败:${e.message || e}`)
tip('登出失败:' + (e.message || e))
} finally {
busy.value = ''
}
}
const oldPwd = ref('')
const newPwd = ref('')
const againPwd = ref('')
const pwdBusy = ref(false)
const pwdMsg = ref('')
const pwdOk = ref(false)
async function changePwd() {
pwdMsg.value = ''
if (!oldPwd.value || !newPwd.value) return (pwdMsg.value = '请填写完整密码')
if (newPwd.value !== againPwd.value) return (pwdMsg.value = '两次新密码不一致')
pwdBusy.value = true
try {
await adminPassword({
account: store.current,
old_password: oldPwd.value,
new_password: newPwd.value,
})
pwdMsg.value = '密码已修改'
pwdOk.value = true
oldPwd.value = newPwd.value = againPwd.value = ''
setTimeout(() => emit('close'), 800)
} catch (e) {
pwdOk.value = false
pwdMsg.value = '修改失败:' + (e.message || e)
} finally {
pwdBusy.value = false
}
}
</script>
<style scoped>
.mask {
position: fixed; inset: 0; z-index: 50;
background: rgba(31, 38, 51, 0.35);
display: flex; justify-content: flex-end;
animation: fade .18s ease;
}
.tip {
position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
background: rgba(24, 39, 75, .92); color: #fff;
padding: 8px 18px; border-radius: 999px; font-size: 12.5px;
z-index: 5; box-shadow: 0 8px 24px -8px rgba(24, 39, 75, .4);
animation: fade .15s ease;
}
.profile {
width: 320px; height: 100%;
background: var(--surface);
display: flex; flex-direction: column;
box-shadow: -12px 0 34px -12px rgba(24, 39, 75, 0.3);
animation: slide .2s ease;
}
@keyframes slide { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.head {
display: flex; align-items: center; gap: 12px;
padding: 18px 20px 14px;
border-bottom: 1px solid var(--border);
}
.avatar {
width: 46px; height: 46px; border-radius: 50%;
position: relative; overflow: hidden; flex-shrink: 0;
display: grid; place-items: center;
color: #fff; font-size: 18px; font-weight: 700;
background: var(--primary-grad);
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.meta { flex: 1; min-width: 0; }
.name-line { display: flex; align-items: center; gap: 8px; }
.name-line strong { font-size: 15px; }
.tag { font-style: normal; font-size: 10px; color: var(--primary);
background: var(--primary-weak); border-radius: 999px; padding: 1px 8px; }
.dept { font-size: 11.5px; color: var(--text-faint); }
.close {
border: none; background: transparent; cursor: pointer;
color: var(--text-faint); font-size: 14px; padding: 6px; border-radius: 8px;
}
.close:hover { color: var(--text); background: var(--surface-2); }
.body { flex: 1; overflow: auto; padding: 4px 20px 20px; }
.sec { padding: 14px 0 4px; }
.sec + .sec { border-top: 1px dashed var(--border); margin-top: 6px; }
.sec-title {
font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
color: var(--text-faint); margin-bottom: 10px;
}
.prow { display: flex; align-items: center; gap: 8px; padding: 7px 0; }
.prow.flat { padding: 6px 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #c6ccdc; flex-shrink: 0; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(34, 176, 122, 0.18); }
.pname { flex: 1; color: var(--text-sub); font-size: 13px;
white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pstat { font-size: 11px; color: var(--text-faint); }
.ver { font-size: 11px; color: var(--text-faint); }
.plist { display: flex; flex-direction: column; }
.empty { color: var(--text-faint); font-size: 12px; margin: 4px 0; }
.btn.mini { padding: 3px 10px; font-size: 12px; }
.input { width: 100%; margin-bottom: 10px; }
.btn.block { width: 100%; margin-top: 2px; }
.msg { font-size: 12px; color: var(--err); margin: 8px 0 0; }
.msg.ok { color: var(--ok); }
</style>