feat: 实现v3版本的中心机与部署壳拆分登录架构

此提交完成了核心架构改造:
1. 新增钉钉直连接登录链路,使用浏览器本地跳转而非云端中转
2. 实现壳本机会话持久化,重启后不丢失登录态
3. 重构后端API鉴权,支持Bearer Token身份验证
4. 重写ProfilePanel与LoginPage页面样式与交互逻辑
5. 新增文档说明完整的拆分重构方案

主要变更包括:
- 新增/auth/exchange、/api/auth/dingtalk等登录相关接口
- 重构plugins/allowed_platforms接口支持新鉴权方式
- 实现云端会话token管理与本地会话落盘
- 替换旧登录页为分屏设计,支持钉钉扫码直连登录
This commit is contained in:
2026-09-13 21:31:28 +08:00
parent 9f6deaae76
commit 6f248b0741
10 changed files with 1022 additions and 231 deletions
+1
View File
@@ -0,0 +1 @@
{"5b5b138d2d5344ce87bde69ac17a2cb2": ["37036361", 1789294401], "2d53d67eb6e04d5eb564af487c7c437c": ["37036361", 1789294411], "d84bae0c4bd543a79924ea033adfb19a": ["37036361", 1789294893], "0a904b0be8e04ecab1aa3bb9ae15c005": ["37036361", 1789294591], "1879d5b380914d30925433a44f2a6d26": ["37036361", 1789294957], "be2581e6fa394f55986b9b556b3d2d0d": ["37036361", 1789295036]}
+151 -15
View File
@@ -14,6 +14,7 @@ import logging
import os
import socket
import subprocess
import secrets
import sys
import threading
import time
@@ -25,7 +26,7 @@ from pathlib import Path
from fastapi import FastAPI, HTTPException, Request, Response, WebSocket
from pydantic import BaseModel
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import HTMLResponse
from fastapi.responses import HTMLResponse, RedirectResponse
from fastapi.staticfiles import StaticFiles
from urllib.parse import urlencode
@@ -75,24 +76,59 @@ DINGTALK_APP_KEY = os.getenv("DINGTALK_APP_KEY", "") or os.getenv("DINGTALK_APPK
# 统一账户体系为真源:登录态由后端 cookie 会话维护(账号在统一后端 accounts 表)。
# cookie 会话:token -> (account, 活跃时间戳);登录后 set-cookie,进程内保持,供代理转发账号。
SESSION_COOKIE = "cp_session"
_SESS_TTL = 24 * 3600 # 会话空闲有效期 24h(惰性过期,防长期运行无限累积)
# 会话空闲有效期:7 天滑动续期(每次有效请求刷新 TTL;天天用永不重登,超期需重登)
_SESS_TTL = 7 * 24 * 3600
_SESS: dict[str, tuple] = {}
_SESS_LOCK = threading.Lock()
# 本机会话落盘文件:重启后端不丢会话(兑现"双击壳直接进插件页、不必每次重登")
_SESS_FILE = Path(__file__).resolve().parents[1] / "_cp_sessions.json"
def _sess_persist():
"""把本机会话快照落盘为首存(token → [account, 最近活跃ts]),进程重启后仍有效。"""
try:
with _SESS_LOCK:
_payload = {t: [a, int(_ts)] for t, (a, _ts) in _SESS.items()}
_SESS_FILE.write_text(json.dumps(_payload, ensure_ascii=False), encoding="utf-8")
except OSError as _exc: # noqa: BLE001
_LOGGER.warning("本机会话持久化失败: %s", _exc)
def _sess_load():
"""启动时从磁盘恢复本机会话(惰性丢弃已过期条)。"""
if not _SESS_FILE.is_file():
return
try:
_raw = json.loads(_SESS_FILE.read_text(encoding="utf-8"))
except (OSError, ValueError):
return
_now = time.time()
with _SESS_LOCK:
for _t, _it in (_raw or {}).items():
try:
_a, _ts = _it[0], float(_it[1])
except (KeyError, IndexError, TypeError, ValueError):
continue
if _now - _ts <= _SESS_TTL:
_SESS[_t] = (_a, _ts)
def _sess_account(request) -> str:
"""从请求 cookie 会话解析当前登录账号;未登录/过期返回空串(过期顺手清理)。"""
"""从请求 cookie 会话解析当前登录账号;未登录/过期返回空串(过期顺手清理并落盘)。"""
token = request.cookies.get(SESSION_COOKIE, "")
account = ""
with _SESS_LOCK:
item = _SESS.get(token)
if not item:
return ""
account, ts = item
if time.time() - ts > _SESS_TTL:
_SESS.pop(token, None)
return ""
_SESS[token] = (account, time.time()) # 滑动续期
return account
if item:
_account, _ts = item
if time.time() - _ts <= _SESS_TTL:
_SESS[token] = (_account, time.time()) # 滑动续期
account = _account
else:
_SESS.pop(token, None)
if account:
_sess_persist() # 滑动续期也落盘,重启后仍有效
return account
def _require_login(request: Request) -> str:
@@ -103,6 +139,9 @@ def _require_login(request: Request) -> str:
return account
_sess_load() # 启动即恢复本机会话(重启后端不丢会话)
# 平台登录态:标签/展示名来自 auth,在线状态实时校验(非内存假状态)
PLATFORMS: dict = {p["id"]: {"id": p["id"], "label": p["label"]}
for p in platform_auth.platforms()}
@@ -240,14 +279,22 @@ app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_methods=["*"], all
@app.get("/api/admin/me")
def admin_me(request: Request) -> dict:
"""当前登录账号是否为管理员(会话 cookie)。统一后端不可达时视为非管理员。"""
"""当前登录账号是否管理员(会话 cookie)。
账号一律以**壳本机会话**为准(登录即有效);is_admin/部门 尽量从云端补齐,
云端未授信 X-Admin-User(未配 CONTROLPLANE_TOKEN)或不可达时,仅降级 is_admin=False,
不影响员工正常进入插件页(前端以 account 非空判登录)。
"""
account = _sess_account(request)
if not account:
return {"account": "", "is_admin": False}
return {"account": "", "is_admin": False, "dept": "", "nickname": ""}
try:
return _cp_call("GET", "/api/admin/me", headers=_cp_headers(request))
r = _cp_call("GET", "/api/admin/me", headers=_cp_headers(request))
if r.get("account") == account:
return r
except HTTPException:
return {"account": account, "is_admin": False}
pass
return {"account": account, "is_admin": False, "dept": "", "nickname": ""}
class _LoginIn(BaseModel):
@@ -271,6 +318,7 @@ def admin_login(b: _LoginIn, response: Response) -> dict:
token = uuid.uuid4().hex
with _SESS_LOCK:
_SESS[token] = (b.account.strip(), time.time())
_sess_persist()
response.set_cookie(SESSION_COOKIE, token, httponly=True, samesite="lax")
# 登录成功即联网同步该账号的离线授权票据 + 管控清单 + 中心机公钥(供离线运行)
if CONTROLPLANE_URL:
@@ -308,6 +356,7 @@ def _dingtalk_establish(account: str, nickname: str, dingtalk_uid: str, response
token = uuid.uuid4().hex
with _SESS_LOCK:
_SESS[token] = (acct, time.time())
_sess_persist()
response.set_cookie(SESSION_COOKIE, token, httponly=True, samesite="lax")
if CONTROLPLANE_URL:
try:
@@ -355,6 +404,92 @@ def admin_dingtalk_inline_qr(request: Request) -> dict:
headers=({"X-API-Token": CONTROLPLANE_TOKEN} if CONTROLPLANE_TOKEN else {}))
# ==================== v3 钉钉直连接登录:/api/auth/dingtalk + /auth/done(§2.1,待 §0 验证后实测) ====================
# 浏览器跳转模型:壳生成 state → 打开钉钉授权URL(redirect_uri=http://localhost:8799/auth/done)
# → 用户本机浏览器带回 code+state → 壳校验 state → POST 云端 /auth/exchange{code} 换工号+云端token → 建本机会话。
# 云端只参与换 token,AppSecret 不出云端;会话存本机、重启不掉(见上方 _SESS 持久化)。
_LOGIN_STATE_TTL = 5 * 60 # state 有效期(秒)
_LOGIN_STATES: dict[str, float] = {} # state -> expiry(待回跳校验)
_LOGIN_LOCK = threading.Lock()
# account -> 最近云端会话 token(7 天,供壳后续调 /api/plugins 用 Bearer,见 §2.2)
_ACCT_CLOUD_TOKEN: dict[str, str] = {}
def _login_state_new() -> str:
with _LOGIN_LOCK:
_now = time.time()
for s in [s for s, e in _LOGIN_STATES.items() if e < _now]:
_LOGIN_STATES.pop(s, None)
state = secrets.token_urlsafe(24)
_LOGIN_STATES[state] = _now + _LOGIN_STATE_TTL
return state
def _login_state_take(state: str) -> bool:
with _LOGIN_LOCK:
exp = _LOGIN_STATES.pop(state, None)
return bool(exp and exp >= time.time())
def _auth_done_page(text: str) -> HTMLResponse:
return HTMLResponse(f"""<!doctype html><html><head><meta charset="utf-8"><title>登录</title></head>
<body style="font-family:sans-serif;text-align:center;padding:60px">
<p>{text}</p><p><a href="/">返回</a></p></body></html>""")
@app.get("/api/auth/dingtalk")
def auth_dingtalk_url() -> dict:
"""生成并返回钉钉扫码授权 URL(redirect_uri=本机 /auth/done)。前端「钉钉登录」当前窗口跳转该 URL。"""
if not DINGTALK_APP_KEY:
raise HTTPException(503, "未配置钉钉开放平台应用(DINGTALK_APP_KEY)")
if not CONTROLPLANE_URL:
raise HTTPException(503, "未配置中心机地址(CONTROLPLANE_URL)")
state = _login_state_new()
redirect_uri = f"http://localhost:{PORT}/auth/done"
login_url = "https://login.dingtalk.com/oauth2/challenge.htm?" + urlencode({
"redirect_uri": redirect_uri,
"response_type": "code",
"client_id": DINGTALK_APP_KEY,
"scope": "openid",
"prompt": "consent",
"state": state})
return {"url": login_url, "state": state}
@app.get("/auth/done")
def auth_done(code: str = "", state: str = "", error: str = "") -> Response:
"""钉钉回跳落点(浏览器):收 code+state → 校验 state → 云端 /auth/exchange 换工号 → 建本机会话。
成功后写会话 cookie 并 302 回主页;任何失败给 HTML 提示,不建立会话。
"""
if error:
return _auth_done_page("钉钉登录被取消或失败,请返回重试。")
if not (code and state) or not _login_state_take(state):
return _auth_done_page("登录状态无效或已过期,请返回重新扫码。")
try:
info = _cp_call("POST", "/auth/exchange", json={"code": code})
except HTTPException as e:
return _auth_done_page(f"登录失败:{e.detail}")
account = (info.get("account") or "").strip()
if not account or not info.get("exists"):
return _auth_done_page("账号未开通或未解析到有效工号,请联系管理员。")
# 建本机会话(写内存+落盘+set-cookie),并存云端 token 供后续调云端 API(§2.2)。
_token = uuid.uuid4().hex
with _SESS_LOCK:
_SESS[_token] = (account, time.time())
_sess_persist()
if info.get("token"):
_ACCT_CLOUD_TOKEN[account] = info["token"]
resp = RedirectResponse("/")
resp.set_cookie(SESSION_COOKIE, _token, httponly=True, samesite="lax")
if CONTROLPLANE_URL:
try:
_sync_licensing(account)
except Exception as _exc: # noqa: BLE001 同步失败不影响登录
_LOGGER.warning("登录后同步离线授权票据失败:%s", _exc)
return resp
# ==================== 钉钉真实扫码:扫码URL + 静默回调页 ====================
# 扫码 URL 指向中心机 /api/admin/dingtalk/scan(back 回跳到本机 /cb);
# 扫码成功 → 中心机 /cb 302 回本机 /cb?account=&nickname= → 本页静默调 dingtalk/login 建会话
@@ -407,6 +542,7 @@ def admin_logout(request: Request, response: Response) -> dict:
token = request.cookies.get(SESSION_COOKIE, "")
with _SESS_LOCK:
_SESS.pop(token, None)
_sess_persist()
response.delete_cookie(SESSION_COOKIE)
return {"ok": True}
+14 -10
View File
@@ -174,19 +174,23 @@ function showToast(msg, type = 'info') {
}
async function checkSession() {
// 已在本地标记登录:与后端会话 cookie 是否一致(后端重启会失效,此时回登录页)
if (!store.current) return
// 登录态一律以**后端会话 cookie** 为准(钉钉扫码/账号登录/后端重启后均从 admin/me 判定),
// 不再以 localStorage 的 cp_account 早退——否则全新扫码流程(未写过 cp_account)回跳后无法进入插件页。
try {
const me = await adminMe()
if (!me.account) { store.current = ''; store.isAdmin = false; store.dept = ''; store.nickname = '' }
else {
store.isAdmin = !!me.is_admin
store.dept = me.dept || ''
store.nickname = me.nickname || ''
// 会话有效:补拉插件清单(未登录时 meta 不返回插件)
await refreshMeta()
if (!me.account) {
store.current = ''; store.isAdmin = false; store.dept = ''; store.nickname = ''
try { localStorage.removeItem('cp_account') } catch (_) {}
return
}
} catch (_) { /* 后端 down:暂保持本地态 */ }
store.current = me.account
store.isAdmin = !!me.is_admin
store.dept = me.dept || ''
store.nickname = me.nickname || ''
try { localStorage.setItem('cp_account', me.account) } catch (_) {}
// 会话有效:补拉插件清单(未登录时 meta 不返回插件)
await refreshMeta()
} catch (_) { /* 后端 down:无法校验,保持现状(可能为登录页或本地态) */ }
}
async function refreshMeta() {
+4
View File
@@ -56,6 +56,10 @@ export async function adminDingtalkLogin(account, nickname, dingtalk_uid = '') {
export async function adminDingtalkQr() {
return j('/api/admin/dingtalk/qr')
}
// v3 钉钉直连接登录:生成钉钉授权 URL(redirect_uri=本机 /auth/done),前端当前窗口跳转到该 URL
export async function authDingtalk() {
return j('/api/auth/dingtalk')
}
// 内嵌二维码(DDLogin):拿 goto 参数 + 用 loginTmpCode 登录
export async function adminDingtalkInlineQr() {
return j('/api/admin/dingtalk/inline_qr')
+278 -144
View File
@@ -1,57 +1,78 @@
<template>
<div class="login">
<i class="blob b1"></i>
<i class="blob b2"></i>
<i class="blob b3"></i>
<div class="card">
<div class="brand">
<span class="logo">37</span>
<div class="brand-meta">
<strong>{{ appName || '37du 业务场景工具集' }}</strong>
<span>统一账户登录</span>
<div class="stage">
<!-- 左:品牌叙事面板 -->
<aside class="panel">
<div class="panel-top">
<span class="mark">37</span>
<span class="word">{{ appName || '业务场景工具集' }}</span>
<span class="mono panel-code">{{ code }}</span>
</div>
</div>
<el-form label-position="top" @submit.prevent="doLogin">
<el-form-item label="账号">
<el-input
v-model="account"
placeholder="账号"
autocomplete="username"
size="large"
:prefix-icon="User"
clearable
@keyup.enter="doLogin"
/>
</el-form-item>
<el-form-item label="密码">
<el-input
v-model="password"
type="password"
placeholder="密码"
autocomplete="current-password"
size="large"
:prefix-icon="Lock"
show-password
@keyup.enter="doLogin"
/>
</el-form-item>
<el-button type="primary" size="large" class="primary" :loading="busy" @click="doLogin">
{{ busy ? '校验中…' : '登 录' }}
</el-button>
</el-form>
<div class="panel-mid">
<h1 class="headline">一处登录,<br />驱动所有业务场景。</h1>
<p class="slogan">考勤 · 审批 · 数据导出 · 定时任务<br />装好即用,扫码即入。</p>
<div class="divider"><span>或使用钉钉登录</span></div>
<el-button size="large" class="dingtalk" :loading="dingBusy" :icon="ChatDotRound" @click="openDing">钉钉扫码登录</el-button>
<!-- 内嵌二维码:本页内渲染钉钉二维码,扫码即登录(不弹浏览器) -->
<div v-if="inlineOpen" class="inline-qr">
<div ref="qrBoxEl" class="qr-box"><div id="ding_qr_container"></div></div>
<p class="ding-tip">用钉钉 App 扫码,自动登录 / 自动建号(新账号首次登录请改密)</p>
<div class="qr-actions">
<el-link type="primary" :underline="false" @click="openDingWindow">改用浏览器窗口授权</el-link>
<div class="nodes">
<div v-for="(n, i) in nodes" :key="n.label" class="node" :class="{ act: n.act }">
<span class="n-idx mono">0{{ i + 1 }}</span>
<span class="n-txt">{{ n.label }}</span>
<i class="n-dot"></i>
</div>
</div>
</div>
</div>
<div class="panel-foot mono">{{ foot }}</div>
</aside>
<!-- 右:认证面板 -->
<section class="auth">
<div class="auth-head">
<span class="mono auth-index">AUTH / 01</span>
<h2 class="auth-title">欢迎回来</h2>
<p class="auth-sub">使用统一账号或钉钉扫码登录</p>
</div>
<el-form label-position="top" @submit.prevent="doLogin">
<el-form-item label="账号">
<el-input
v-model="account"
placeholder="账号"
autocomplete="username"
size="large"
:prefix-icon="User"
clearable
@keyup.enter="doLogin"
/>
</el-form-item>
<el-form-item label="密码">
<el-input
v-model="password"
type="password"
placeholder="密码"
autocomplete="current-password"
size="large"
:prefix-icon="Lock"
show-password
@keyup.enter="doLogin"
/>
</el-form-item>
<el-button type="primary" size="large" class="primary" :loading="busy" @click="doLogin">
{{ busy ? '校验中…' : '登 录' }}
</el-button>
</el-form>
<div class="divider"><span>或使用钉钉登录</span></div>
<el-button size="large" class="dingtalk" :loading="dingBusy" :icon="ChatDotRound" @click="openDing">钉钉扫码登录</el-button>
<!-- 内嵌二维码:本页内渲染钉钉二维码,扫码即登录(不弹浏览器) -->
<div v-if="inlineOpen" class="inline-qr">
<div ref="qrBoxEl" class="qr-box"><div id="ding_qr_container"></div></div>
<p class="ding-tip">用钉钉 App 扫码,自动登录 / 自动建号(新账号首次登录请改密)</p>
<div class="qr-actions">
<el-link type="primary" :underline="false" @click="openDingWindow">改用浏览器窗口授权</el-link>
</div>
</div>
</section>
</div>
<!-- 真实钉钉扫码(配置了开放平台应用时 window.open 扫码页;否则回落到工号录入) -->
@@ -77,7 +98,7 @@
import { ref, onMounted, onUnmounted, nextTick } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { User, Lock, ChatDotRound } from '@element-plus/icons-vue'
import { adminLogin, adminDingtalkLogin, adminDingtalkQr, adminPassword, adminDingtalkInlineQr, adminDingtalkInlineLogin } from '../api'
import { adminLogin, adminDingtalkLogin, adminDingtalkQr, adminPassword, adminDingtalkInlineQr, adminDingtalkInlineLogin, authDingtalk } from '../api'
const props = defineProps({ appName: { type: String, default: '' } })
const emit = defineEmits(['ok'])
@@ -96,6 +117,16 @@ const qrBoxEl = ref(null)
const dingGoto = ref('')
let ddMsgHandler = null
/* ---------- 蓝本展示数据(纯装饰,无逻辑) ---------- */
const nodes = [
{ label: '统一身份与权限', act: true },
{ label: '插件仓库与更新', act: true },
{ label: '执行调度与日志' },
{ label: '离线兜底运行' },
]
const code = 'v0.31.0'
const foot = '37DU AUTOMATION · SERVICE SHELL · 2026'
onMounted(async () => {
try { const r = await adminDingtalkQr(); dingUrl.value = r.url || '' } catch (_) {}
})
@@ -116,18 +147,22 @@ async function doLogin() {
}
async function openDing() {
// 优先内嵌二维码:本页内渲染钉钉二维码,扫码即登录;失败则回落浏览器窗口授权 / 工号录入。
if (dingBusy.value) return
dingBusy.value = true
// v3 钉钉直连接登录:壳后端生成授权 URL(redirect_uri=本机 /auth/done),当前窗口跳转钉钉。
try {
const r = await adminDingtalkInlineQr()
if (r && r.goto) {
dingGoto.value = r.goto
inlineOpen.value = true
await nextTick()
loadDdLogin()
const r = await authDingtalk()
if (r && r.url) {
window.location.href = r.url // 当前窗口跳转;扫码后浏览器跳回 /auth/done → 云端换身份 → 回主页
return
}
} catch (_) { /* 中心机未配置钉钉应用或无中心机时走回退 */ }
openDingWindow()
} catch (e) {
ElMessage.error('钉钉登录不可用:' + (e.message || e))
}
dingBusy.value = false
// 兜底:未配置钉钉应用时回落到工号录入
if (!dingAccount.value) dingAccount.value = account.value.trim()
dingOpen.value = true
}
function openDingWindow() {
@@ -239,117 +274,216 @@ async function promptChangePwd(acc, r) {
</script>
<style scoped>
/* ================= 精密蓝本 · 分屏编辑式登录 =================
暖纸底 + 墨色 + 赭红强调,发丝线 / 索引编号 / 制图节点营造"精密、可靠"。 */
.login {
display: grid;
place-items: center;
height: 100%;
padding: 24px;
box-sizing: border-box;
position: relative;
overflow: hidden;
background: radial-gradient(1100px 520px at 50% -12%, rgba(59, 108, 255, .07), transparent 62%);
}
/* ---------- 背景光斑 ---------- */
.blob {
position: absolute;
border-radius: 50%;
filter: blur(90px);
opacity: .38;
pointer-events: none;
will-change: transform;
animation: float 18s ease-in-out infinite;
}
.b1 { width: 460px; height: 460px; background: #a8c1ff; top: -150px; right: -110px; }
.b2 { width: 400px; height: 400px; background: #9fe3c8; bottom: -140px; left: -90px; animation-delay: -6s; }
.b3 { width: 280px; height: 280px; background: #ffd6a8; bottom: 18%; right: 10%; opacity: .22; animation-delay: -12s; }
@keyframes float {
0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
50% { transform: translate3d(0, -22px, 0) scale(1.06); }
}
/* ---------- 卡片 ---------- */
.card {
width: 380px;
max-width: 100%;
height: 100%;
box-sizing: border-box;
overflow: auto;
padding: 42px 32px;
display: flex;
flex-direction: column;
gap: 18px;
padding: 32px 32px 26px;
border: 1px solid var(--border);
border-radius: 20px;
background: var(--surface);
align-items: center;
justify-content: center;
background-color: #eeece4;
background-image:
radial-gradient(1200px 700px at 82% -8%, rgba(208, 74, 36, .07), transparent 55%),
radial-gradient(1000px 700px at 6% 108%, rgba(32, 34, 38, .06), transparent 55%);
font-family: var(--font-body);
color: #17181a;
}
/* 全屏细网格 */
.login::before {
content: '';
position: fixed;
inset: 0;
pointer-events: none;
background-image:
linear-gradient(rgba(23, 24, 26, .045) 1px, transparent 1px),
linear-gradient(90deg, rgba(23, 24, 26, .045) 1px, transparent 1px);
background-size: 52px 52px;
-webkit-mask-image: radial-gradient(circle at 50% 42%, #000, transparent 74%);
mask-image: radial-gradient(circle at 50% 42%, #000, transparent 74%);
}
.mono { font-family: var(--font-mono); letter-spacing: .04em; }
/* ---------- 舞台 ---------- */
.stage {
position: relative;
z-index: 1;
width: min(1080px, 100%);
display: grid;
grid-template-columns: 1.08fr 1fr;
min-height: 600px;
border-radius: 24px;
overflow: hidden;
border: 1px solid rgba(23, 24, 26, .09);
box-shadow:
0 24px 60px -26px rgba(24, 39, 75, .34),
0 2px 10px -3px rgba(24, 39, 75, .08);
animation: rise .5s cubic-bezier(.22, 1, .36, 1) both;
0 50px 120px -48px rgba(23, 24, 26, .5),
0 6px 24px -8px rgba(23, 24, 26, .14);
animation: rise .6s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes rise {
from { opacity: 0; transform: translateY(14px) scale(.985); }
from { opacity: 0; transform: translateY(18px) scale(.985); }
to { opacity: 1; transform: none; }
}
/* ---------- 品牌区 ---------- */
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 2px; }
.logo {
width: 42px;
height: 42px;
flex: none;
border-radius: 12px;
display: grid;
place-items: center;
background: var(--primary-grad);
color: #fff;
font-size: 15px;
font-weight: 800;
letter-spacing: .02em;
box-shadow: 0 6px 16px -5px rgba(59, 108, 255, .65);
/* ---------- 左:品牌叙事面板 ---------- */
.panel {
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 42px 46px 36px;
color: #eceadf;
background:
radial-gradient(560px 420px at 110% -10%, rgba(208, 74, 36, .28), transparent 60%),
radial-gradient(460px 380px at -12% 112%, rgba(90, 98, 110, .35), transparent 62%),
#1a1c1f;
position: relative;
}
.brand-meta { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.brand-meta strong {
font-size: 15px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
.panel::after { /* 左侧制图导轨 */
content: '';
position: absolute;
top: 0; bottom: 0; left: 22px;
width: 1px;
background: linear-gradient(rgba(236, 234, 223, .16), rgba(236, 234, 223, .02));
}
.brand-meta span { font-size: 11.5px; color: var(--text-faint); letter-spacing: .02em; }
.panel-top { display: flex; align-items: center; gap: 12px; }
.mark {
width: 40px; height: 40px; flex: none;
display: grid; place-items: center;
border-radius: 10px;
background: #d04a24;
color: #fdfbf4;
font-weight: 800; font-size: 15px; letter-spacing: .01em;
box-shadow: 0 8px 22px -6px rgba(208, 74, 36, .6);
}
.word { font-size: 14px; font-weight: 600; letter-spacing: .02em; }
.panel-code { margin-left: auto; font-size: 11px; opacity: .5; }
.panel-mid { padding: 8px 12px 0 0; }
.headline {
margin: 0 0 18px;
font-size: 33px;
line-height: 1.24;
font-weight: 700;
letter-spacing: .005em;
}
.headline::after {
content: '';
display: block;
width: 34px; height: 3px; margin-top: 22px;
background: #d04a24;
border-radius: 3px;
}
.slogan { margin: 22px 0 34px; font-size: 13.5px; line-height: 1.95; opacity: .62; }
.nodes { display: flex; flex-direction: column; gap: 20px; }
.node { display: flex; align-items: center; gap: 14px; }
.n-idx { width: 30px; font-size: 12px; opacity: .45; }
.n-txt { font-size: 14.5px; letter-spacing: .01em; color: rgba(236, 234, 223, .72); }
.node.act .n-txt { color: #f3f1e6; font-weight: 600; }
.n-dot {
width: 7px; height: 7px; border-radius: 50%;
margin-left: auto;
background: #2a2d31;
border: 1px solid rgba(236, 234, 223, .22);
}
.node.act .n-dot {
background: #d04a24;
box-shadow: 0 0 0 4px rgba(208, 74, 36, .22);
border-color: transparent;
}
.panel-foot { font-size: 10.5px; opacity: .38; letter-spacing: .12em; }
/* ---------- 右:认证面板 ---------- */
.auth {
background: #f6f4ec;
padding: 46px 50px 40px;
display: flex;
flex-direction: column;
justify-content: center;
}
.auth-head { margin-bottom: 26px; }
.auth-index { font-size: 11px; color: #d04a24; letter-spacing: .16em; }
.auth-title { margin: 10px 0 6px; font-size: 24px; font-weight: 700; letter-spacing: .01em; }
.auth-sub { margin: 0; font-size: 13px; color: #6c6e74; }
/* ---------- 表单 ---------- */
.auth :deep(.el-form-item) { margin-bottom: 20px; }
.auth :deep(.el-form-item__label) {
font-size: 12.5px; color: #4a4b50; font-weight: 600;
padding-bottom: 7px;
}
.auth :deep(.el-input__wrapper) {
border-radius: 8px;
background: #fbfaf5;
box-shadow: 0 0 0 1px #ded9ca inset;
padding: 2px 12px;
transition: box-shadow .2s, background-color .2s;
}
.auth :deep(.el-input__wrapper:hover) { box-shadow: 0 0 0 1px #cdc7b4 inset; }
.auth :deep(.el-input__wrapper.is-focus) {
background: #fff;
box-shadow: 0 0 0 1.5px #d04a24 inset, 0 8px 22px -12px rgba(208, 74, 36, .5);
}
.auth :deep(.el-input__inner) { color: #17181a; height: 44px; }
/* ---------- 主按钮 ---------- */
.primary { width: 100%; margin-top: 2px; letter-spacing: .06em; font-weight: 600; }
.primary {
width: 100%; height: 46px; margin-top: 2px;
border: none; border-radius: 8px;
background: #17181a;
color: #f6f4ec;
font-weight: 600; letter-spacing: .14em;
box-shadow: 0 10px 26px -12px rgba(23, 24, 26, .7);
transition: transform .12s, background-color .15s, box-shadow .12s;
}
.primary:hover { background: #26282c; transform: translateY(-1px); box-shadow: 0 14px 30px -12px rgba(23, 24, 26, .7); }
.primary:active { transform: none; }
.primary:disabled { opacity: .55; }
/* ---------- 钉钉登录区 ---------- */
/* ---------- 钉钉 ---------- */
.divider {
display: flex; align-items: center; gap: 10px;
color: var(--text-faint); font-size: 11px; letter-spacing: .02em;
margin: 6px 0 2px;
display: flex; align-items: center; gap: 12px;
color: #9a968a; font-size: 11px; letter-spacing: .06em;
margin: 26px 0 14px;
}
.divider::before, .divider::after {
content: ''; height: 1px; flex: 1; background: var(--border);
.divider::before, .divider::after { content: ''; height: 1px; flex: 1; background: #ded9ca; }
.dingtalk {
width: 100%; height: 46px; border-radius: 8px;
border: none; color: #fff;
background: linear-gradient(120deg, #1491f0, #0a7cdf);
font-weight: 600; letter-spacing: .04em;
box-shadow: 0 10px 26px -12px rgba(10, 124, 223, .6);
transition: transform .12s, filter .12s;
}
.dingtalk { width: 100%; color: #0aa9f4; border-color: rgba(10,169,244,.35); letter-spacing: .04em; }
.dingtalk:hover, .dingtalk:focus { border-color: #0aa9f4; color: #0aa9f4; background: rgba(10,169,244,.06); }
.ding-tip { margin: 0 0 14px; font-size: 12px; line-height: 1.7; color: var(--text-faint); }
.inline-qr { margin-top: 14px; text-align: center; }
.qr-box { width: 240px; height: 240px; margin: 0 auto 6px; border: 1px solid rgba(0,0,0,.06); border-radius: 10px; overflow: hidden; background: #fff; display: flex; align-items: center; justify-content: center; }
.dingtalk:hover { color: #fff; filter: brightness(1.04); transform: translateY(-1px); }
.dingtalk:active { transform: none; }
/* ---------- 内嵌二维码兜底 ---------- */
.inline-qr { margin-top: 18px; text-align: center; }
.qr-box { width: 240px; height: 240px; margin: 0 auto 8px; border: 1px solid rgba(23,24,26,.08); border-radius: 10px; overflow: hidden; background: #fff; display: flex; align-items: center; justify-content: center; }
.qr-box :deep(#ding_qr_container) { margin: 0 auto; }
.qr-actions { margin-top: 4px; }
.qr-actions .el-link { font-size: 12px; }
.ding-tip { margin: 0 0 14px; font-size: 12px; line-height: 1.7; color: #6c6e74; }
/* ---------- 自适应 & 降级 ---------- */
@media (max-width: 420px) {
.login { padding: 16px; }
.card { padding: 26px 22px 22px; border-radius: 16px; }
.blob { filter: blur(70px); opacity: .3; }
/* ---------- 自适应 ---------- */
@media (max-width: 860px) {
.stage { grid-template-columns: 1fr; min-height: 0; }
.panel { padding: 30px 34px; min-height: 300px; }
.auth { padding: 34px 30px; }
.panel-mid { padding-top: 4px; }
}
@media (max-height: 640px) {
.login { padding: 22px 18px; }
.panel { justify-content: flex-start; gap: 26px; }
.nodes { gap: 14px; }
}
@media (prefers-reduced-motion: reduce) {
.blob, .card { animation: none; }
.stage { animation: none; }
* { transition-duration: .01ms !important; }
}
</style>
+143 -46
View File
@@ -7,23 +7,32 @@
:with-header="true"
@close="emit('close')"
>
<!-- 个人信息卡片 -->
<el-card class="info-card" shadow="never">
<template #header>
<div class="info-head">
<el-avatar :size="46" :src="store.avatarUrl" @error="onAvatarError" class="avatar">
<span>{{ store.current.slice(0, 1).toUpperCase() }}</span>
</el-avatar>
<div class="info-meta">
<div class="name-line">
<strong>{{ store.current }}</strong>
<el-tag v-if="store.isAdmin" size="small" type="primary" effect="light" round>管理员</el-tag>
</div>
<span class="dept">{{ store.dept || '未设置部门' }}</span>
<!-- 个人信息 -->
<section class="pcard">
<div class="cover"><span class="cover-id mono">ID · {{ store.current }}</span></div>
<div class="pcard-main">
<el-avatar :size="60" :src="store.avatarUrl" @error="onAvatarError" class="avatar">
<span>{{ store.current.slice(0, 1).toUpperCase() }}</span>
</el-avatar>
<div class="pcard-id">
<div class="name-line">
<strong>{{ store.current }}</strong>
<em v-if="store.isAdmin" class="admin">管理员</em>
</div>
<span class="dept">{{ store.dept || '未设置部门' }}</span>
</div>
</template>
</el-card>
</div>
<div class="pcard-rows">
<div class="crow">
<span>已授权插件</span>
<span class="mono">{{ store.plugins.length }}</span>
</div>
<div class="crow">
<span>平台在线</span>
<span class="mono">{{ store.platforms.filter(p => p.online).length }}/{{ store.platforms.length }}</span>
</div>
</div>
</section>
<!-- 平台登录态 -->
<el-collapse v-model="activeNames">
@@ -34,14 +43,14 @@
<span>平台登录态</span>
</div>
</template>
<div v-for="p in store.platforms" :key="p.id" class="prow">
<i class="dot" :class="{ on: p.online }"></i>
<div v-for="(p, i) in store.platforms" :key="p.id" class="prow">
<span class="ridx mono">P0{{ i + 1 }}</span>
<span class="dot" :class="{ on: p.online }"></span>
<span class="pname">{{ p.label }}</span>
<span class="pstat">{{ p.online ? '已登录' : '未登录' }}</span>
<el-button size="small" :disabled="busy === p.id" @click="relogin(p.id)">
{{ busy === p.id ? '处理中…' : '重新登录' }}
<el-button size="small" :disabled="busy === p.id || p.online" @click="relogin(p.id)">
{{ busy === p.id ? '处理中…' : p.online ? '正常' : '重新登录' }}
</el-button>
<el-button size="small" :disabled="busy === p.id || !p.online" @click="logout(p.id)">登出</el-button>
<el-button v-if="p.online" size="small" plain type="danger" :disabled="busy === p.id" @click="logout(p.id)">登出</el-button>
</div>
</el-collapse-item>
@@ -54,10 +63,12 @@
</div>
</template>
<el-empty v-if="!store.plugins.length" description="当前账号暂无可用插件" />
<div v-else 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 v-else class="ilist">
<div v-for="(p, i) in store.plugins" :key="p.id" class="irow">
<span class="ridx mono">{{ String(i + 1).padStart(2, '0') }}</span>
<span class="iname">{{ p.name }}</span>
<span class="mono iver">v{{ p.version }}</span>
<span class="i-dot"></span>
</div>
</div>
</el-collapse-item>
@@ -189,28 +200,114 @@ async function changePwd() {
</script>
<style scoped>
.info-card { margin-bottom: 16px; }
.info-head { display: flex; align-items: center; gap: 12px; }
.avatar { flex-shrink: 0; }
.info-meta { flex: 1; min-width: 0; }
.name-line { display: flex; align-items: center; gap: 8px; }
.name-line strong { font-size: 15px; }
.dept { font-size: 11.5px; color: var(--text-faint); }
.mono { font-family: var(--font-mono); letter-spacing: .04em; }
.panel-title { display: flex; align-items: center; gap: 8px; }
.prow {
display: flex; align-items: center; gap: 8px;
padding: 8px 0;
/* ================= 个人信息卡 ================= */
.pcard {
margin-bottom: 18px;
background: #ffffff;
border: 1px solid var(--border);
border-radius: 14px;
overflow: hidden;
box-shadow: 0 10px 28px -18px rgba(23, 24, 26, .35);
}
.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; }
.cover {
height: 66px;
background:
radial-gradient(360px 200px at 90% -30%, rgba(208, 74, 36, .5), transparent 60%),
radial-gradient(300px 180px at -10% 120%, rgba(120, 128, 140, .4), transparent 60%),
#1a1c1f;
position: relative;
}
.cover-id {
position: absolute;
right: 14px; bottom: 12px;
font-size: 11px;
color: rgba(236, 234, 223, .55);
letter-spacing: .1em;
}
.pcard-main {
display: flex; align-items: center; gap: 14px;
padding: 0 18px 16px;
margin-top: -30px;
position: relative;
}
.avatar {
border: 3px solid #fff;
border-radius: 50%;
box-shadow: 0 6px 16px -6px rgba(23, 24, 26, .45);
background: #17181a;
color: #f6f4ec;
font-weight: 700;
flex: none;
}
.pcard-id { min-width: 0; }
.name-line { display: flex; align-items: center; gap: 8px; }
.name-line strong { font-size: 16px; letter-spacing: .01em; color: #17181a; }
.admin {
font-style: normal; font-size: 10.5px; font-weight: 600;
color: #d04a24;
border: 1px solid rgba(208, 74, 36, .35);
background: rgba(208, 74, 36, .07);
border-radius: 4px;
padding: 1px 6px;
letter-spacing: .04em;
}
.dept { font-size: 12px; color: var(--text-faint); }
.pwd-card { margin-top: 16px; }
.pcard-rows { border-top: 1px solid var(--border); }
.crow {
display: flex; align-items: center; justify-content: space-between;
padding: 11px 18px;
border-bottom: 1px solid var(--border);
font-size: 13px;
}
.crow:last-child { border-bottom: none; }
.crow span:first-child { color: var(--text-sub); }
.crow .mono { color: #17181a; font-size: 13px; font-weight: 600; }
/* ================= 折叠面板 ================= */
.panel-title { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-sub); }
.panel-title :deep(.el-icon) { color: #d04a24; }
/* ---------- 平台登录态:编号 + 发丝线 ---------- */
.prow {
display: flex; align-items: center; gap: 10px;
padding: 11px 0;
border-bottom: 1px dashed var(--border);
}
.prow:last-child { border-bottom: none; }
.ridx { flex: none; width: 26px; font-size: 11px; color: var(--text-faint); }
.dot {
flex: none; width: 7px; height: 7px; border-radius: 50%;
background: #c6ccdc;
}
.dot.on { background: #22b07a; box-shadow: 0 0 0 3px rgba(34, 176, 122, .16); }
.pname { flex: 1; color: var(--text-sub); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prow :deep(.el-button--primary) { border-color: transparent; }
.prow :deep(.el-button--danger.is-plain) { border-color: rgba(214, 69, 69, .35); color: #d64545; }
/* ---------- 我的插件:台账式列表 ---------- */
.ilist { display: flex; flex-direction: column; }
.irow {
display: flex; align-items: center; gap: 10px;
padding: 11px 0;
border-bottom: 1px dashed var(--border);
}
.irow:last-child { border-bottom: none; }
.iname { flex: 1; color: var(--text); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iver { font-size: 11px; color: var(--text-faint); }
.i-dot { flex: none; width: 5px; height: 5px; border-radius: 50%; background: #d04a24; }
/* ---------- 修改密码 ---------- */
.pwd-card { margin-top: 16px; border-radius: 14px; border-color: var(--border); }
.pwd-card :deep(.el-card__header) {
font-size: 13px; font-weight: 600;
border-bottom: 1px solid var(--border);
padding: 12px 16px;
}
.pwd-card :deep(.el-card__body) { padding: 16px; }
.pwd-card :deep(.el-form-item__label) { color: var(--text-sub); font-weight: 500; }
.pwd-card :deep(.el-button--primary) { width: 100%; border-color: transparent; background: #17181a; }
.pwd-card :deep(.el-button--primary:hover) { background: #26282c; }
</style>
+2
View File
@@ -28,6 +28,8 @@
--radius: 14px;
--radius-sm: 9px;
--mono: "JetBrains Mono", "Consolas", "Courier New", monospace;
--font-mono: "JetBrains Mono", "Consolas", "Courier New", monospace;
--font-body: "Inter", "Microsoft YaHei UI", "PingFang SC", -apple-system, sans-serif;
/* element-plus 主题与品牌蓝统一 */
--el-color-primary: #3b6cff;