feat: 新增控制面管理功能,优化插件加载与消息通知
- 新增内网插件控制面服务,实现统一账户、权限管理与插件分发 - 重构后端插件加载逻辑,支持按账号动态权限白名单加载 - 优化XQ0001排班异常提醒文案与推送群配置 - 新增前端管理界面与登录态会话管理 - 新增插件上传、账号管理等后台管理接口
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div class="__app">
|
||||
<!-- 顶部:品牌 + 平台登录态 + 进度 -->
|
||||
<LoginPage v-if="!store.current" :app-name="store.appName" @ok="onLogin" />
|
||||
<div class="__app" v-else>
|
||||
<!-- 顶部:品牌 + 平台登录态 + 当前账号/登出 + 进度 -->
|
||||
<header class="topbar panel">
|
||||
<div class="brand">
|
||||
<span class="logo">37</span>
|
||||
@@ -34,6 +35,12 @@
|
||||
<span v-if="store.running" class="run-label">{{ store.progress }}%</span>
|
||||
<div v-show="store.running" class="progress"><div :style="{ width: store.progress + '%' }"></div></div>
|
||||
</div>
|
||||
|
||||
<div class="acct">
|
||||
<span class="acct-name">{{ store.current }}</span>
|
||||
<em v-if="store.isAdmin" class="acct-tag">管理员</em>
|
||||
<button class="chip" @click="logout">登出</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- 主体:左场景 | 右插件页 + 日志 -->
|
||||
@@ -47,8 +54,8 @@
|
||||
<li
|
||||
v-for="(p, i) in store.plugins"
|
||||
:key="p.id"
|
||||
:class="{ active: p.id === store.selectedId }"
|
||||
@click="store.selectedId = p.id"
|
||||
:class="{ active: p.id === store.selectedId && store.view === 'plugin' }"
|
||||
@click="openPlugin(p.id)"
|
||||
>
|
||||
<span class="scene-icon" :style="{ background: PALETTE[i % PALETTE.length] }">
|
||||
{{ p.name.slice(0, 1) }}
|
||||
@@ -56,13 +63,22 @@
|
||||
<span class="scene-name">{{ p.name }}</span>
|
||||
<em>v{{ p.version }}</em>
|
||||
</li>
|
||||
<li
|
||||
class="admin-entry"
|
||||
:class="{ active: store.view === 'admin' }"
|
||||
@click="store.view = 'admin'"
|
||||
>
|
||||
<span class="scene-icon" style="background: #3b3f4a">⚙</span>
|
||||
<span class="scene-name">控制面管理</span>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="side-foot">场景以插件方式接入</div>
|
||||
</aside>
|
||||
|
||||
<main class="main">
|
||||
<div class="page-scroll panel">
|
||||
<PluginPage />
|
||||
<PluginPage v-if="store.view === 'plugin'" />
|
||||
<ManagementView v-else-if="store.view === 'admin'" />
|
||||
</div>
|
||||
<LogPanel />
|
||||
</main>
|
||||
@@ -74,14 +90,21 @@
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import PluginPage from './components/PluginPage.vue'
|
||||
import LogPanel from './components/LogPanel.vue'
|
||||
import ManagementView from './components/ManagementView.vue'
|
||||
import LoginPage from './components/LoginPage.vue'
|
||||
import { store, handleEvent, clearLogs } from './store'
|
||||
import { connectWS, fetchMeta, loginPlatform } from './api'
|
||||
import { connectWS, fetchMeta, loginPlatform, adminLogout } from './api'
|
||||
|
||||
const PALETTE = ['#3b6cff', '#7c5cff', '#12a4d8', '#22b07a', '#e88a3a', '#e5484d']
|
||||
|
||||
const wsText = computed(() =>
|
||||
store.wsOn ? '服务已连接' : '连接中断,正在重连…')
|
||||
|
||||
function openPlugin(id) {
|
||||
store.selectedId = id
|
||||
store.view = 'plugin'
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
const meta = await fetchMeta()
|
||||
store.appName = meta.appName
|
||||
@@ -94,10 +117,34 @@ onMounted(async () => {
|
||||
window.__ws = ws
|
||||
ws.onopen = () => (store.wsOn = true)
|
||||
ws.onclose = () => { store.wsOn = false; setTimeout(() => (location.reload()), 2500) }
|
||||
checkSession()
|
||||
})
|
||||
|
||||
const busyLogin = ref('')
|
||||
|
||||
async function checkSession() {
|
||||
// 已在本地标记登录:与后端会话 cookie 是否一致(后端重启会失效,此时回登录页)
|
||||
if (!store.current) return
|
||||
try {
|
||||
const me = await fetch('/api/admin/me').then((r) => r.json())
|
||||
if (!me.account) { store.current = ''; store.isAdmin = false }
|
||||
else store.isAdmin = !!me.is_admin
|
||||
} catch (_) { /* 后端 down:暂保持本地态 */
|
||||
}
|
||||
}
|
||||
|
||||
function onLogin(ok) {
|
||||
store.current = ok.account
|
||||
store.isAdmin = !!ok.is_admin
|
||||
try { localStorage.setItem('cp_account', ok.account) } catch (_) {}
|
||||
}
|
||||
async function logout() {
|
||||
try { await adminLogout() } catch (_) {}
|
||||
store.current = ''
|
||||
store.isAdmin = false
|
||||
try { localStorage.removeItem('cp_account') } catch (_) {}
|
||||
}
|
||||
|
||||
async function login(id) {
|
||||
if (busyLogin.value) return
|
||||
busyLogin.value = id
|
||||
@@ -152,6 +199,11 @@ async function login(id) {
|
||||
.run-state { display: flex; align-items: center; gap: 10px; }
|
||||
.run-label { font-size: 12px; color: var(--primary); font-weight: 600; min-width: 38px; text-align: right; }
|
||||
|
||||
.acct { display: flex; align-items: center; gap: 8px; margin-left: 12px; }
|
||||
.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; }
|
||||
|
||||
.body { flex: 1; display: flex; gap: 14px; min-height: 0; margin-top: 14px; }
|
||||
|
||||
.side { width: 232px; flex-shrink: 0; display: flex; flex-direction: column; padding: 14px 12px; }
|
||||
@@ -172,6 +224,8 @@ async function login(id) {
|
||||
}
|
||||
.scene-name { flex: 1; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.scene-list li.active .scene-name { color: var(--primary); }
|
||||
.scene-list li.admin-entry { border-top: 1px dashed var(--border); margin-top: 6px; border-radius: 0; }
|
||||
.scene-list li.admin-entry.active .scene-name { color: var(--primary); font-weight: 600; }
|
||||
.scene-list em { font-style: normal; font-size: 10px; color: var(--text-faint); }
|
||||
.side-foot { font-size: 10px; color: var(--text-faint); text-align: center; padding-top: 10px; border-top: 1px dashed var(--border); margin-top: 8px; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user