refactor: 项目重命名为37du自动化工作台,完成全链路更新

本次提交完成了项目从"业务场景工具集"到"自动化工作台"的全链路重命名:
1.  更新所有页面标题、应用名称配置
2.  重构前端登录页UI与交互逻辑,新增启动加载动画
3.  移除旧版钉钉登录相关API与代码
4.  优化控制面板后台统计接口的SQL查询与字段映射
5.  新增agent_cli命令行管理工具,支持插件与账号权限管理
6.  修复后端插件权限校验逻辑,新增云端权限拉取能力
7.  更新控制面登录页面样式与交互体验
This commit is contained in:
2026-09-14 00:34:54 +08:00
parent fb85157678
commit ba24c29d53
10 changed files with 996 additions and 489 deletions
+351
View File
@@ -0,0 +1,351 @@
# -*- coding: utf-8 -*-
"""agent 脚手架 · 中心机插件发布与账号权限管理 CLI(单文件自包含)。
用途:让 agent / 运维以命令行方式管理中心机,无需打开浏览器即可:
- 发布 / 删除插件包(按最近 3 版自动裁剪保留)
- 变更插件状态(published / disabled / revoked)与强制更新阈值
- 建号 / 重置密码 / 改部门昵称 / 授撤销管理员 / 删除账号
- 按账号授予 / 撤销插件与平台权限
- 查看插件 / 账号 / 运行统计
鉴权:
管理接口同时需要 内部凭证(X-API-Token) + 管理票据(X-Admin-Token)。
本脚本运行在中心机本机,直接复用 controlplane/.env 与 .admin_secret:
- X-API-Token 取自 CONTROLPLANE_TOKEN(.env);为空则该接口不强制,无需携带。
- X-Admin-Token 用 CONTROLPLANE_ADMIN_SECRET > CONTROLPLANE_TOKEN > .admin_secret
对指定管理员账号临时签发短期票据(与 app.py 完全一致,签名不可伪造)。
因此本 CLI 只在"中心机本机 + 拥有管理密钥"的环境下可用,等价于本地管理台白名单。
管理员账号:需用 --admin 显式指定(或设环境变量 AGENT_ADMIN_ACCOUNT),该账号须 is_admin=1。
运行(项目 .venv):
python -m controlplane.agent_cli publish plugin.zip --id report --version 1.2.0
python -m controlplane.agent_cli plugins
python -m controlplane.agent_cli grant alice report # 默认授予 download+run
python -m controlplane.agent_cli users
需一次性传参的自包含要求:无外部参数依赖,配置固化/读取 .env 即可。
"""
from __future__ import annotations
import argparse
import base64
import hashlib
import hmac
import json
import os
import time
from pathlib import Path
from typing import Optional
APP_DIR = Path(__file__).resolve().parent
def _load_dotenv() -> None:
"""读取 controlplane/.env(同 app.py 规则:环境变量优先,不覆盖已存在值)。"""
env_path = APP_DIR / ".env"
if not env_path.is_file():
return
for _ln in env_path.read_text(encoding="utf-8").splitlines():
_line = _ln.strip()
if not _line or _line.startswith("#") or "=" not in _line:
continue
_k, _v = _line.split("=", 1)
k, v = _k.strip(), _v.strip()
if k and k not in os.environ:
os.environ[k] = v
_load_dotenv()
BASE_URL = os.getenv("CONTROLPLANE_AGENT_BASE", "").rstrip("/") or \
f"http://127.0.0.1:{os.getenv('CONTROLPLANE_PORT', '8800')}"
API_TOKEN = os.getenv("CONTROLPLANE_TOKEN", "")
def _admin_secret() -> str:
"""与 app.py 完全一致:CONTROLPLANE_ADMIN_SECRET > CONTROLPLANE_TOKEN > .admin_secret。"""
cand = os.getenv("CONTROLPLANE_ADMIN_SECRET") or os.getenv("CONTROLPLANE_TOKEN") or ""
if cand:
return cand
_f = APP_DIR / ".admin_secret"
if _f.is_file():
return _f.read_text(encoding="utf-8").strip()
return ""
def _mint_admin_token(account: str, secret: str) -> str:
"""临时签发 1 小时管理票据(算法必须与 app._sign_admin_token 一致)。"""
payload = base64.urlsafe_b64encode(
json.dumps({"a": account, "e": int(time.time()) + 3600}, separators=(",", ":")).encode()
).decode().rstrip("=")
sig = hmac.new(secret.encode("utf-8"), payload.encode("utf-8"), hashlib.sha256).hexdigest()
return f"{payload}.{sig}"
class Client:
"""携带 X-API-Token + X-Admin-Token 的中心机 API 客户端。"""
def __init__(self, base: str, api_token: str, admin: str, secret: str):
self.base = base
self.api_token = api_token
self.admin = admin
self.secret = secret
def _headers(self, json_body: bool = True) -> dict:
h = {}
if self.api_token:
h["X-API-Token"] = self.api_token
if self.admin and self.secret:
h["X-Admin-Token"] = _mint_admin_token(self.admin, self.secret)
if json_body:
h["Content-Type"] = "application/json"
return h
def call(self, method: str, path: str, json_body: Optional[dict] = None,
_hdrs_json: Optional[bool] = None) -> dict:
import requests
url = self.base + path # path 已是完整路径(含 query)
try:
if json_body is not None:
r = requests.request(method, url, headers=self._headers(True), json=json_body, timeout=30)
else:
r = requests.request(method, url, headers=self._headers(False), timeout=30)
except requests.ConnectionError as exc:
raise SystemExit(f"[x] 无法连接中心机 {self.base}({exc})。请确认服务已启动。")
try:
data = r.json()
except ValueError:
data = {"raw": r.text[:300]}
if r.status_code >= 400:
detail = data.get("detail") if isinstance(data, dict) else data
if isinstance(detail, dict):
detail = detail.get("msg") or detail
raise SystemExit(f"[x] HTTP {r.status_code}:{detail or r.text[:200]}")
return data if isinstance(data, dict) else {"result": data}
def upload_pkg(self, path: str, plugin_id: str, name: str, version: str) -> dict:
import requests
import urllib.parse
qs = urllib.parse.urlencode({"plugin_id": plugin_id, "name": name, "version": version})
with open(path, "rb") as fp:
r = requests.post(f"{self.base}/api/admin/pkg?{qs}",
headers=self._headers(False),
files={"upload": (Path(path).name, fp, "application/zip")},
timeout=60)
try:
data = r.json()
except ValueError:
data = {"raw": r.text[:300]}
if r.status_code >= 400:
detail = data.get("detail") if isinstance(data, dict) else data
raise SystemExit(f"[x] HTTP {r.status_code}:{detail}")
return data
# ------------------------------ 输出辅助 ------------------------------
def _plugin_rows(plugins) -> None:
"""overview 的 plugins 为列表(含版本/授权明细),此处只打印核心字段。"""
rows = plugins if isinstance(plugins, list) else \
(list(plugins.values()) if isinstance(plugins, dict) else [])
if not rows:
print("(暂无插件)")
return
print(f"{'ID':<28}{'名称':<16}{'最新版':<10}{'状态':<12}账号数")
for p in rows:
if not isinstance(p, dict):
continue
print(f"{str(p.get('id', '')):<28}{str(p.get('name') or ''):<16}"
f"{str(p.get('latest_version') or ''):<10}{str(p.get('status') or ''):<12}{len(p.get('accounts') or [])}")
# ================================ main ================================
def _build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
prog="agent_cli",
description="37du 中心机 · agent 插件发布与管理 CLI",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("--admin", default=os.getenv("AGENT_ADMIN_ACCOUNT", ""),
help="用于签发管理票据的管理员账号(须 is_admin=1)")
parser.add_argument("--base", default=BASE_URL, help="中心机服务地址")
sub = parser.add_subparsers(dest="command", required=True)
p_pub = sub.add_parser("publish", help="发布插件包 zip(自动裁剪保留最近 3 版)")
p_pub.add_argument("pkg", help="插件 zip 路径")
p_pub.add_argument("--id", dest="plugin_id", required=True, help="插件 ID(须与 plugin.json 内 id 一致)")
p_pub.add_argument("--name", default="", help="插件名称(缺省取 plugin.json 内 name 或 ID)")
p_pub.add_argument("--version", required=True, help="版本号,如 1.2.0")
sub.add_parser("plugins", help="列出插件清单")
p_del = sub.add_parser("plugin-del", help="删除插件(连带全部版本、授权、磁盘包)")
p_del.add_argument("plugin_id")
p_status = sub.add_parser("plugin-status", help="变更插件状态/强制更新阈值")
p_status.add_argument("plugin_id")
p_status.add_argument("--status", choices=["published", "disabled", "revoked"], default="",
help="新状态(留空不改变)")
p_status.add_argument("--force-min-version", default="", help="强制最低版本(与 --force-deadline 成对)")
p_status.add_argument("--force-deadline", default="", help="强制更新截止时间(ISO 字符串)")
p_status.add_argument("--clear-force", action="store_true", help="清除强制更新配置")
sub.add_parser("users", help="列出账号清单")
p_user = sub.add_parser("user-add", help="新建账号")
p_user.add_argument("account")
p_user.add_argument("--password", required=True)
p_user.add_argument("--dept", default="")
p_user.add_argument("--nickname", default="")
p_user.add_argument("--admin", dest="is_admin_flag", action="store_true", help="设为管理员")
p_upd = sub.add_parser("user-update", help="更新账号(部门/昵称/管理员)")
p_upd.add_argument("account")
p_upd.add_argument("--dept", default=None)
p_upd.add_argument("--nickname", default=None)
p_upd.add_argument("--is-admin", dest="is_admin_opt", type=lambda s: s in ("1", "true", "yes", "是"),
default=None)
p_rp = sub.add_parser("user-reset-pwd", help="管理员重置账号密码")
p_rp.add_argument("account")
p_rp.add_argument("--password", required=True)
p_del_u = sub.add_parser("user-del", help="删除账号")
p_del_u.add_argument("account")
p_grant = sub.add_parser("grant", help="授予账号某插件权限(默认 download+run)")
p_grant.add_argument("account")
p_grant.add_argument("plugin_id")
p_grant.add_argument("--no-download", action="store_true", help="不授予下载权限")
p_grant.add_argument("--no-run", action="store_true", help="不授予运行权限")
p_revoke = sub.add_parser("revoke", help="撤销账号某插件权限")
p_revoke.add_argument("account")
p_revoke.add_argument("plugin_id")
p_gp = sub.add_parser("grant-platform", help="授予账号某平台登录权限")
p_gp.add_argument("account")
p_gp.add_argument("platform_id")
p_rp_plt = sub.add_parser("revoke-platform", help="撤销账号某平台登录权限")
p_rp_plt.add_argument("account")
p_rp_plt.add_argument("platform_id")
sub.add_parser("stats", help="运行统计看板")
sub.add_parser("me", help="校验当前管理身份")
return parser
def _run(args: argparse.Namespace) -> int:
if not args.admin:
raise SystemExit("[x] 未指定管理员账号:请用 --admin <账号> 或设置环境变量 AGENT_ADMIN_ACCOUNT。")
secret = _admin_secret()
if not secret:
raise SystemExit("[x] 未找到管理密钥(CONTROLPLANE_ADMIN_SECRET / CONTROLPLANE_TOKEN / .admin_secret 均为空),无法签发管理票据。")
c = Client(args.base, API_TOKEN, args.admin, secret)
cmd = args.command
if cmd == "publish":
r = c.upload_pkg(args.pkg, args.plugin_id, args.name, args.version)
print(f"[ok] 已发布 {r.get('plugin_id')} v{r.get('version')} → {r.get('filename')}")
elif cmd == "plugins":
data = c.call("GET", "/api/admin/overview")
_plugin_rows(data.get("plugins", {}))
elif cmd == "plugin-del":
r = c.call("POST", "/api/admin/plugin/delete", {"plugin_id": args.plugin_id})
print(f"[ok] 已删除插件 {r.get('plugin_id')}")
elif cmd == "plugin-status":
import urllib.parse as _q
body = {}
if args.status:
body["status"] = args.status
if args.force_min_version and args.force_deadline:
body.update({"force_min_version": args.force_min_version, "force_deadline": args.force_deadline})
elif args.clear_force:
body["clear_force"] = True
r = c.call("POST", f"/api/admin/plugin/patch?{_q.urlencode({'plugin_id': args.plugin_id})}", body)
print("[ok]", json.dumps(r, ensure_ascii=False))
elif cmd == "users":
data = c.call("GET", "/api/admin/accounts")
accounts = data.get("accounts", "")
if isinstance(accounts, dict):
accounts = list(accounts.values())
accounts = [a for a in (accounts or []) if isinstance(a, dict)]
if not accounts:
print("(暂无账号)")
return 0
print(f"{'账号':<16}{'昵称':<14}{'部门':<12}{'管理员'}")
for a in accounts:
print(f"{str(a.get('account', '')):<16}{str(a.get('nickname') or ''):<14}"
f"{str(a.get('dept') or ''):<12}{'是' if a.get('is_admin') else '否'}")
elif cmd == "user-add":
r = c.call("POST", "/api/admin/account", {
"account": args.account, "password": args.password,
"dept": args.dept, "nickname": args.nickname, "is_admin": args.is_admin_flag})
print(f"[ok] 已建号 {r.get('account')}" + ("(管理员)" if r.get("is_admin") else ""))
elif cmd == "user-update":
body = {"account": args.account}
for k, v in (("dept", args.dept), ("nickname", args.nickname), ("is_admin", args.is_admin_opt)):
if v is not None:
body[k] = v
r = c.call("POST", "/api/admin/account/update", body)
print(f"[ok] 已更新 {r.get('account')}")
elif cmd == "user-reset-pwd":
r = c.call("POST", "/api/admin/account/reset_pwd", {"account": args.account, "new_password": args.password})
print(f"[ok] 已重置 {r.get('account')} 密码")
elif cmd == "user-del":
r = c.call("POST", "/api/admin/account/delete", {"account": args.account})
print(f"[ok] 已删除账号 {r.get('account')}")
elif cmd == "grant":
r = c.call("POST", "/api/admin/account_plugins", {
"account": args.account, "plugin_id": args.plugin_id, "granted": True,
"can_download": not args.no_download, "can_run": not args.no_run})
print(f"[ok] 已授予 {r.get('account')} → {r.get('plugin_id')}(download={'y' if not args.no_download else 'n'}"
f"/run={'y' if not args.no_run else 'n'})")
elif cmd == "revoke":
r = c.call("POST", "/api/admin/account_plugins", {
"account": args.account, "plugin_id": args.plugin_id, "granted": False})
print(f"[ok] 已撤销 {r.get('account')} → {r.get('plugin_id')}")
elif cmd == "grant-platform":
r = c.call("POST", "/api/admin/account_platforms", {
"account": args.account, "platform_id": args.platform_id, "granted": True})
print(f"[ok] 已授予 {r.get('account')} → 平台 {r.get('platform_id')}")
elif cmd == "revoke-platform":
r = c.call("POST", "/api/admin/account_platforms", {
"account": args.account, "platform_id": args.platform_id, "granted": False})
print(f"[ok] 已撤销 {r.get('account')} → 平台 {r.get('platform_id')}")
elif cmd == "stats":
print(json.dumps(c.call("GET", "/api/admin/stats"), ensure_ascii=False, indent=2))
elif cmd == "me":
data = c.call("GET", "/api/admin/me")
print(f"登录账号:{data.get('account')} 管理员:{'是' if data.get('is_admin') else '否'} "
f"部门:{data.get('dept') or ''}")
return 0
def main() -> None:
args = _build_parser().parse_args()
try:
_run(args)
except SystemExit as exc:
if exc.code:
print(str(exc.code))
raise
if __name__ == "__main__":
main()
+21 -22
View File
@@ -1413,23 +1413,21 @@ def admin_stats(x_admin_token: str = Header(default="", alias="X-Admin-Token"),
_require_admin(x_admin_token, x_api_token)
with _db() as conn:
users = dict(conn.execute(
"SELECT (SELECT COUNT(*) FROM accounts), "
"(SELECT COUNT(*) FROM accounts WHERE is_admin = 1), "
"(SELECT COUNT(DISTINCT account) FROM account_plugins)").fetchone())
"SELECT (SELECT COUNT(*) FROM accounts) AS total, "
"(SELECT COUNT(*) FROM accounts WHERE is_admin = 1) AS admins, "
"(SELECT COUNT(DISTINCT account) FROM account_plugins) AS authorized").fetchone())
plugins = dict(conn.execute(
"SELECT "
" (SELECT COUNT(*) FROM plugins), "
" (SELECT COUNT(*) FROM plugins WHERE status = 'published'), "
" (SELECT COUNT(*) FROM plugins WHERE status = 'disabled'), "
" (SELECT COUNT(*) FROM plugins WHERE status = 'revoked')").fetchone())
"SELECT (SELECT COUNT(*) FROM plugins) AS total, "
"(SELECT COUNT(*) FROM plugins WHERE status = 'published') AS published, "
"(SELECT COUNT(*) FROM plugins WHERE status = 'disabled') AS disabled, "
"(SELECT COUNT(*) FROM plugins WHERE status = 'revoked') AS revoked").fetchone())
runs = dict(conn.execute(
"SELECT "
" (SELECT COUNT(*) FROM runtime_reports WHERE status = 'start'), "
" (SELECT COUNT(*) FROM runtime_reports WHERE status IN ('done','success')), "
" (SELECT COUNT(*) FROM runtime_reports WHERE status IN ('error','failed')), "
" (SELECT COALESCE(SUM(duration_sec),0) FROM runtime_reports), "
" (SELECT COUNT(DISTINCT account) FROM runtime_reports WHERE account <> ''), "
" (SELECT COUNT(DISTINCT plugin_id) FROM runtime_reports WHERE plugin_id <> '')").fetchone())
"SELECT (SELECT COUNT(*) FROM runtime_reports WHERE status = 'start') AS started, "
"(SELECT COUNT(*) FROM runtime_reports WHERE status IN ('done','success')) AS success, "
"(SELECT COUNT(*) FROM runtime_reports WHERE status IN ('error','failed')) AS failed, "
"(SELECT COALESCE(SUM(duration_sec),0) FROM runtime_reports) AS duration_sec, "
"(SELECT COUNT(DISTINCT account) FROM runtime_reports WHERE account <> '') AS active_users, "
"(SELECT COUNT(DISTINCT plugin_id) FROM runtime_reports WHERE plugin_id <> '') AS active_plugins").fetchone())
# 近 14 天运行趋势(按日:触发次数 / 成功 / 失败)
trend_rows = conn.execute(
@@ -1486,14 +1484,15 @@ def admin_stats(x_admin_token: str = Header(default="", alias="X-Admin-Token"),
for rc in recent:
rc["nickname"] = nick.get(rc.get("account", ""), "")
now_day = datetime.now().strftime("%Y-%m-%d")
return {
"users": {"total": int(users[0] or 0), "admins": int(users[1] or 0),
"authorized": int(users[2] or 0)},
"plugins": {"total": int(plugins[0] or 0), "published": int(plugins[1] or 0),
"disabled": int(plugins[2] or 0), "revoked": int(plugins[3] or 0)},
"runs": {"total": int(runs[0] or 0), "success": int(runs[1] or 0),
"failed": int(runs[2] or 0), "durationSec": int(runs[3] or 0),
"activeUsers": int(runs[4] or 0), "activePlugins": int(runs[5] or 0)},
"users": {"total": int(users["total"] or 0), "admins": int(users["admins"] or 0),
"authorized": int(users["authorized"] or 0)},
"plugins": {"total": int(plugins["total"] or 0), "published": int(plugins["published"] or 0),
"disabled": int(plugins["disabled"] or 0), "revoked": int(plugins["revoked"] or 0)},
"runs": {"total": int(runs["started"] or 0), "success": int(runs["success"] or 0),
"failed": int(runs["failed"] or 0), "durationSec": int(runs["duration_sec"] or 0),
"activeUsers": int(runs["active_users"] or 0), "activePlugins": int(runs["active_plugins"] or 0)},
"trend": trend, "topPlugins": top_plugins, "topUsers": top_users,
"recent": recent, "today": now_day,
}
Binary file not shown.
@@ -1,48 +1,57 @@
<template>
<div class="login-wrap">
<div class="orb orb-a"></div>
<div class="orb orb-b"></div>
<div class="orb orb-c"></div>
<div class="grid-mask"></div>
<n-card class="card" :bordered="false">
<div class="login">
<div class="card">
<div class="brand">
<span class="logo">37</span>
<div class="brand-meta">
<strong>{{ appName }}</strong>
<span>中心机统一账户登录</span>
<h1>{{ appName }}</h1>
<p>中心机统一账户登录</p>
</div>
</div>
<n-form label-placement="top" @keydown.enter="doLogin">
<n-form class="form" label-placement="top" @keydown.enter.prevent="doLogin">
<n-form-item label="账号">
<n-input v-model:value="account" placeholder="请输入账号" size="large">
<n-input
v-model:value="account"
placeholder="请输入账号"
autocomplete="username"
size="large"
@keyup.enter="doLogin"
>
<template #prefix><n-icon><User /></n-icon></template>
</n-input>
</n-form-item>
<n-form-item label="密码">
<n-input v-model:value="password" type="password" show-password-on="click" placeholder="请输入密码" size="large">
<n-input
v-model:value="password"
type="password"
placeholder="请输入密码"
autocomplete="current-password"
size="large"
show-password-on="click"
@keyup.enter="doLogin"
>
<template #prefix><n-icon><Lock /></n-icon></template>
</n-input>
</n-form-item>
<n-button type="primary" size="large" block class="login-btn" :loading="busy" @click="doLogin">
{{ busy ? '校验中…' : '登 录' }}
<n-button type="primary" size="large" block class="primary" :loading="busy" @click="doLogin">
{{ busy ? '登录中…' : '登 录' }}
</n-button>
</n-form>
<div class="foot">内网管理面 · 请使用管理员账号登录</div>
</n-card>
</div>
</div>
</template>
<script setup>
import { onMounted, ref } from 'vue'
import { ref } from 'vue'
import { User, Lock } from '@element-plus/icons-vue'
import { adminLogin } from '../api'
import { store } from '../store.js'
import { message } from '../naive'
const props = defineProps({ appName: { type: String, default: '37du 内网插件控制面' } })
const props = defineProps({ appName: { type: String, default: '37du 自动化工作台' } })
const emit = defineEmits(['ok'])
const account = ref('')
@@ -73,61 +82,44 @@ async function doLogin() {
</script>
<style scoped>
.login-wrap {
height: 100vh; position: relative; overflow: hidden;
display: grid; place-items: center;
background:
radial-gradient(1000px 520px at 85% -10%, rgba(59, 108, 255, .16), transparent 60%),
radial-gradient(900px 480px at 0% 110%, rgba(34, 199, 232, .14), transparent 55%),
radial-gradient(700px 420px at 60% 120%, rgba(139, 92, 246, .10), transparent 60%),
linear-gradient(180deg, #f4f7fd 0%, #e9eefb 100%);
}
.orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; pointer-events: none; }
.orb-a { width: 360px; height: 360px; top: -120px; right: -60px; background: radial-gradient(circle, rgba(59, 108, 255, .35), transparent 70%); }
.orb-b { width: 300px; height: 300px; bottom: -100px; left: -80px; background: radial-gradient(circle, rgba(34, 199, 232, .32), transparent 70%); }
.orb-c { width: 260px; height: 260px; bottom: 80px; right: 12%; background: radial-gradient(circle, rgba(139, 92, 246, .22), transparent 70%); }
.grid-mask {
position: absolute; inset: 0; pointer-events: none;
background-image:
linear-gradient(rgba(59, 108, 255, .05) 1px, transparent 1px),
linear-gradient(90deg, rgba(59, 108, 255, .05) 1px, transparent 1px);
background-size: 44px 44px;
mask-image: radial-gradient(circle at 50% 42%, rgba(0, 0, 0, .5), transparent 75%);
-webkit-mask-image: radial-gradient(circle at 50% 42%, rgba(0, 0, 0, .5), transparent 75%);
.login {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 24px;
box-sizing: border-box;
background: linear-gradient(180deg, #f7f8fa 0%, #eef0f4 100%);
font-family: var(--font-body, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif);
}
.card {
width: 380px; position: relative; z-index: 2;
border-radius: 20px;
background: rgba(255, 255, 255, .82);
backdrop-filter: blur(18px);
-webkit-backdrop-filter: blur(18px);
border: 1px solid var(--cp-border);
box-shadow: 0 24px 60px -24px rgba(43, 64, 132, .35);
animation: cp-rise .6s cubic-bezier(.22, .61, .36, 1) both;
width: 380px;
box-sizing: border-box;
background: #ffffff;
border: 1px solid var(--cp-border, #e5e7ec);
border-radius: 16px;
padding: 34px 32px 28px;
box-shadow: 0 16px 40px -24px rgba(30, 42, 76, .25);
}
.brand { display: flex; align-items: center; gap: 13px; margin-bottom: 24px; }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.logo {
width: 46px; height: 46px; border-radius: 14px; position: relative;
width: 42px; height: 42px; border-radius: 12px; flex: none;
display: grid; place-items: center;
background: linear-gradient(135deg, #3b6cff 0%, #22c7e8 130%);
color: #fff; font-size: 16px; font-weight: 800; letter-spacing: .5px;
box-shadow: 0 10px 22px -8px rgba(59, 108, 255, .6);
color: #fff; font-size: 15px; font-weight: 800; letter-spacing: .4px;
box-shadow: 0 8px 18px -8px rgba(59, 108, 255, .55);
}
.logo::after { content: ''; position: absolute; inset: 2px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .28); }
.brand-meta { display: flex; flex-direction: column; line-height: 1.3; }
.brand-meta strong { font-size: 16px; color: var(--cp-ink); letter-spacing: .2px; }
.brand-meta span { font-size: 12px; color: var(--cp-ink-3); }
.brand-meta h1 { margin: 0; font-size: 17px; font-weight: 700; color: var(--cp-ink, #1c2433); letter-spacing: .2px; }
.brand-meta p { margin: 3px 0 0; font-size: 12px; color: var(--cp-ink-3, #8a93a6); }
/* 登录按钮:与 logo / 侧栏选中态统一的品牌渐变 */
.login-btn {
margin-top: 6px;
background: linear-gradient(135deg, #3b6cff 0%, #22b0e8 130%);
border: none;
box-shadow: 0 10px 22px -10px rgba(59, 108, 255, .55);
transition: box-shadow .2s, transform .2s;
}
.login-btn:hover { box-shadow: 0 14px 26px -10px rgba(59, 108, 255, .65); transform: translateY(-1px); }
.login-btn:active { transform: translateY(0); }
.foot { margin-top: 18px; text-align: center; font-size: 11.5px; color: var(--cp-ink-3); }
</style>
.form :deep(.n-form-item) { margin-bottom: 20px; }
.form :deep(.n-form-item-label) { font-size: 12.5px; font-weight: 600; color: var(--cp-ink-2, #4a5270); padding-bottom: 6px; }
.form :deep(.n-input) { border-radius: 8px; }
.form :deep(.n-input__inner) { font-size: 14px; }
.primary.n-button--primary-type { height: 44px; border-radius: 8px; font-size: 14px; letter-spacing: .1em; }
.foot { margin-top: 20px; text-align: center; font-size: 11.5px; color: var(--cp-ink-3, #8a93a6); }
</style>
+37 -5
View File
@@ -638,21 +638,53 @@ def _account_allowed_platforms(account: str) -> set | None:
return None
def _cloud_plugin_ids(account: str) -> set | None:
"""已登录且有云端会话 token 时,用 Bearer 向中心机 /api/plugins 拉账号可用插件 id 集(§2.2)。
降级策略(三态):
- 200 → 返回账号允许的插件 id 集(真正按员工权限过滤)
- 401 → 云端可达但 token 失效(如云端重启):返回空集,**不给全量**,防越权泄露
- 其它(超时/断连/5xx) → 返回 None,调用方按离线兜底放行本地全量(§2.5)
"""
token = (_ACCT_CLOUD_TOKEN or {}).get(account) if account else None
if not token or not CONTROLPLANE_URL:
return None
import requests
try:
r = requests.get(f"{CONTROLPLANE_URL}/api/plugins",
headers={"Authorization": f"Bearer {token}"}, timeout=5)
except Exception: # noqa: BLE001 云端不可达 → 离线兜底
return None
if r.status_code == 401:
return set()
if r.status_code != 200:
return None
return {p["id"] for p in r.json().get("plugins", [])}
@app.get("/api/meta")
def meta(request: Request) -> dict:
account = _sess_account(request)
# 插件清单仅对已登录账号可见(未登录不泄露插件元数据)
plugins = [_plugin_schema(p) for p in PLUGINS] if account else []
allowed = _account_allowed_platforms(account) if account else None
# 插件清单仅对已登录账号可见(未登录不泄露插件元数据);
# 已登录且能按云端权限(authorization)解析时,仅返回该员工被授权插件(§2.2 权限隔离)。
if account:
allowed = _cloud_plugin_ids(account)
plugins = ([_plugin_schema(p) for p in PLUGINS if p.id in allowed]
if allowed is not None # 云端按员工返回了授权集(也可能是空集=无权限)
else [_plugin_schema(p) for p in PLUGINS]) # 无 token/云端不可达 → 离线兜底全量
else:
plugins = []
allowed_plats = _account_allowed_platforms(account) if account else None
platforms = [{"id": pid, "label": m["label"],
"online": platform_auth.is_online(pid),
# 已登录时按账号白名单;未登录/中心机不可达默认展示
"allowed": (pid in allowed) if allowed is not None else True}
"allowed": (pid in allowed_plats) if allowed_plats is not None else True}
for pid, m in PLATFORMS.items()]
return {
# controlplane_url 供前端管理员跳转控制面;未配置时为空(前端隐藏管理入口)
"controlplane": CONTROLPLANE_URL,
"appName": "37du 业务场景工具集",
"appName": "37du 自动化工作台",
"dingtalkScan": bool(DINGTALK_APP_KEY),
"platforms": platforms,
"plugins": plugins,
+1 -1
View File
@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>37du 业务场景工具集</title>
<title>37du 自动化工作台</title>
</head>
<body>
<div id="app"></div>
+33 -2
View File
@@ -1,5 +1,10 @@
<template>
<LoginPage v-if="!store.current" :app-name="store.appName" @ok="onLogin" />
<div v-if="booting" class="boot">
<span class="boot-logo">37</span>
<span class="boot-txt">{{ store.appName || '自动化工作台' }}</span>
<span class="boot-dots"><i></i><i></i><i></i></span>
</div>
<LoginPage v-else-if="!store.current" :app-name="store.appName" @ok="onLogin" />
<div class="__app" v-else>
<!-- 顶部:品牌 + 平台登录态 + 当前账号/登出 + 进度 -->
<header class="topbar panel">
@@ -161,12 +166,14 @@ onMounted(async () => {
store.selectedId = store.plugins[0]?.id || ''
clearLogs()
openWS()
checkSession()
await checkSession()
booting.value = false // 会话判定完成(登录/未登录/后端不可达均已定),再渲染首屏
loadAvatar()
})
const profileOpen = ref(false)
const busyLogin = ref('')
const booting = ref(true) // 鉴权判定中:未确定会话前先显示加载骨架,避免「闪一下登录页再进首页」
// 平台登录等轻量操作反馈:统一走 element-plus 全局消息
function showToast(msg, type = 'info') {
@@ -267,6 +274,30 @@ async function login(id) {
</script>
<style scoped>
.boot {
min-height: 100vh;
display: flex; flex-direction: column; align-items: center; justify-content: center;
gap: 14px; background: var(--bg);
}
.boot-logo {
width: 54px; height: 54px; border-radius: 16px;
display: grid; place-items: center;
background: var(--primary-grad); color: #fff;
font-size: 20px; font-weight: 800;
box-shadow: 0 10px 26px -8px rgba(59,108,255,.65);
animation: bootpop .4s ease;
}
.boot-txt { font-size: 13px; color: var(--text-faint); letter-spacing: .06em; }
.boot-dots { display: flex; gap: 5px; }
.boot-dots i {
width: 6px; height: 6px; border-radius: 50%; background: var(--primary);
animation: bootblink 1s infinite ease-in-out;
}
.boot-dots i:nth-child(2) { animation-delay: .15s; }
.boot-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bootpop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bootblink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; transform: translateY(-2px); } }
.topbar {
display: flex; align-items: center; gap: 16px;
padding: 12px 18px;
-13
View File
@@ -50,23 +50,10 @@ export async function adminMe() {
export async function adminLogin(account, password) {
return j('/api/admin/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ account, password }) })
}
export async function adminDingtalkLogin(account, nickname, dingtalk_uid = '') {
return j('/api/admin/dingtalk/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ 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')
}
export async function adminDingtalkInlineLogin(code) {
return j('/api/admin/dingtalk/inline', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ code }) })
}
export async function adminLogout() {
return j('/api/admin/logout', { method: 'POST' })
}
+494 -379
View File
@@ -1,135 +1,103 @@
<template>
<div class="login">
<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>
<!-- 巨大 37:节点阵列 -->
<div class="ghost" aria-hidden="true">37</div>
<div class="panel-mid">
<h1 class="headline">一处登录,<br />驱动所有业务场景。</h1>
<p class="slogan">考勤 · 审批 · 数据导出 · 定时任务<br />装好即用,扫码即入。</p>
<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 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 class="pipeline" aria-hidden="true">
<i></i><i></i><i></i>
</div>
<!-- 真实钉钉扫码(配置了开放平台应用时 window.open 扫码页;否则回落到工号录入) -->
<el-dialog v-model="dingOpen" title="钉钉登录" width="360px" align-center>
<p class="ding-tip">完成钉钉扫码后,填入工号与姓名即自动建立/匹配账号。<br>新账号默认无插件权限,首次登录请改密。</p>
<el-form label-position="top" @submit.prevent="doDing">
<el-form-item label="工号(作为账号)">
<el-input v-model="dingAccount" placeholder="钉钉工号" size="large" :disabled="dingBusy" @keyup.enter="doDing" />
<!-- 顶部:品牌 + 系统状态 -->
<header class="topbar">
<div class="brand">
<span class="mark">37</span>
<span class="name">{{ appName || '37du 自动化工作台' }}</span>
</div>
<div class="sys">
<span class="dot" aria-hidden="true"></span>
<span>引擎运行中</span>
</div>
</header>
<!-- 中央:接入终端 -->
<main class="panel">
<span class="core-mark">37 CORE · AUTOMATION</span>
<h1>自动化工作台</h1>
<p class="sub">使用统一账号或钉钉扫码,进入你的流程中心</p>
<el-form label-position="top" class="form" @submit.prevent="doLogin">
<el-form-item label="员工账号">
<el-input
v-model="account"
placeholder="请输入账号"
autocomplete="username"
size="large"
clearable
@keyup.enter="doLogin"
/>
</el-form-item>
<el-form-item label="姓名">
<el-input v-model="dingName" placeholder="钉钉姓名" size="large" :disabled="dingBusy" @keyup.enter="doDing" />
<el-form-item label="密码">
<el-input
v-model="password"
type="password"
placeholder="请输入密码"
autocomplete="current-password"
size="large"
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>
<template #footer>
<el-button @click="dingOpen = false">取消</el-button>
<el-button type="primary" :loading="dingBusy" @click="doDing">确认登录</el-button>
</template>
</el-dialog>
<div class="divider"><span>或</span></div>
<el-button
size="large"
class="dingtalk"
:loading="dingBusy"
:icon="ChatDotRound"
@click="openDing"
>
钉钉扫码接入
</el-button>
</main>
<!-- 底部:流程状态 -->
<footer class="footbar">
<div class="flows">
<span>接入终端就绪</span>
<span class="f-blocks" aria-hidden="true">
<i></i><i></i><i></i><i></i><i></i>
</span>
</div>
<span class="copyright">© 37du 自动化工作台</span>
</footer>
</div>
</template>
<script setup>
import { ref, onMounted, onUnmounted, nextTick } from 'vue'
import { ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { User, Lock, ChatDotRound } from '@element-plus/icons-vue'
import { adminLogin, adminDingtalkLogin, adminDingtalkQr, adminPassword, adminDingtalkInlineQr, adminDingtalkInlineLogin, authDingtalk } from '../api'
import { ChatDotRound } from '@element-plus/icons-vue'
import { adminLogin, adminPassword, authDingtalk } from '../api'
const props = defineProps({ appName: { type: String, default: '' } })
defineProps({ appName: { type: String, default: '' } })
const emit = defineEmits(['ok'])
const account = ref('')
const password = ref('')
const busy = ref(false)
const dingOpen = ref(false)
const dingBusy = ref(false)
const dingAccount = ref('')
const dingName = ref('')
const dingUrl = ref('')
// 内嵌二维码状态
const inlineOpen = ref(false)
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 (_) {}
})
async function doLogin() {
if (busy.value) return
@@ -138,7 +106,12 @@ async function doLogin() {
try {
const r = await adminLogin(account.value, password.value)
ElMessage.success('登录成功')
emit('ok', { account: account.value.trim(), is_admin: !!r.is_admin, dept: r.dept || '', must_change_pwd: !!r.must_change_pwd })
emit('ok', {
account: account.value.trim(),
is_admin: !!r.is_admin,
dept: r.dept || '',
must_change_pwd: !!r.must_change_pwd
})
} catch (e) {
ElMessage.error('登录失败:' + (e.message || e))
} finally {
@@ -146,113 +119,21 @@ async function doLogin() {
}
}
// 钉钉扫码登录:壳后端直接生成授权 URL,当前窗口跳转钉钉;扫码后浏览器自动跳回 /auth/done
async function openDing() {
if (dingBusy.value) return
dingBusy.value = true
// v3 钉钉直连接登录:壳后端生成授权 URL(redirect_uri=本机 /auth/done),当前窗口跳转钉钉。
try {
const r = await authDingtalk()
if (r && r.url) {
window.location.href = r.url // 当前窗口跳转;扫码后浏览器跳回 /auth/done → 云端换身份 → 回主页
window.location.href = r.url
return
}
ElMessage.error('钉钉登录未配置,请联系管理员')
} catch (e) {
ElMessage.error('钉钉登录不可用:' + (e.message || e))
}
dingBusy.value = false
// 兜底:未配置钉钉应用时回落到工号录入
if (!dingAccount.value) dingAccount.value = account.value.trim()
dingOpen.value = true
}
function openDingWindow() {
// 链接授权:新窗口打开钉钉二维码页(中心机换取身份后回跳建会话)
if (dingUrl.value) {
const w = window.open(dingUrl.value, 'dingLogin', 'width=460,height=560,menubar=no,toolbar=no,status=no')
if (w) return
}
if (!dingAccount.value) dingAccount.value = account.value.trim()
dingOpen.value = true // 工号录入兜底
}
function loadDdLogin() {
if (window.DDLogin) { renderDdLogin(); return }
const s = document.createElement('script')
s.src = 'https://g.alicdn.com/dingding/dinglogin/0.0.5/ddLogin.js'
s.async = true
s.onload = renderDdLogin
s.onerror = () => {
ElMessage.error('加载钉钉二维码组件失败,已改用浏览器窗口授权')
inlineOpen.value = false
openDingWindow()
}
document.head.appendChild(s)
if (!ddMsgHandler) {
ddMsgHandler = (ev) => {
if (ev.origin && /(?:^|\.)(?:login|oapi|qr|auth|api)\.dingtalk\.com$/.test(
new URL(ev.origin).hostname || ev.origin)) {
const code = ev.data && ev.data.loginTmpCode ? ev.data.loginTmpCode : ev.data
if (code && typeof code === 'string') loginInline(code)
}
}
window.addEventListener('message', ddMsgHandler)
}
}
function renderDdLogin() {
if (!window.DDLogin || !document.getElementById('ding_qr_container')) return
new window.DDLogin({
id: 'ding_qr_container',
goto: dingGoto.value,
style: 'border:none;background:#fff;',
width: '260',
height: '260',
})
}
async function loginInline(code) {
if (dingBusy.value) return
dingBusy.value = true
try {
const r = await adminDingtalkInlineLogin(code)
ElMessage.success(r.created ? '已自动建立账号,登录成功' : '登录成功')
inlineOpen.value = false
if (r.must_change_pwd) {
await promptChangePwd(r.account || account.value, r)
} else {
emit('ok', { account: r.account, is_admin: !!r.is_admin, dept: '', created: !!r.created, nickname: r.nickname || '' })
}
} catch (e) {
ElMessage.error('登录失败:' + (e.message || e))
} finally {
dingBusy.value = false
}
}
onUnmounted(() => {
if (ddMsgHandler) window.removeEventListener('message', ddMsgHandler)
})
async function doDing() {
if (dingBusy.value) return
if (!dingAccount.value.trim()) { ElMessage.warning('请输入钉钉工号'); return }
if (!dingName.value.trim()) { ElMessage.warning('请输入钉钉姓名'); return }
dingBusy.value = true
const acc = dingAccount.value.trim()
try {
const r = await adminDingtalkLogin(acc, dingName.value.trim())
ElMessage.success(r.created ? '已自动建立账号,登录成功' : '登录成功')
dingOpen.value = false
if (r.must_change_pwd) {
await promptChangePwd(acc, r)
} else {
emit('ok', { account: acc, is_admin: !!r.is_admin, dept: '', created: !!r.created, nickname: r.nickname || '' })
}
} catch (e) {
ElMessage.error('登录失败:' + (e.message || e))
} finally {
dingBusy.value = false
}
}
async function promptChangePwd(acc, r) {
@@ -274,216 +155,450 @@ async function promptChangePwd(acc, r) {
</script>
<style scoped>
/* ================= 精密蓝本 · 分屏编辑式登录 =================
暖纸底 + 墨色 + 赭红强调,发丝线 / 索引编号 / 制图节点营造"精密、可靠"。 */
/* ============================================================
暖米画布 + 工程网格 + 点阵 37 + 接入终端
- 精密感来自网格与节点,不来自阴影
- 体温红只出现在:port 聚焦、主按钮、管线节点、状态点
============================================================ */
/* ---------- 画布 ---------- */
.login {
position: relative;
height: 100%;
min-height: 100vh;
min-height: 100dvh;
box-sizing: border-box;
overflow: auto;
padding: 42px 32px;
display: flex;
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;
padding: 110px 24px 170px;
overflow: hidden;
background: #EDE7DB;
color: #1C1712;
font-family: var(--font-body, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif);
}
/* 全屏细网格 */
/* 工程网格:边缘径向淡出 */
.login::before {
content: '';
position: fixed;
position: absolute;
inset: 0;
pointer-events: none;
z-index: 0;
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%);
linear-gradient(rgba(28, 23, 18, .045) 1px, transparent 1px),
linear-gradient(90deg, rgba(28, 23, 18, .045) 1px, transparent 1px);
background-size: 44px 44px;
-webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 78%);
mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 78%);
pointer-events: none;
}
.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 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(18px) scale(.985); }
to { opacity: 1; transform: none; }
}
/* ---------- 左:品牌叙事面板 ---------- */
.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;
}
.panel::after { /* 左侧制图导轨 */
/* 顶部暖辉光 */
.login::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));
inset: 0;
z-index: 0;
background: radial-gradient(660px 480px at 50% 38%, rgba(209, 74, 43, .06), transparent 68%);
pointer-events: none;
}
.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;
/* ---------- 巨大 37:节点阵列 ---------- */
.ghost {
position: absolute;
left: 50%;
bottom: -0.12em;
transform: translateX(-50%);
font-family: 'Helvetica Neue', 'Arial Narrow', Arial, sans-serif;
font-size: clamp(280px, 74vw, 640px);
font-weight: 800;
line-height: .72;
letter-spacing: -.08em;
white-space: nowrap;
pointer-events: none;
user-select: none;
z-index: 1;
color: rgba(28, 23, 18, .05); /* 兜底 */
animation: breathe 7s ease-in-out infinite;
}
.headline::after {
content: '';
display: block;
width: 34px; height: 3px; margin-top: 22px;
background: #d04a24;
border-radius: 3px;
@keyframes breathe {
0%, 100% { opacity: .8; }
50% { opacity: 1; }
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
.ghost {
color: transparent;
background-image: radial-gradient(circle at 1px 1px,
rgba(28, 23, 18, .16) 1px, transparent 1.9px);
background-size: 9px 9px;
-webkit-background-clip: text;
background-clip: text;
}
}
.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);
/* ---------- 基线管道 ---------- */
.pipeline {
position: absolute;
left: 50%;
bottom: 0;
transform: translateX(-50%);
width: min(920px, 92vw);
height: 1px;
background: linear-gradient(90deg,
transparent, rgba(28, 23, 18, .14) 18%,
rgba(28, 23, 18, .14) 82%, transparent);
z-index: 1;
pointer-events: none;
}
.node.act .n-dot {
background: #d04a24;
box-shadow: 0 0 0 4px rgba(208, 74, 36, .22);
border-color: transparent;
.pipeline i {
position: absolute;
top: -2px;
width: 5px;
height: 5px;
border-radius: 50%;
background: #D14A2B;
box-shadow: 0 0 0 3px rgba(209, 74, 43, .10);
}
.pipeline i:nth-child(1) { left: 22%; }
.pipeline i:nth-child(2) { left: 50%; animation: blip 3.6s ease-in-out infinite; }
.pipeline i:nth-child(3) { left: 78%; }
@keyframes blip {
0%, 100% { opacity: .35; transform: scale(.85); }
50% { opacity: 1; transform: scale(1.1); }
}
.panel-foot { font-size: 10.5px; opacity: .38; letter-spacing: .12em; }
/* ---------- 右:认证面板 ---------- */
.auth {
background: #f6f4ec;
padding: 46px 50px 40px;
/* ---------- 顶部栏 ---------- */
.topbar {
position: absolute;
top: 40px;
left: 48px;
right: 48px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
justify-content: space-between;
z-index: 3;
}
.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) {
.brand { display: flex; align-items: center; gap: 10px; }
.mark {
width: 28px;
height: 28px;
flex: none;
display: grid;
place-items: center;
border-radius: 8px;
background: #fbfaf5;
box-shadow: 0 0 0 1px #ded9ca inset;
padding: 2px 12px;
transition: box-shadow .2s, background-color .2s;
background: #D14A2B;
color: #F7F2E8;
font-size: 11px;
font-weight: 800;
letter-spacing: .01em;
font-family: 'Helvetica Neue', Arial, sans-serif;
}
.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);
.name {
font-size: 12.5px;
font-weight: 500;
letter-spacing: .04em;
color: #6B6155;
}
.sys {
display: flex;
align-items: center;
gap: 8px;
font-size: 10.5px;
letter-spacing: .12em;
color: #6F6659;
}
.dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: #D14A2B;
animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
0% { box-shadow: 0 0 0 0 rgba(209, 74, 43, .4); }
70% { box-shadow: 0 0 0 7px rgba(209, 74, 43, 0); }
100% { box-shadow: 0 0 0 0 rgba(209, 74, 43, 0); }
}
.sep { color: #C4BBA8; }
/* ---------- 中央:接入终端 ---------- */
.panel {
position: relative;
z-index: 2;
width: 100%;
max-width: 360px;
padding: 40px 36px 36px;
background: #F8F4EC;
border: 1px solid #DDD4C2;
border-radius: 14px;
box-shadow:
0 1px 0 rgba(255, 255, 255, .9) inset,
0 24px 48px -28px rgba(28, 23, 18, .30);
animation: rise .45s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes rise {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: none; }
}
/* 卡片内元素依次点亮:终端端口逐个上电 */
@keyframes seq {
from { opacity: 0; transform: translateY(7px); }
to { opacity: 1; transform: none; }
}
.core-mark { animation: seq .5s .05s both; }
.panel h1 { animation: seq .5s .10s both; }
.panel .sub{ animation: seq .5s .15s both; }
.form { animation: seq .55s .20s both; }
.divider { animation: seq .5s .26s both; }
.dingtalk { animation: seq .5s .32s both; }
/* 底部金手指纹理 */
.panel::after {
content: '';
position: absolute;
left: 36px;
right: 36px;
bottom: 0;
height: 3px;
background-image: repeating-linear-gradient(
to right,
rgba(201, 191, 171, .65) 0 8px,
transparent 8px 12px
);
pointer-events: none;
}
.core-mark {
display: block;
margin-bottom: 20px;
font-family: 'Helvetica Neue', Arial, sans-serif;
font-size: 10px;
font-weight: 700;
letter-spacing: .18em;
color: #D14A2B;
}
.panel h1 {
margin: 0 0 8px;
font-size: 26px;
font-weight: 700;
line-height: 1.2;
letter-spacing: -.01em;
color: #1C1712;
}
.panel .sub {
margin: 0 0 34px;
font-size: 13px;
line-height: 1.6;
color: #635A4D;
}
/* ---------- 表单:接口式输入 ---------- */
.form :deep(.el-form-item) {
position: relative;
padding-left: 16px;
margin-bottom: 26px;
}
.form :deep(.el-form-item__content) {
position: relative;
line-height: normal;
}
/* 左侧接口指示灯 */
.form :deep(.el-form-item__content)::before {
content: '';
position: absolute;
left: -16px;
top: 50%;
transform: translateY(-50%);
width: 6px;
height: 6px;
border-radius: 1px;
background: #C9BFAB;
transition: background .2s, box-shadow .2s;
}
.form :deep(.el-form-item:focus-within .el-form-item__content)::before {
background: #D14A2B;
box-shadow: 0 0 0 3px rgba(209, 74, 43, .12);
}
.form :deep(.el-form-item__label) {
padding-bottom: 6px;
font-size: 12px;
font-weight: 500;
letter-spacing: .02em;
line-height: 1.4;
color: #635A4D;
}
/* 底线式输入 */
.form :deep(.el-input__wrapper) {
padding: 0;
background: transparent;
border-radius: 0;
box-shadow: none !important;
border-bottom: 1px solid #D8D0BC;
transition: border-color .2s;
}
.form :deep(.el-input__wrapper:hover) {
border-bottom-color: #BCB29A;
}
.form :deep(.el-input__wrapper.is-focus) {
border-bottom-color: #D14A2B;
}
.form :deep(.el-input__inner) {
height: 44px;
padding: 0;
font-size: 15px;
color: #1C1712;
caret-color: #D14A2B;
}
.form :deep(.el-input__inner::placeholder) {
color: #9A8F7A;
}
.form :deep(.el-input__suffix),
.form :deep(.el-input__prefix),
.form :deep(.el-input__suffix-inner) {
color: #9A8F7A;
}
.form :deep(.el-input__suffix-inner .el-input__icon:hover) {
color: #635A4D;
}
.auth :deep(.el-input__inner) { color: #17181a; height: 44px; }
/* ---------- 主按钮 ---------- */
.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.el-button {
width: 100%;
height: 48px;
margin-top: 6px;
border: none;
border-radius: 8px;
background: #D14A2B;
color: #FFF8F2;
font-size: 14px;
font-weight: 600;
letter-spacing: .12em;
box-shadow: 0 12px 28px -14px rgba(209, 74, 43, .7);
transition: background-color .15s, opacity .15s, transform .12s ease, box-shadow .15s ease;
}
.primary.el-button:hover,
.primary.el-button:focus {
background: #BB3F21;
color: #FFF8F2;
transform: translateY(-1px);
box-shadow: 0 15px 30px -14px rgba(209, 74, 43, .78);
}
.primary.el-button:active {
background: #A53517;
transform: translateY(1px) scale(.99);
box-shadow: 0 6px 16px -12px rgba(209, 74, 43, .8);
}
.primary.el-button.is-disabled,
.primary.el-button.is-loading {
background: #D14A2B;
opacity: .55;
}
.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: 12px;
color: #9a968a; font-size: 11px; letter-spacing: .06em;
margin: 26px 0 14px;
display: flex;
align-items: center;
gap: 14px;
margin: 28px 0 16px;
font-size: 11.5px;
letter-spacing: .04em;
color: #8D8476;
}
.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;
.divider::before,
.divider::after {
content: '';
flex: 1;
height: 1px;
background: #E0D9C6;
}
.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; }
/* ---------- 钉钉按钮 ---------- */
.dingtalk.el-button {
width: 100%;
height: 48px;
border-radius: 8px;
border: 1px solid #DED6C2;
background: #FDFBF6;
color: #1C1712;
font-size: 14px;
font-weight: 500;
letter-spacing: .02em;
transition: border-color .15s, background-color .15s, transform .12s ease, box-shadow .15s ease;
}
.dingtalk.el-button:hover,
.dingtalk.el-button:focus {
border-color: #C4BBA8;
background: #FFFFFF;
color: #1C1712;
transform: translateY(-1px);
box-shadow: 0 8px 20px -14px rgba(28, 23, 18, .28);
}
.dingtalk.el-button:active {
transform: translateY(0) scale(.99);
}
.dingtalk.el-button :deep(.el-icon) {
color: #1491F0;
}
/* ---------- 键盘可达 ---------- */
.primary.el-button:focus-visible,
.dingtalk.el-button:focus-visible {
outline: 2px solid #D14A2B;
outline-offset: 3px;
}
/* ---------- 底部:流程状态 ---------- */
.footbar {
position: absolute;
bottom: 40px;
left: 48px;
right: 48px;
display: flex;
align-items: center;
justify-content: space-between;
z-index: 3;
}
.flows {
display: flex;
align-items: center;
gap: 10px;
font-size: 10.5px;
letter-spacing: .12em;
color: #6F6659;
}
.f-blocks { display: flex; gap: 3px; }
.f-blocks i {
width: 12px;
height: 4px;
border-radius: 1px;
background: #C9BEAA;
}
.copyright {
font-size: 10.5px;
letter-spacing: .1em;
color: #9A8F7C;
}
/* ---------- 自适应 ---------- */
@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-width: 720px) {
.login { padding: 96px 20px 140px; }
.topbar { top: 24px; left: 24px; right: 24px; }
.footbar { bottom: 24px; left: 24px; right: 24px; }
.panel { padding: 32px 24px 30px; }
.panel h1 { font-size: 23px; }
.panel::after { left: 24px; right: 24px; }
.copyright { display: none; }
}
@media (max-height: 640px) {
.login { padding: 22px 18px; }
.panel { justify-content: flex-start; gap: 26px; }
.nodes { gap: 14px; }
@media (max-height: 680px) {
.login {
align-items: flex-start;
overflow-x: hidden;
overflow-y: auto;
padding: 80px 24px 120px;
}
.footbar { display: none; }
}
@media (prefers-reduced-motion: reduce) {
.stage { animation: none; }
.dot, .pipeline i, .ghost { animation: none; }
.panel { animation: none; }
.core-mark, .panel h1, .panel .sub, .form, .divider, .dingtalk { animation: none; }
* { transition-duration: .01ms !important; }
}
</style>
+1 -1
View File
@@ -103,7 +103,7 @@ def _stop(proc: subprocess.Popen) -> None:
def main() -> int:
app_name = "37du 业务场景工具集"
app_name = "37du 自动化工作台"
proc = _start_server()
if not _open_window(app_name):