feat(controlplane): 完成多页面管理台重构与平台权限控制
1. 重构控制面前端为多页面路由架构,拆分出概览/插件/账号/权限管理页面 2. 引入Element Plus组件库优化UI样式与交互 3. 新增平台登录权限校验,支持按账号授权HR/OA平台访问 4. 新增平台登出接口与个人中心功能 5. 完善账号管理、插件授权相关API与UI交互 6. 新增防火墙、启停、自启动脚本与部署文档
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<LoginPage v-if="!store.current" :app-name="store.appName" @ok="onLogin" />
|
||||
<div class="__app" v-else>
|
||||
<header class="topbar panel">
|
||||
<el-container class="console" v-else>
|
||||
<el-header class="topbar" height="56px">
|
||||
<div class="brand">
|
||||
<span class="logo">37</span>
|
||||
<div class="brand-meta">
|
||||
@@ -10,60 +10,122 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="spacer"></div>
|
||||
<div class="acct">
|
||||
<span class="acct-name">{{ store.current }}</span>
|
||||
<em v-if="store.isAdmin" class="acct-tag">管理员</em>
|
||||
<button class="btn" @click="logout">登出</button>
|
||||
</div>
|
||||
</header>
|
||||
<el-dropdown trigger="click" @command="onCommand">
|
||||
<span class="acct">
|
||||
<el-icon><UserFilled /></el-icon>
|
||||
{{ store.current }}
|
||||
<el-tag v-if="store.isAdmin" size="small" type="primary" effect="light" round>管理员</el-tag>
|
||||
<el-icon class="caret"><ArrowDown /></el-icon>
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="pwd">修改密码</el-dropdown-item>
|
||||
<el-dropdown-item command="logout" divided>退出登录</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</el-header>
|
||||
|
||||
<main class="page panel">
|
||||
<ManagementView />
|
||||
</main>
|
||||
</div>
|
||||
<el-container class="body">
|
||||
<el-aside width="180px" class="aside">
|
||||
<el-menu :default-active="route" router class="menu" @select="onMenu">
|
||||
<el-menu-item index="#/overview">
|
||||
<el-icon><Odometer /></el-icon><span>概览</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="#/plugins">
|
||||
<el-icon><Box /></el-icon><span>插件管理</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="#/accounts">
|
||||
<el-icon><User /></el-icon><span>账号管理</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="#/grants">
|
||||
<el-icon><Key /></el-icon><span>权限授权</span>
|
||||
</el-menu-item>
|
||||
</el-menu>
|
||||
</el-aside>
|
||||
<el-main class="main">
|
||||
<component :is="viewComp" :key="route" />
|
||||
</el-main>
|
||||
</el-container>
|
||||
</el-container>
|
||||
|
||||
<PasswordDialog v-model="pwdOpen" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted } from 'vue'
|
||||
import ManagementView from './components/ManagementView.vue'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { UserFilled, ArrowDown, Odometer, Box, User, Key } from '@element-plus/icons-vue'
|
||||
import LoginPage from './components/LoginPage.vue'
|
||||
import { store } from './store'
|
||||
import PasswordDialog from './components/PasswordDialog.vue'
|
||||
import OverviewView from './views/OverviewView.vue'
|
||||
import PluginManageView from './views/PluginManageView.vue'
|
||||
import AccountManageView from './views/AccountManageView.vue'
|
||||
import GrantManageView from './views/GrantManageView.vue'
|
||||
import { store, clearSession } from './store'
|
||||
import { adminMe } from './api'
|
||||
|
||||
function onLogin() {
|
||||
// store 已在 LoginPage 写入
|
||||
// 轻量 hash 路由:StaticFiles(html=True) 下刷新安全,零后端改动
|
||||
const route = ref(location.hash && VIEWS[location.hash] ? location.hash : '#/overview')
|
||||
const VIEWS = {
|
||||
'#/overview': OverviewView,
|
||||
'#/plugins': PluginManageView,
|
||||
'#/accounts': AccountManageView,
|
||||
'#/grants': GrantManageView,
|
||||
}
|
||||
function logout() {
|
||||
store.current = ''
|
||||
store.isAdmin = false
|
||||
try { localStorage.removeItem('cp_account') } catch (_) {}
|
||||
window.addEventListener('hashchange', () => {
|
||||
if (VIEWS[location.hash]) route.value = location.hash
|
||||
})
|
||||
const viewComp = computed(() => VIEWS[route.value] || OverviewView)
|
||||
|
||||
function onMenu(index) {
|
||||
location.hash = index
|
||||
route.value = index
|
||||
}
|
||||
|
||||
const pwdOpen = ref(false)
|
||||
function onCommand(cmd) {
|
||||
if (cmd === 'pwd') pwdOpen.value = true
|
||||
else if (cmd === 'logout') {
|
||||
clearSession()
|
||||
ElMessage.success('已退出登录')
|
||||
}
|
||||
}
|
||||
|
||||
function onLogin() {
|
||||
route.value = '#/overview'
|
||||
location.hash = '#/overview'
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// 已本地标记登录时,校验仍为管理员(控制面重启/权限变更后回登录页)
|
||||
// 已本地标记登录时,校验登录票据仍有效且为管理员(票据过期/权限变更后回登录页)
|
||||
if (!store.current) return
|
||||
try {
|
||||
const me = await adminMe()
|
||||
if (!me.account || !me.is_admin) { store.current = ''; store.isAdmin = false }
|
||||
if (!me.account || !me.is_admin) clearSession()
|
||||
else store.isAdmin = true
|
||||
} catch (_) { /* 后端 down:保持本地态 */ }
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 18px; flex-shrink: 0; }
|
||||
.console { height: 100vh; background: #f5f7fa; }
|
||||
.topbar { display: flex; align-items: center; gap: 16px; background: #fff;
|
||||
border-bottom: 1px solid var(--el-border-color-light); }
|
||||
.brand { display: flex; align-items: center; gap: 11px; }
|
||||
.logo { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
|
||||
background: var(--primary-grad); color: #fff; font-size: 14px; font-weight: 800;
|
||||
box-shadow: 0 4px 12px -3px rgba(59,108,255,.6); }
|
||||
.brand-meta { display: flex; flex-direction: column; line-height: 1.2; }
|
||||
.brand-meta strong { font-size: 14px; }
|
||||
.brand-meta span { font-size: 11px; color: var(--text-faint); }
|
||||
.logo { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
|
||||
background: var(--el-color-primary); color: #fff; font-size: 13px; font-weight: 800; }
|
||||
.brand-meta { display: flex; flex-direction: column; line-height: 1.25; }
|
||||
.brand-meta strong { font-size: 14px; color: var(--el-text-color-primary); }
|
||||
.brand-meta span { font-size: 11px; color: var(--el-text-color-secondary); }
|
||||
.spacer { flex: 1; }
|
||||
.acct { display: flex; align-items: center; gap: 8px; }
|
||||
.acct-name { font-size: 13px; font-weight: 600; color: var(--text-sub); }
|
||||
.acct-tag { font-style: normal; font-size: 10px; color: var(--primary);
|
||||
border: 1px solid var(--primary-weak); background: var(--primary-weak); border-radius: 999px; padding: 1px 7px; }
|
||||
.btn { padding: 6px 14px; font-size: 12.5px; }
|
||||
.page { flex: 1; min-height: 0; padding: 20px 24px; overflow: auto; margin-top: 14px; }
|
||||
</style>
|
||||
.acct { display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
|
||||
color: var(--el-text-color-primary); cursor: pointer; outline: none; }
|
||||
.acct .caret { font-size: 12px; color: var(--el-text-color-secondary); }
|
||||
|
||||
.body { min-height: 0; }
|
||||
.aside { background: #fff; border-right: 1px solid var(--el-border-color-light); padding-top: 10px; }
|
||||
.menu { border-right: none; }
|
||||
.menu .el-menu-item { height: 44px; }
|
||||
.main { padding: 18px 20px; overflow: auto; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user