此提交实现完整的插件管理产品化闭环: 1. 中心机新增Ed25519密钥、审计/运行上报表、插件扩展字段,实现票据/管控清单签发、鉴权下载能力 2. 部署端新增设备级单活调度器、用户私有插件库、离线/联网校验链、插件下载安装流程 3. 控制面与部署前端同步更新UI与接口适配,新增审计页、插件管理增强功能 4. 修复两个工作流脚本的过滤与Excel导出问题,优化打包依赖与日志面板 5. 新增完整架构设计与实施文档
216 lines
7.6 KiB
Vue
216 lines
7.6 KiB
Vue
<template>
|
|
<n-config-provider :theme-overrides="themeOverrides" :locale="zhCN" :date-locale="dateZhCN">
|
|
<LoginPage v-if="!store.current" :app-name="store.appName" @ok="onLogin" />
|
|
<div class="console" v-else>
|
|
<header class="topbar">
|
|
<div class="brand">
|
|
<span class="logo">37</span>
|
|
<div class="brand-meta">
|
|
<strong>{{ store.appName }}</strong>
|
|
<span>中心机 · 控制面</span>
|
|
</div>
|
|
</div>
|
|
<div class="spacer"></div>
|
|
<n-dropdown trigger="click" :options="acctOptions" @select="onCommand">
|
|
<div class="acct">
|
|
<span class="avatar">{{ initial }}</span>
|
|
<span class="acct-name">{{ store.current }}</span>
|
|
<n-tag v-if="store.isAdmin" size="small" round :bordered="false" type="primary" class="admin-tag">管理员</n-tag>
|
|
<n-icon class="caret" :size="13"><ArrowDown /></n-icon>
|
|
</div>
|
|
</n-dropdown>
|
|
</header>
|
|
|
|
<div class="body">
|
|
<aside class="aside">
|
|
<div class="aside-inner">
|
|
<n-menu class="menu" :value="activeKey" :options="menuOptions" :root-indent="0" @update:value="onMenu" />
|
|
</div>
|
|
<div class="aside-foot">
|
|
<span>37du 自动化</span>
|
|
<span class="ver">v0.1.0</span>
|
|
</div>
|
|
</aside>
|
|
<main class="main">
|
|
<component :is="viewComp" :key="route" />
|
|
</main>
|
|
</div>
|
|
</div>
|
|
<PasswordDialog v-model="pwdOpen" />
|
|
</n-config-provider>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { computed, onMounted, ref } from 'vue'
|
|
import { ArrowDown } from '@element-plus/icons-vue'
|
|
import { themeOverrides, zhCN, dateZhCN, message } from './naive'
|
|
import LoginPage from './components/LoginPage.vue'
|
|
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 StatsView from './views/StatsView.vue'
|
|
import AuditView from './views/AuditView.vue'
|
|
import { store, clearSession } from './store'
|
|
import { adminMe } from './api'
|
|
|
|
const menuOptions = [
|
|
{ label: '概览', key: 'overview' },
|
|
{ label: '数据看板', key: 'stats' },
|
|
{ label: '插件管理', key: 'plugins' },
|
|
{ label: '账号管理', key: 'accounts' },
|
|
{ label: '权限授权', key: 'grants' },
|
|
{ label: '审计报表', key: 'audit' },
|
|
]
|
|
const acctOptions = [
|
|
{ label: '修改密码', key: 'pwd' },
|
|
{ type: 'divider', key: 'd1' },
|
|
{ label: '退出登录', key: 'logout' },
|
|
]
|
|
|
|
// 轻量 hash 路由:StaticFiles(html=True) 下刷新安全,零后端改动
|
|
const KEY = {
|
|
'#/overview': 'overview',
|
|
'#/stats': 'stats',
|
|
'#/plugins': 'plugins',
|
|
'#/accounts': 'accounts',
|
|
'#/grants': 'grants',
|
|
'#/audit': 'audit',
|
|
}
|
|
const VIEWS = {
|
|
'#/overview': OverviewView,
|
|
'#/stats': StatsView,
|
|
'#/plugins': PluginManageView,
|
|
'#/accounts': AccountManageView,
|
|
'#/grants': GrantManageView,
|
|
'#/audit': AuditView,
|
|
}
|
|
const route = ref(VIEWS[location.hash] ? location.hash : '#/overview')
|
|
window.addEventListener('hashchange', () => {
|
|
if (VIEWS[location.hash]) route.value = location.hash
|
|
})
|
|
const viewComp = computed(() => VIEWS[route.value] || OverviewView)
|
|
const activeKey = computed(() => KEY[route.value] || 'overview')
|
|
|
|
function onMenu(key) {
|
|
const h = '#/' + key
|
|
location.hash = h
|
|
route.value = h
|
|
}
|
|
|
|
const initial = computed(() => (store.current || '')[0]?.toUpperCase() || '?')
|
|
|
|
const pwdOpen = ref(false)
|
|
function onCommand(cmd) {
|
|
if (cmd === 'pwd') pwdOpen.value = true
|
|
else if (cmd === 'logout') {
|
|
clearSession()
|
|
message.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) clearSession()
|
|
else store.isAdmin = true
|
|
} catch (_) { /* 后端 down:保持本地态 */ }
|
|
})
|
|
</script>
|
|
|
|
<style scoped>
|
|
.console { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
|
|
|
|
/* ---------- 顶栏:磨砂玻璃 ---------- */
|
|
.topbar {
|
|
height: 64px; flex-shrink: 0;
|
|
display: flex; align-items: center; gap: 16px;
|
|
padding: 0 24px;
|
|
background: rgba(255, 255, 255, .72);
|
|
backdrop-filter: blur(16px);
|
|
-webkit-backdrop-filter: blur(16px);
|
|
border-bottom: 1px solid var(--cp-border);
|
|
position: relative; z-index: 20;
|
|
}
|
|
.topbar::after {
|
|
content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
|
|
background: linear-gradient(90deg, transparent, rgba(59, 108, 255, .35), rgba(34, 199, 232, .35), transparent);
|
|
}
|
|
.brand { display: flex; align-items: center; gap: 12px; }
|
|
.logo {
|
|
width: 38px; height: 38px; border-radius: 12px;
|
|
display: grid; place-items: center; position: relative;
|
|
background: linear-gradient(135deg, #3b6cff 0%, #22c7e8 130%);
|
|
color: #fff; font-size: 14px; font-weight: 800; letter-spacing: .5px;
|
|
box-shadow: 0 6px 16px -6px rgba(59, 108, 255, .6);
|
|
}
|
|
.logo::after { content: ''; position: absolute; inset: 2px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .28); }
|
|
.brand-meta { display: flex; flex-direction: column; line-height: 1.25; }
|
|
.brand-meta strong { font-size: 15px; color: var(--cp-ink); letter-spacing: .2px; }
|
|
.brand-meta span { font-size: 11px; color: var(--cp-ink-3); letter-spacing: .4px; }
|
|
.spacer { flex: 1; }
|
|
|
|
.acct {
|
|
display: flex; align-items: center; gap: 9px; cursor: pointer;
|
|
padding: 6px 10px; border-radius: 12px; transition: background .18s;
|
|
}
|
|
.acct:hover { background: rgba(59, 108, 255, .07); }
|
|
.avatar {
|
|
width: 30px; height: 30px; border-radius: 50%;
|
|
display: grid; place-items: center;
|
|
background: linear-gradient(135deg, #3b6cff, #22c7e8);
|
|
color: #fff; font-size: 13px; font-weight: 700;
|
|
}
|
|
.acct-name { font-size: 13px; font-weight: 600; color: var(--cp-ink); }
|
|
.admin-tag { margin-left: 2px; }
|
|
.caret { color: var(--cp-ink-3); }
|
|
|
|
/* ---------- 主体:悬浮侧栏 + 内容区 ---------- */
|
|
.body { flex: 1; display: flex; gap: 18px; padding: 18px 24px 24px; min-height: 0; }
|
|
.aside {
|
|
width: 208px; flex-shrink: 0;
|
|
display: flex; flex-direction: column;
|
|
background: rgba(255, 255, 255, .78);
|
|
backdrop-filter: blur(14px);
|
|
-webkit-backdrop-filter: blur(14px);
|
|
border: 1px solid var(--cp-border);
|
|
border-radius: 18px;
|
|
box-shadow: var(--cp-card-shadow);
|
|
padding: 14px 10px;
|
|
}
|
|
.aside-inner { flex: 1; }
|
|
.aside-foot {
|
|
display: flex; align-items: center; justify-content: space-between;
|
|
padding: 12px 12px 4px; margin-top: 8px;
|
|
border-top: 1px dashed var(--cp-border);
|
|
font-size: 11px; color: var(--cp-ink-3);
|
|
}
|
|
.main { flex: 1; min-width: 0; overflow: auto; padding: 4px 4px 8px; }
|
|
|
|
/* 页面切换过渡:轻微上浮淡入 */
|
|
.view-fade-enter-active { transition: opacity .22s ease, transform .22s ease; }
|
|
.view-fade-leave-active { transition: opacity .12s ease; }
|
|
.view-fade-enter-from { opacity: 0; transform: translateY(8px); }
|
|
.view-fade-leave-to { opacity: 0; }
|
|
|
|
/* ---------- 侧栏菜单:干净的标准导航,配色由 naive 主题统一控制 ---------- */
|
|
.menu { padding: 2px; }
|
|
.menu :deep(.n-menu-item) { margin-bottom: 4px; }
|
|
.menu :deep(.n-menu-item-content) {
|
|
/* 无图标时 naive 给 `padding-left:0` 的内联样式,需 !important 压过,
|
|
否则文字贴左边界、跑出圆角底色区域 */
|
|
padding-left: 16px !important;
|
|
padding-right: 16px !important;
|
|
border-radius: 10px;
|
|
box-sizing: border-box;
|
|
}
|
|
</style>
|