feat: 新增通知推送功能及离线登录,优化重连逻辑
- 新增通知推送模块:支持 WebSocket 实时推送与轮询兜底,新增通知管理界面 - 新增离线登录功能:断网时凭本地 7 天授权票据自动登录或手动登录 - 优化 Electron 客户端 WebSocket 重连逻辑,避免死循环 - 调整工作流脚本,拆分重构合同相关分支逻辑 - 新增设备上报客户端版本字段,用于升级追踪与关旧依据
This commit is contained in:
@@ -14,6 +14,7 @@ from fastapi import APIRouter, File, Header, HTTPException, Query, UploadFile
|
||||
from fastapi.responses import FileResponse
|
||||
|
||||
from controlplane import config, schemas
|
||||
from controlplane.apis.notifications import push_account, push_all
|
||||
from controlplane.core.auth import _identity, _require_admin, _revoke_account_tokens
|
||||
from controlplane.core.crypto import _hash_password
|
||||
from controlplane.core.db import _audit, _db, _now
|
||||
@@ -738,18 +739,40 @@ def admin_devices(page: int = Query(default=1, ge=1),
|
||||
page_size: int = Query(default=20, ge=1, le=1000),
|
||||
x_admin_token: str = Header(default="", alias="X-Admin-Token"),
|
||||
x_api_token: str = Header(default="", alias="X-API-Token")) -> dict:
|
||||
"""执行机设备列表(统一分页,按最近心跳倒序):环境信息 + Chrome 检测结果。"""
|
||||
"""执行机设备列表(统一分页,按最近心跳倒序):环境信息 + Chrome 检测结果 + 客户端版本。"""
|
||||
_require_admin(x_admin_token, x_api_token)
|
||||
limit, offset = page_bounds(page, page_size)
|
||||
with _db() as conn:
|
||||
total = count_rows(conn, "SELECT COUNT(*) AS c FROM devices")
|
||||
rows = [dict(r) for r in conn.execute(
|
||||
"SELECT device_id, account, hostname, os, ip, chrome_installed, chrome_version, "
|
||||
" chrome_ok, last_seen, status, created_at, updated_at "
|
||||
" chrome_ok, client_version, last_seen, status, created_at, updated_at "
|
||||
"FROM devices ORDER BY last_seen DESC LIMIT %s OFFSET %s", (limit, offset))]
|
||||
return {"items": rows, "total": total}
|
||||
|
||||
|
||||
@router.get("/api/admin/devices/summary")
|
||||
def admin_devices_summary(x_admin_token: str = Header(default="", alias="X-Admin-Token"),
|
||||
x_api_token: str = Header(default="", alias="X-API-Token")) -> dict:
|
||||
"""客户端升级追踪汇总:按版本统计设备数 + 按账号分组展示各设备客户端版本(关旧控制面依据)。"""
|
||||
_require_admin(x_admin_token, x_api_token)
|
||||
with _db() as conn:
|
||||
total = count_rows(conn, "SELECT COUNT(*) AS c FROM devices")
|
||||
by_version = [dict(r) for r in conn.execute(
|
||||
"SELECT client_version AS client_version, COUNT(*) AS count "
|
||||
"FROM devices GROUP BY client_version ORDER BY count DESC")]
|
||||
by_account = [dict(r) for r in conn.execute(
|
||||
"SELECT account, client_version, COUNT(*) AS device_count, "
|
||||
" MAX(last_seen) AS last_seen "
|
||||
"FROM devices GROUP BY account, client_version ORDER BY account")]
|
||||
# 关联账号姓名/部门,方便按人识别
|
||||
nick = {dict(r)["account"]: (dict(r)["nickname"] or "", dict(r)["dept"] or "")
|
||||
for r in conn.execute("SELECT account, nickname, dept FROM accounts")}
|
||||
for row in by_account:
|
||||
row["nickname"], row["dept"] = nick.get(row["account"], ("", ""))
|
||||
return {"total": total, "by_version": by_version, "by_account": by_account}
|
||||
|
||||
|
||||
@router.post("/api/admin/shell-release")
|
||||
async def admin_shell_release(upload: UploadFile = File(...),
|
||||
version: str = Query(...),
|
||||
@@ -792,4 +815,112 @@ async def admin_shell_release(upload: UploadFile = File(...),
|
||||
"sha256": sha256, "notes": notes},
|
||||
ensure_ascii=False, indent=2), encoding="utf-8")
|
||||
_audit(login, "shell-release", filename)
|
||||
return {"ok": True, "version": version, "filename": filename, "sha256": sha256}
|
||||
return {"ok": True, "version": version, "filename": filename, "sha256": sha256}
|
||||
|
||||
|
||||
# ==================== 通知下发管理 ====================
|
||||
_NOTIF_LEVELS = {"info", "warning", "important"}
|
||||
_NOTIF_TARGETS = {"all", "account"}
|
||||
|
||||
|
||||
def _notif_expiry(iso: str):
|
||||
"""ISO 时间串 → MySQL DATETIME;空串返回 None。"""
|
||||
iso = (iso or "").strip()
|
||||
if not iso:
|
||||
return None
|
||||
return iso.replace("T", " ")[:19]
|
||||
|
||||
|
||||
@router.get("/api/admin/notifications")
|
||||
def admin_notifications(page: int = Query(default=1, ge=1),
|
||||
page_size: int = Query(default=20, ge=1, le=200),
|
||||
q: str = Query(default=""),
|
||||
x_admin_token: str = Header(default="", alias="X-Admin-Token"),
|
||||
x_api_token: str = Header(default="", alias="X-API-Token")) -> dict:
|
||||
"""通知列表(分页,按 id 倒序)。"""
|
||||
_require_admin(x_admin_token, x_api_token)
|
||||
limit, offset = page_bounds(page, page_size)
|
||||
where, args = "", []
|
||||
if q.strip():
|
||||
where = " WHERE (title LIKE %s OR content LIKE %s OR account LIKE %s)"
|
||||
args = [f"%{q.strip()}%"] * 3
|
||||
with _db() as conn:
|
||||
total = count_rows(conn, "SELECT COUNT(*) AS c FROM notifications" + where, args)
|
||||
rows = [dict(r) for r in conn.execute(
|
||||
"SELECT id, title, content, level, target, account, created_at, expires_at, active "
|
||||
"FROM notifications" + where + " ORDER BY id DESC LIMIT %s OFFSET %s",
|
||||
args + [limit, offset])]
|
||||
return {"items": rows, "total": total}
|
||||
|
||||
|
||||
@router.post("/api/admin/notifications")
|
||||
async def admin_notification_create(body: schemas.NotificationIn,
|
||||
x_admin_token: str = Header(default="", alias="X-Admin-Token"),
|
||||
x_api_token: str = Header(default="", alias="X-API-Token")) -> dict:
|
||||
"""下发通知:all=全部账号 / account=指定账号;创建后即时 WebSocket 推送在线客户端。"""
|
||||
login = _require_admin(x_admin_token, x_api_token)
|
||||
title = (body.title or "").strip()
|
||||
if not title:
|
||||
raise HTTPException(400, "标题不能为空")
|
||||
if body.level not in _NOTIF_LEVELS:
|
||||
raise HTTPException(400, "level 仅允许 info/warning/important")
|
||||
if body.target not in _NOTIF_TARGETS:
|
||||
raise HTTPException(400, "target 仅允许 all/account")
|
||||
if body.target == "account" and not (body.account or "").strip():
|
||||
raise HTTPException(400, "target=account 时必须指定 account")
|
||||
expires = _notif_expiry(body.expires_at)
|
||||
with _db() as conn:
|
||||
cur = conn.execute(
|
||||
"INSERT INTO notifications(title, content, level, target, account, expires_at) "
|
||||
"VALUES (%s,%s,%s,%s,%s,%s)",
|
||||
(title, (body.content or "").strip(), body.level, body.target,
|
||||
(body.account or "").strip(), expires))
|
||||
nid = cur.lastrowid
|
||||
conn.commit()
|
||||
_audit(login, "notify-create", f"通知 #{nid} {title} → {body.target}")
|
||||
payload = {"type": "notify", "notification": {
|
||||
"id": nid, "title": title, "content": (body.content or "").strip(),
|
||||
"level": body.level, "target": body.target, "account": (body.account or "").strip(),
|
||||
"created_at": _now()}}
|
||||
if body.target == "all":
|
||||
pushed = await push_all(payload)
|
||||
else:
|
||||
pushed = await push_account((body.account or "").strip(), payload)
|
||||
return {"ok": True, "id": nid, "title": title, "target": body.target,
|
||||
"pushed": pushed}
|
||||
|
||||
|
||||
@router.patch("/api/admin/notifications/{nid}")
|
||||
async def admin_notification_toggle(nid: int,
|
||||
active: bool = Query(...),
|
||||
x_admin_token: str = Header(default="", alias="X-Admin-Token"),
|
||||
x_api_token: str = Header(default="", alias="X-API-Token")) -> dict:
|
||||
"""启用/停用通知;启用时即时推送给在线客户端。"""
|
||||
login = _require_admin(x_admin_token, x_api_token)
|
||||
with _db() as conn:
|
||||
row = conn.execute(
|
||||
"SELECT id, title, content, level, target, account, created_at, expires_at "
|
||||
"FROM notifications WHERE id = %s", (nid,)).fetchone()
|
||||
conn.execute("UPDATE notifications SET active = %s WHERE id = %s", (int(active), nid))
|
||||
conn.commit()
|
||||
_audit(login, "notify-toggle", f"通知 #{nid} active={active}")
|
||||
if active and row:
|
||||
payload = {"type": "notify", "notification": dict(row)}
|
||||
if row["target"] == "all":
|
||||
await push_all(payload)
|
||||
else:
|
||||
await push_account(row["account"] or "", payload)
|
||||
return {"ok": True, "id": nid, "active": active}
|
||||
|
||||
|
||||
@router.delete("/api/admin/notifications/{nid}")
|
||||
def admin_notification_delete(nid: int,
|
||||
x_admin_token: str = Header(default="", alias="X-Admin-Token"),
|
||||
x_api_token: str = Header(default="", alias="X-API-Token")) -> dict:
|
||||
"""删除通知。"""
|
||||
login = _require_admin(x_admin_token, x_api_token)
|
||||
with _db() as conn:
|
||||
conn.execute("DELETE FROM notifications WHERE id = %s", (nid,))
|
||||
conn.commit()
|
||||
_audit(login, "notify-delete", f"通知 #{nid}")
|
||||
return {"ok": True, "id": nid}
|
||||
@@ -0,0 +1,102 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""客户端通知:HTTP 拉取(兜底)+ WebSocket 实时推送(管理端下发即推,秒达)。"""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
|
||||
from fastapi import APIRouter, Header, HTTPException, Query, WebSocket, WebSocketDisconnect
|
||||
|
||||
from controlplane import config
|
||||
from controlplane.core.auth import _check_token, _cloud_account
|
||||
from controlplane.core.db import _db
|
||||
|
||||
router = APIRouter(tags=["notifications"])
|
||||
|
||||
# WebSocket 连接注册表:account -> set[WebSocket]
|
||||
# 说明:控制面单 worker 部署时进程内共享,管理端创建/停用通知时据此即时推送在线客户端;
|
||||
# 即使推送失败/客户端离线,客户端 60s 轮询兜底保证最终送达。
|
||||
_WS_CLIENTS: dict[str, set] = {}
|
||||
|
||||
|
||||
@router.get("/api/notifications")
|
||||
def notifications(account: str = Query(default=""),
|
||||
x_api_token: str = Header(default="", alias="X-API-Token"),
|
||||
authorization: str = Header(default="", alias="Authorization")) -> dict:
|
||||
"""客户端拉取通知:优先云会话 token 解工号;兜底 account + X-API-Token。
|
||||
返回 target=all 与 target=该账号 的启用且未过期通知(按创建时间倒序)。"""
|
||||
acct = _cloud_account(authorization)
|
||||
if not acct:
|
||||
_check_token(x_api_token)
|
||||
acct = (account or "").strip()
|
||||
if not acct:
|
||||
raise HTTPException(400, "缺少有效会话或 account")
|
||||
with _db() as conn:
|
||||
rows = conn.execute(
|
||||
"""
|
||||
SELECT id, title, content, level, target, account, created_at, expires_at
|
||||
FROM notifications
|
||||
WHERE active = 1
|
||||
AND (target = 'all' OR (target = 'account' AND account = %s))
|
||||
AND (expires_at IS NULL OR expires_at > NOW())
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 50
|
||||
""",
|
||||
(acct,),
|
||||
).fetchall()
|
||||
return {"notifications": [dict(r) for r in rows]}
|
||||
|
||||
|
||||
@router.websocket("/ws/notifications")
|
||||
async def ws_notifications(websocket: WebSocket, account: str = Query(default="")):
|
||||
"""客户端长连接:管理端下发通知时即时推送(秒达)。鉴权用 X-API-Token 请求头。"""
|
||||
token = (websocket.headers.get("x-api-token") or "").strip()
|
||||
if config.CONTROLPLANE_TOKEN and token != config.CONTROLPLANE_TOKEN:
|
||||
await websocket.close(code=4401)
|
||||
return
|
||||
acct = (account or "").strip()
|
||||
if not acct:
|
||||
await websocket.close(code=4400)
|
||||
return
|
||||
await websocket.accept()
|
||||
_WS_CLIENTS.setdefault(acct, set()).add(websocket)
|
||||
try:
|
||||
await websocket.send_json({"type": "hello", "account": acct})
|
||||
# 保持连接:接收客户端心跳/占位帧;断开(含网络异常)自动清理
|
||||
while True:
|
||||
await websocket.receive_text()
|
||||
except WebSocketDisconnect:
|
||||
pass
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
finally:
|
||||
ws_set = _WS_CLIENTS.get(acct)
|
||||
if ws_set:
|
||||
ws_set.discard(websocket)
|
||||
if not ws_set:
|
||||
_WS_CLIENTS.pop(acct, None)
|
||||
|
||||
|
||||
async def _send_ws(ws_set: set, payload: dict) -> None:
|
||||
for ws in list(ws_set):
|
||||
try:
|
||||
await ws.send_json(payload)
|
||||
except Exception: # noqa: BLE001
|
||||
ws_set.discard(ws)
|
||||
|
||||
|
||||
async def push_all(payload: dict) -> int:
|
||||
"""推送给全部在线客户端,返回目标连接数。"""
|
||||
n = 0
|
||||
for ws_set in _WS_CLIENTS.values():
|
||||
n += len(ws_set)
|
||||
await _send_ws(ws_set, payload)
|
||||
return n
|
||||
|
||||
|
||||
async def push_account(account: str, payload: dict) -> int:
|
||||
"""推送给指定账号的在线客户端,返回目标连接数。"""
|
||||
ws_set = _WS_CLIENTS.get(account)
|
||||
if not ws_set:
|
||||
return 0
|
||||
await _send_ws(ws_set, payload)
|
||||
return len(ws_set)
|
||||
@@ -236,17 +236,19 @@ def device_report(b: schemas.DeviceReportIn,
|
||||
with _db() as conn:
|
||||
conn.execute(
|
||||
"INSERT INTO devices(device_id, account, hostname, os, ip, "
|
||||
"chrome_installed, chrome_version, chrome_ok, last_seen, status) "
|
||||
"VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) "
|
||||
"chrome_installed, chrome_version, chrome_ok, client_version, last_seen, status) "
|
||||
"VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) "
|
||||
"ON DUPLICATE KEY UPDATE "
|
||||
"account = VALUES(account), hostname = VALUES(hostname), os = VALUES(os), "
|
||||
"ip = VALUES(ip), chrome_installed = VALUES(chrome_installed), "
|
||||
"chrome_version = VALUES(chrome_version), chrome_ok = VALUES(chrome_ok), "
|
||||
"client_version = VALUES(client_version), "
|
||||
"last_seen = VALUES(last_seen), status = VALUES(status)",
|
||||
(device_id, (b.account or "").strip(), (b.hostname or "").strip(),
|
||||
(b.os or "").strip(), (b.ip or "").strip(),
|
||||
int(bool(b.chrome_installed)), (b.chrome_version or "").strip(),
|
||||
int(bool(b.chrome_ok)), _now(), int(bool(b.status))))
|
||||
int(bool(b.chrome_ok)), (b.client_version or "").strip(),
|
||||
_now(), int(bool(b.status))))
|
||||
conn.commit()
|
||||
return {"ok": True, "device_id": device_id}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ from controlplane.apis import dingtalk as api_dingtalk
|
||||
from controlplane.apis import file_sources as api_file_sources
|
||||
from controlplane.apis import fileserver_status as api_fileserver_status
|
||||
from controlplane.apis import meta as api_meta
|
||||
from controlplane.apis import notifications as api_notifications
|
||||
from controlplane.apis import plugins as api_plugins
|
||||
from controlplane.apis import schedules as api_schedules
|
||||
|
||||
@@ -67,6 +68,7 @@ app.add_middleware(CORSMiddleware, allow_origins=_CORS_ORIGINS,
|
||||
|
||||
app.include_router(api_meta.router)
|
||||
app.include_router(api_plugins.router)
|
||||
app.include_router(api_notifications.router)
|
||||
app.include_router(api_auth.router)
|
||||
app.include_router(api_config_push.router)
|
||||
app.include_router(api_file_sources.router)
|
||||
|
||||
@@ -155,6 +155,7 @@ _DDL_TABLES = (
|
||||
chrome_installed TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否已安装 Chrome:1=是 0=否',
|
||||
chrome_version VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'Chrome 版本号',
|
||||
chrome_ok TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'Chrome 是否就绪(已安装且版本可用):1=是 0=否',
|
||||
client_version VARCHAR(32) NOT NULL DEFAULT '' COMMENT '客户端(壳子)版本号(升级追踪/关旧依据)',
|
||||
last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后在线时间(心跳上报更新)',
|
||||
status TINYINT(1) NOT NULL DEFAULT 1 COMMENT '设备状态:1=在线 0=离线',
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '首次上报时间',
|
||||
@@ -272,6 +273,21 @@ _DDL_TABLES = (
|
||||
PRIMARY KEY (account)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='登录防爆破共享计数(落库,gunicorn 多 worker 通用)'
|
||||
""",
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS notifications (
|
||||
id INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '通知ID',
|
||||
title VARCHAR(200) NOT NULL COMMENT '标题',
|
||||
content TEXT NOT NULL COMMENT '内容',
|
||||
level VARCHAR(16) NOT NULL DEFAULT 'info' COMMENT '级别:info/warning/important',
|
||||
target VARCHAR(16) NOT NULL DEFAULT 'all' COMMENT '范围:all=全部账号 account=指定账号',
|
||||
account VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'target=account 时的目标账号',
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
expires_at DATETIME NULL COMMENT '过期时间(NULL=长期有效)',
|
||||
active TINYINT(1) NOT NULL DEFAULT 1 COMMENT '1=启用 0=停用',
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_active (active, target, account)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='通知(管理端下发,客户端定时拉取)'
|
||||
""",
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class RuntimeReportIn(BaseModel):
|
||||
|
||||
|
||||
class DeviceReportIn(BaseModel):
|
||||
"""执行机心跳/环境上报(含 Chrome 检测结果),与 devices 表一一对应。"""
|
||||
"""执行机心跳/环境上报(含 Chrome 检测结果 + 客户端版本),与 devices 表一一对应。"""
|
||||
device_id: str
|
||||
account: str = ""
|
||||
hostname: str = ""
|
||||
@@ -32,6 +32,7 @@ class DeviceReportIn(BaseModel):
|
||||
chrome_version: str = "" # Chrome 版本号(检测到才填)
|
||||
chrome_ok: int = 0 # Chrome 是否就绪:1=是 0=否
|
||||
status: int = 1 # 设备状态:1=在线 0=离线
|
||||
client_version: str = "" # 客户端(壳子)版本号(升级追踪/关旧依据)
|
||||
|
||||
|
||||
class AuthIn(BaseModel):
|
||||
@@ -123,4 +124,14 @@ class PluginPatchIn(BaseModel):
|
||||
status: str = "" # 空=不改;published / disabled / revoked
|
||||
force_min_version: str = "" # 与 deadline 成对生效;二者齐全=开启,否则看 clear_force
|
||||
force_deadline: str = "" # ISO 时间串
|
||||
clear_force: bool = False # True = 清除强制更新配置
|
||||
clear_force: bool = False # True = 清除强制更新配置
|
||||
|
||||
|
||||
class NotificationIn(BaseModel):
|
||||
"""管理端下发通知:标题/内容/级别/范围(all 或指定账号)/有效期。"""
|
||||
title: str
|
||||
content: str = ""
|
||||
level: str = "info" # info / warning / important
|
||||
target: str = "all" # all=全部账号;account=指定账号
|
||||
account: str = "" # target=account 时的目标账号
|
||||
expires_at: str = "" # ISO 时间串或空(空=长期有效)
|
||||
Binary file not shown.
@@ -49,7 +49,7 @@
|
||||
|
||||
<script setup>
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { ArrowDown, Lock, SwitchButton, Odometer, TrendCharts, Box, User, Key, Document, Files } from '@element-plus/icons-vue'
|
||||
import { ArrowDown, Lock, SwitchButton, Odometer, TrendCharts, Box, User, Key, Document, Files, Monitor, Bell } from '@element-plus/icons-vue'
|
||||
import { ElMessage as message } from 'element-plus'
|
||||
import LoginPage from './components/LoginPage.vue'
|
||||
import PasswordDialog from './components/PasswordDialog.vue'
|
||||
@@ -61,12 +61,16 @@ import StatsView from './views/StatsView.vue'
|
||||
import AuditView from './views/AuditView.vue'
|
||||
import CredsManageView from './views/CredsManageView.vue'
|
||||
import FileSourceManageView from './views/FileSourceManageView.vue'
|
||||
import UpgradeView from './views/UpgradeView.vue'
|
||||
import NotifyManageView from './views/NotifyManageView.vue'
|
||||
import { store, clearSession } from './store'
|
||||
import { adminMe } from './api'
|
||||
|
||||
const menuOptions = [
|
||||
{ label: '概览', key: 'overview', icon: Odometer },
|
||||
{ label: '数据看板', key: 'stats', icon: TrendCharts },
|
||||
{ label: '升级进度', key: 'upgrade', icon: Monitor, admin: true },
|
||||
{ label: '通知推送', key: 'notify', icon: Bell, admin: true },
|
||||
{ label: '插件管理', key: 'plugins', icon: Box },
|
||||
{ label: '账号管理', key: 'accounts', icon: User },
|
||||
{ label: '权限授权', key: 'grants', icon: Key },
|
||||
@@ -80,6 +84,8 @@ const menu = computed(() => menuOptions.filter(m => !m.admin || store.isAdmin))
|
||||
const KEY = {
|
||||
'#/overview': 'overview',
|
||||
'#/stats': 'stats',
|
||||
'#/upgrade': 'upgrade',
|
||||
'#/notify': 'notify',
|
||||
'#/plugins': 'plugins',
|
||||
'#/accounts': 'accounts',
|
||||
'#/grants': 'grants',
|
||||
@@ -90,6 +96,8 @@ const KEY = {
|
||||
const VIEWS = {
|
||||
'#/overview': OverviewView,
|
||||
'#/stats': StatsView,
|
||||
'#/upgrade': UpgradeView,
|
||||
'#/notify': NotifyManageView,
|
||||
'#/plugins': PluginManageView,
|
||||
'#/accounts': AccountManageView,
|
||||
'#/grants': GrantManageView,
|
||||
|
||||
@@ -155,6 +155,13 @@ export async function adminReports(page = 1, pageSize = 20, filters = {}) {
|
||||
export async function adminStats() {
|
||||
return req('/api/admin/stats', { headers: adminHeaders() })
|
||||
}
|
||||
// 客户端升级追踪:按版本统计 + 按账号分组(关旧控制面依据)
|
||||
export async function adminDevicesSummary() {
|
||||
return req('/api/admin/devices/summary', { headers: adminHeaders() })
|
||||
}
|
||||
export async function adminDevices(page = 1, pageSize = 20) {
|
||||
return req('/api/admin/devices?' + pagedQuery({ page, page_size: pageSize }), { headers: adminHeaders() })
|
||||
}
|
||||
export async function adminCredsList(page = 1, pageSize = 20) {
|
||||
return req('/api/admin/creds/manage?' + pagedQuery({ page, page_size: pageSize }), { headers: adminHeaders() })
|
||||
}
|
||||
@@ -198,4 +205,23 @@ export async function adminUpload(pluginId, name, version, file) {
|
||||
fd.append('upload', file)
|
||||
const qs = new URLSearchParams({ plugin_id: pluginId, name, version })
|
||||
return req('/api/admin/pkg?' + qs.toString(), { method: 'POST', headers: adminHeaders(), body: fd })
|
||||
}
|
||||
// ===== 通知推送 =====
|
||||
export async function adminNotifications(page = 1, pageSize = 20, q = '') {
|
||||
const qs = pagedQuery({ page, page_size: pageSize })
|
||||
const url = '/api/admin/notifications?' + qs + (q ? '&q=' + encodeURIComponent(q) : '')
|
||||
return req(url, { headers: adminHeaders() })
|
||||
}
|
||||
export async function adminNotificationCreate(body) {
|
||||
return req('/api/admin/notifications', {
|
||||
method: 'POST',
|
||||
headers: adminHeaders({ 'Content-Type': 'application/json' }),
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
}
|
||||
export async function adminNotificationToggle(id, active) {
|
||||
return req(`/api/admin/notifications/${id}?active=${active}`, { method: 'PATCH', headers: adminHeaders() })
|
||||
}
|
||||
export async function adminNotificationDelete(id) {
|
||||
return req(`/api/admin/notifications/${id}`, { method: 'DELETE', headers: adminHeaders() })
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="page-head cp-rise">
|
||||
<div>
|
||||
<h3>通知推送 <span class="badge">Notify</span></h3>
|
||||
<p>向客户端推送通知(全部账号或指定账号)· 客户端定时拉取并弹系统通知</p>
|
||||
</div>
|
||||
<div style="display:flex;gap:10px">
|
||||
<el-button type="primary" :icon="Plus" @click="openCreate">新建通知</el-button>
|
||||
<el-button :loading="busy" :icon="Refresh" @click="reload">刷新</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cp-card cp-rise" style="padding: 12px 16px">
|
||||
<el-table :data="items" size="small" v-loading="busy" :row-key="r => r.id">
|
||||
<el-table-column label="ID" width="60">
|
||||
<template #default="{ row }"><span class="mono">{{ row.id }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="级别" width="90">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="levelType(row.level)" size="small" effect="light">{{ levelLabel(row.level) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="标题" width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }"><b>{{ row.title }}</b></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="内容" min-width="240" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.content || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="范围" width="170">
|
||||
<template #default="{ row }">
|
||||
<template v-if="row.target === 'all'">全部账号</template>
|
||||
<template v-else>账号 {{ row.account }}{{ acctName(row.account) ? '(' + acctName(row.account) + ')' : '' }}</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" width="150">
|
||||
<template #default="{ row }"><span class="mono dim-sm">{{ fmtTime(row.created_at) }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="80">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.active ? 'success' : 'info'" size="small">{{ row.active ? '启用' : '停用' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="150">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" size="small" @click="toggle(row)">{{ row.active ? '停用' : '启用' }}</el-button>
|
||||
<el-button link type="danger" size="small" @click="del(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<PagerBar :total="total" :page="page" :page-size="pageSize" @change="onPageChange" />
|
||||
</div>
|
||||
|
||||
<!-- 新建通知 -->
|
||||
<el-dialog v-model="dlgOpen" title="新建通知" width="520px" destroy-on-close>
|
||||
<el-form label-width="70px">
|
||||
<el-form-item label="标题" required>
|
||||
<el-input v-model="form.title" placeholder="如:插件更新提醒" maxlength="200" />
|
||||
</el-form-item>
|
||||
<el-form-item label="内容">
|
||||
<el-input v-model="form.content" type="textarea" :rows="3" placeholder="通知正文(可选)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="级别">
|
||||
<el-radio-group v-model="form.level">
|
||||
<el-radio-button value="info">一般</el-radio-button>
|
||||
<el-radio-button value="warning">提醒</el-radio-button>
|
||||
<el-radio-button value="important">重要</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="范围">
|
||||
<el-radio-group v-model="form.target">
|
||||
<el-radio-button value="all">全部账号</el-radio-button>
|
||||
<el-radio-button value="account">指定账号</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.target === 'account'" label="账号" required>
|
||||
<el-select
|
||||
v-model="form.account"
|
||||
filterable
|
||||
placeholder="搜索选择账号(昵称 / 工号)"
|
||||
style="width:100%"
|
||||
:loading="acctLoading"
|
||||
>
|
||||
<el-option v-for="a in accounts" :key="a.account" :label="acctLabel(a)" :value="a.account" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="有效期">
|
||||
<el-date-picker
|
||||
v-model="form.expires_at"
|
||||
type="datetime"
|
||||
placeholder="空 = 长期有效"
|
||||
value-format="YYYY-MM-DDTHH:mm:ss"
|
||||
style="width:100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dlgOpen = false">取消</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="create">发送</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { Plus, Refresh } from '@element-plus/icons-vue'
|
||||
import { ElMessage as message, ElMessageBox } from 'element-plus'
|
||||
import { adminNotifications, adminNotificationCreate, adminNotificationToggle, adminNotificationDelete, adminAccounts } from '../api'
|
||||
import { fmtTime } from '../format'
|
||||
import PagerBar from '../components/PagerBar.vue'
|
||||
import { usePagedList } from '../composables/usePagedList'
|
||||
|
||||
const list = usePagedList((p, s, q) => adminNotifications(p, s, q || ''), { onError: e => message.error('读取失败:' + (e.message || e)) })
|
||||
const { items, total, page, size: pageSize, busy, load: reload, onPageChange } = list
|
||||
|
||||
function levelType(l) {
|
||||
return { info: 'info', warning: 'warning', important: 'danger' }[l] || 'info'
|
||||
}
|
||||
function levelLabel(l) {
|
||||
return { info: '一般', warning: '提醒', important: '重要' }[l] || l
|
||||
}
|
||||
|
||||
// 账号下拉(昵称 + 工号)
|
||||
const accounts = ref([])
|
||||
const acctLoading = ref(false)
|
||||
const acctMap = computed(() => {
|
||||
const m = {}
|
||||
for (const a of accounts.value) m[a.account] = a.nickname || ''
|
||||
return m
|
||||
})
|
||||
function acctLabel(a) {
|
||||
return a.nickname ? `${a.nickname}(${a.account})` : a.account
|
||||
}
|
||||
function acctName(account) {
|
||||
return acctMap.value[account] || ''
|
||||
}
|
||||
async function loadAccounts() {
|
||||
acctLoading.value = true
|
||||
try {
|
||||
const r = await adminAccounts(1, 200)
|
||||
accounts.value = r.items || []
|
||||
} catch (e) {
|
||||
message.warning('账号列表加载失败:' + (e.message || e))
|
||||
} finally {
|
||||
acctLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 新建
|
||||
const dlgOpen = ref(false)
|
||||
const saving = ref(false)
|
||||
const form = reactive({ title: '', content: '', level: 'info', target: 'all', account: '', expires_at: '' })
|
||||
|
||||
function openCreate() {
|
||||
form.title = ''; form.content = ''; form.level = 'info'; form.target = 'all'; form.account = ''; form.expires_at = ''
|
||||
dlgOpen.value = true
|
||||
void loadAccounts()
|
||||
}
|
||||
|
||||
async function create() {
|
||||
if (!form.title.trim()) { message.warning('请填写标题'); return }
|
||||
if (form.target === 'account' && !form.account.trim()) { message.warning('指定账号时请填写目标账号'); return }
|
||||
saving.value = true
|
||||
try {
|
||||
await adminNotificationCreate({
|
||||
title: form.title.trim(), content: form.content, level: form.level,
|
||||
target: form.target, account: form.account.trim(), expires_at: form.expires_at || '',
|
||||
})
|
||||
message.success('通知已发送')
|
||||
dlgOpen.value = false
|
||||
await reload()
|
||||
} catch (e) { message.error('发送失败:' + (e.message || e)) }
|
||||
finally { saving.value = false }
|
||||
}
|
||||
|
||||
async function toggle(row) {
|
||||
try {
|
||||
await adminNotificationToggle(row.id, !row.active)
|
||||
message.success(row.active ? '已停用' : '已启用')
|
||||
await reload()
|
||||
} catch (e) { message.error('操作失败:' + (e.message || e)) }
|
||||
}
|
||||
|
||||
async function del(row) {
|
||||
try {
|
||||
await ElMessageBox.confirm(`确定删除通知「${row.title}」?`, '删除确认', { type: 'warning' })
|
||||
await adminNotificationDelete(row.id)
|
||||
message.success('已删除')
|
||||
await reload()
|
||||
} catch (e) {
|
||||
if (e !== 'cancel' && e !== 'close') message.error('删除失败:' + (e.message || e))
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,198 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="page-head cp-rise">
|
||||
<div>
|
||||
<h3>升级进度 <span class="badge">Upgrade</span></h3>
|
||||
<p>客户端版本追踪 · 按版本/账号查看升级情况(决定何时关闭旧控制面的依据)</p>
|
||||
</div>
|
||||
<el-button :loading="busy" :icon="Refresh" @click="refresh">刷新</el-button>
|
||||
</div>
|
||||
|
||||
<template v-if="s">
|
||||
<!-- KPI -->
|
||||
<div class="kpis cp-rise">
|
||||
<div class="kpi cp-card" v-for="(k, i) in kpis" :key="k.label" :style="{ animationDelay: i * 50 + 'ms' }">
|
||||
<div class="kpi-ic" :style="{ background: k.bg, color: k.color }"><el-icon :size="17"><component :is="k.icon" /></el-icon></div>
|
||||
<div class="kpi-meta">
|
||||
<div class="kpi-num mono" :style="{ color: k.color }">{{ k.value }}</div>
|
||||
<div class="kpi-lab">{{ k.label }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 版本分布 -->
|
||||
<div class="cp-card cp-rise ver-card">
|
||||
<div class="card-title">客户端版本分布 <span class="sub">按设备数 · 最新版高亮</span></div>
|
||||
<div class="ver" v-for="v in versions" :key="v.client_version || '(empty)'">
|
||||
<div class="vhead">
|
||||
<span class="vtag mono" :class="{ latest: v.latest }">{{ v.client_version || '未上报' }}</span>
|
||||
<em>{{ v.count }} 台 · {{ pct(v.count) }}%</em>
|
||||
</div>
|
||||
<div class="vbar"><i :class="{ latest: v.latest }" :style="{ width: pct(v.count) + '%' }"></i></div>
|
||||
</div>
|
||||
<div v-if="!(s.by_version || []).length" class="empty">暂无设备上报</div>
|
||||
</div>
|
||||
|
||||
<!-- 按账号 -->
|
||||
<div class="cp-card cp-rise acct-card">
|
||||
<div class="card-title">按账号查看 <span class="sub">账号 × 客户端版本 × 设备数</span></div>
|
||||
<el-table :data="s.by_account || []" size="small">
|
||||
<el-table-column label="姓名 / 账号" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<div class="who">
|
||||
<span class="wname">{{ row.nickname || '(未命名)' }}</span>
|
||||
<span class="mono wacct">{{ row.account || '—' }}</span>
|
||||
<el-tag v-if="row.dept" size="small" effect="plain" type="info">{{ row.dept }}</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="客户端版本" width="180">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="versionType(row.client_version)" size="small" effect="light">{{ row.client_version || '未上报' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="设备数" width="110">
|
||||
<template #default="{ row }"><span class="mono">{{ row.device_count }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="最后在线" min-width="150">
|
||||
<template #default="{ row }"><span class="mono dim-sm">{{ fmtTime(row.last_seen) }}</span></template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<!-- 设备明细 -->
|
||||
<div class="cp-card cp-rise dev-card">
|
||||
<div class="card-title">设备明细 <span class="sub">最近心跳倒序 · 上报后自动更新版本</span></div>
|
||||
<el-table :data="devices" size="small" v-loading="devBusy" :row-key="r => r.device_id">
|
||||
<el-table-column label="设备ID" min-width="150">
|
||||
<template #default="{ row }"><span class="mono">{{ row.device_id }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="账号" width="140">
|
||||
<template #default="{ row }"><span class="mono">{{ row.account || '—' }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="主机名" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.hostname || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="版本" width="130">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="versionType(row.client_version)" size="small" effect="light">{{ row.client_version || '未上报' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="Chrome" width="90">
|
||||
<template #default="{ row }"><span :style="{ color: row.chrome_ok ? '#1d9d5c' : '#d6453d' }">{{ row.chrome_ok ? '✔ 就绪' : '✘ 异常' }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="最后在线" width="150">
|
||||
<template #default="{ row }"><span class="mono dim-sm">{{ fmtTime(row.last_seen) }}</span></template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<PagerBar :total="devTotal" :page="page" :page-size="pageSize" @change="onPageChange" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-skeleton v-else-if="busy" animated :rows="5" style="margin-top: 20px" />
|
||||
<div v-else class="empty-tip cp-card cp-rise">加载失败或暂无数据</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { Refresh, Monitor, SuccessFilled, WarningFilled, QuestionFilled } from '@element-plus/icons-vue'
|
||||
import { ElMessage as message } from 'element-plus'
|
||||
import { adminDevicesSummary, adminDevices } from '../api'
|
||||
import { fmtTime } from '../format'
|
||||
import PagerBar from '../components/PagerBar.vue'
|
||||
import { usePagedList } from '../composables/usePagedList'
|
||||
|
||||
const busy = ref(false)
|
||||
const s = ref(null)
|
||||
|
||||
const deviceList = usePagedList((p, s) => adminDevices(p, s), { onError: e => message.error('读取失败:' + (e.message || e)) })
|
||||
const { items: devices, total: devTotal, page, size: pageSize, busy: devBusy, load: loadDevices, onPageChange } = deviceList
|
||||
|
||||
// 版本号比较:按 . 分段数值比较
|
||||
function cmpVersion(a, b) {
|
||||
const pa = (a || '').split('.').map(x => parseInt(x, 10) || 0)
|
||||
const pb = (b || '').split('.').map(x => parseInt(x, 10) || 0)
|
||||
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
||||
const d = (pa[i] || 0) - (pb[i] || 0)
|
||||
if (d) return d
|
||||
}
|
||||
return 0
|
||||
}
|
||||
const latestVersion = computed(() => {
|
||||
const vs = (s.value?.by_version || []).map(v => v.client_version || '').filter(Boolean)
|
||||
if (!vs.length) return ''
|
||||
return vs.reduce((a, b) => (cmpVersion(a, b) >= 0 ? a : b))
|
||||
})
|
||||
const versions = computed(() =>
|
||||
(s.value?.by_version || []).map(v => ({
|
||||
...v,
|
||||
latest: !!v.client_version && cmpVersion(v.client_version, latestVersion.value) === 0,
|
||||
})))
|
||||
|
||||
const kpis = computed(() => {
|
||||
const total = s.value?.total || 0
|
||||
const vs = versions.value
|
||||
const latest = vs.filter(v => v.latest).reduce((n, v) => n + v.count, 0)
|
||||
const empty = vs.filter(v => !v.client_version).reduce((n, v) => n + v.count, 0)
|
||||
const old = Math.max(0, total - latest - empty)
|
||||
return [
|
||||
{ label: '总设备数', value: total, icon: Monitor, color: '#2f5cf0', bg: 'linear-gradient(135deg,#e8edfe,#d7e1fd)' },
|
||||
{ label: `已升级 ${latestVersion.value || ''}`.trim(), value: latest, icon: SuccessFilled, color: '#1d9d5c', bg: 'linear-gradient(135deg,#e5f6ed,#d2efe0)' },
|
||||
{ label: '旧版本', value: old, icon: WarningFilled, color: '#d97706', bg: 'linear-gradient(135deg,#fbf0df,#f6e4c8)' },
|
||||
{ label: '未上报版本', value: empty, icon: QuestionFilled, color: '#7a8398', bg: 'linear-gradient(135deg,#eef0f4,#e3e6ec)' },
|
||||
]
|
||||
})
|
||||
|
||||
function pct(n) {
|
||||
const total = s.value?.total || 0
|
||||
return total ? Math.round((n / total) * 100) : 0
|
||||
}
|
||||
function versionType(v) {
|
||||
if (!v) return 'info'
|
||||
return cmpVersion(v, latestVersion.value) === 0 ? 'success' : 'warning'
|
||||
}
|
||||
|
||||
async function refresh() {
|
||||
busy.value = true
|
||||
try {
|
||||
s.value = await adminDevicesSummary()
|
||||
await loadDevices()
|
||||
} catch (e) { message.error('读取失败:' + (e.message || e)) }
|
||||
finally { busy.value = false }
|
||||
}
|
||||
|
||||
onMounted(refresh)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
|
||||
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
|
||||
.kpi { display: flex; align-items: center; gap: 14px; padding: 18px; }
|
||||
.kpi-ic { width: 42px; height: 42px; border-radius: 13px; flex-shrink: 0; display: grid; place-items: center; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .7); }
|
||||
.kpi-num { font-size: 24px; font-weight: 800; line-height: 1.1; }
|
||||
.kpi-lab { font-size: 12px; color: var(--cp-ink-3); margin-top: 4px; letter-spacing: .3px; }
|
||||
|
||||
.ver-card, .acct-card, .dev-card { padding: 20px; margin-bottom: 18px; }
|
||||
.card-title { margin-bottom: 14px; }
|
||||
.card-title .sub { font-size: 11px; font-weight: 500; color: var(--cp-ink-3); margin-left: 4px; }
|
||||
|
||||
.ver { margin-bottom: 12px; }
|
||||
.ver:last-child { margin-bottom: 0; }
|
||||
.vhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
|
||||
.vtag {
|
||||
display: inline-block; padding: 2px 10px; border-radius: 6px;
|
||||
background: var(--cp-panel-2); color: var(--cp-ink-2); font-size: 12px; font-weight: 700;
|
||||
}
|
||||
.vtag.latest { background: linear-gradient(135deg, var(--cp-blue), var(--cp-teal)); color: #fff; }
|
||||
.vhead em { font-style: normal; font-size: 11.5px; color: var(--cp-ink-3); }
|
||||
.vbar { height: 7px; border-radius: 4px; background: var(--cp-panel-2); overflow: hidden; }
|
||||
.vbar i { display: block; height: 100%; background: var(--cp-panel); border-radius: 4px; transition: width .6s cubic-bezier(.22, .61, .36, 1); }
|
||||
.vbar i.latest { background: linear-gradient(90deg, var(--cp-blue), var(--cp-teal)); }
|
||||
.empty { color: var(--cp-ink-3); font-size: 12px; text-align: center; padding: 18px 0; }
|
||||
.empty-tip { padding: 40px; text-align: center; color: var(--cp-ink-3); }
|
||||
.dim-sm { color: var(--cp-ink-2); font-size: 12px; }
|
||||
.who { display: flex; align-items: center; gap: 8px; }
|
||||
.wname { font-weight: 700; color: var(--cp-ink-1); }
|
||||
.wacct { font-size: 12px; color: var(--cp-ink-3); }
|
||||
</style>
|
||||
@@ -16,6 +16,7 @@ const tasks = require("./tasks");
|
||||
const shellUpdater = require("./shell-updater");
|
||||
const chromeManager = require("./chrome-manager");
|
||||
const envSync = require("./env-sync");
|
||||
const notifier = require("./notifier");
|
||||
const { HUB } = require("./hub");
|
||||
const { makeLogger, setLogFile } = require("./logger");
|
||||
|
||||
@@ -151,6 +152,14 @@ async function init(options = {}) {
|
||||
void reportDevice(account)
|
||||
.then(() => logger.info("设备环境上报完成"))
|
||||
.catch(() => {});
|
||||
|
||||
// 通知推送:启动即拉取 + 每 10 分钟轮询(管理端下发的插件/客户端更新等通知)
|
||||
try {
|
||||
notifier.start();
|
||||
logger.info("通知推送已启动(10 分钟轮询)");
|
||||
} catch (e) {
|
||||
logger.warning(`通知推送启动失败:${e.message}`);
|
||||
}
|
||||
} else {
|
||||
logger.info("未配置中心机地址(CONTROLPLANE_URL),进入离线本地模式");
|
||||
state.setAllowed(new Set());
|
||||
|
||||
@@ -273,6 +273,8 @@ async function deviceReport(deviceId, account, info) {
|
||||
chrome_version: (info && info.chromeVersion) || "",
|
||||
chrome_ok: (info && info.chromeOk) ? 1 : 0,
|
||||
status: 1,
|
||||
// 客户端(壳子)版本号:供中心机按版本追踪升级进度(关旧控制面的依据)
|
||||
client_version: (config.runtimeVersion && config.runtimeVersion()) || "",
|
||||
};
|
||||
try {
|
||||
await cp.request("POST", "/api/device/report", { headers: cp.machineHeaders(), json: payload, timeout: 5 });
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
// 通知推送:WebSocket 实时接收(秒达)+ 60s 轮询兜底;记录已读,不重复弹。
|
||||
"use strict";
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const config = require("./config");
|
||||
const cp = require("./cpclient");
|
||||
const session = require("./session");
|
||||
const { makeLogger } = require("./logger");
|
||||
|
||||
const logger = makeLogger("notifier");
|
||||
|
||||
const SEEN_FILE = path.join(config.APP_DATA, "notification_seen.json");
|
||||
const POLL_INTERVAL = 60 * 1000; // 轮询兜底:60 秒
|
||||
const WS_RETRY_MAX = 60000; // WS 重连退避上限 60s
|
||||
|
||||
function loadSeen() {
|
||||
try {
|
||||
if (fs.existsSync(SEEN_FILE)) {
|
||||
const arr = JSON.parse(fs.readFileSync(SEEN_FILE, "utf-8"));
|
||||
if (Array.isArray(arr)) return new Set(arr.map(Number).filter(Boolean));
|
||||
}
|
||||
} catch (e) {
|
||||
/* 忽略损坏文件 */
|
||||
}
|
||||
return new Set();
|
||||
}
|
||||
|
||||
function saveSeen(set) {
|
||||
try {
|
||||
const arr = [...set].slice(-200);
|
||||
fs.mkdirSync(config.APP_DATA, { recursive: true });
|
||||
fs.writeFileSync(SEEN_FILE, JSON.stringify(arr), "utf-8");
|
||||
} catch (e) {
|
||||
/* 忽略 */
|
||||
}
|
||||
}
|
||||
|
||||
function isElectron() {
|
||||
return !!(process.versions && process.versions.electron);
|
||||
}
|
||||
|
||||
function showNative(title, body, level) {
|
||||
if (!isElectron()) {
|
||||
logger.info(`[通知] ${title}${body ? ":" + body : ""}`);
|
||||
return;
|
||||
}
|
||||
// 优先自定义 toast(白底品牌风,可配色);失败回退系统原生通知
|
||||
try {
|
||||
if (require("./notify-toast").show(title, body, level)) return;
|
||||
} catch (e) {
|
||||
/* 忽略,走回退 */
|
||||
}
|
||||
try {
|
||||
const { Notification } = require("electron");
|
||||
if (!Notification.isSupported()) return;
|
||||
const n = new Notification({
|
||||
title: String(title || "37du 通知").slice(0, 120),
|
||||
body: String(body || "").slice(0, 400),
|
||||
silent: level !== "important",
|
||||
});
|
||||
n.on("click", () => {
|
||||
try { n.close(); } catch (e) { /* 忽略 */ }
|
||||
});
|
||||
n.show();
|
||||
} catch (e) {
|
||||
logger.warning(`系统通知展示失败:${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理单条通知:去重后展示
|
||||
function handleNotification(n) {
|
||||
const id = Number(n && n.id);
|
||||
if (!id) return;
|
||||
const seen = loadSeen();
|
||||
if (seen.has(id)) return;
|
||||
seen.add(id);
|
||||
saveSeen(seen);
|
||||
showNative(n.title || "通知", n.content || "", n.level || "info");
|
||||
}
|
||||
|
||||
// ==================== WebSocket 实时推送 ====================
|
||||
let ws = null;
|
||||
let wsRetry = 0;
|
||||
let wsTimer = null;
|
||||
let wsAccount = "";
|
||||
|
||||
function wsUrl(account) {
|
||||
const base = config.CONTROLPLANE_URL.replace(/^http/i, "ws").replace(/\/+$/, "");
|
||||
return `${base}/ws/notifications?account=${encodeURIComponent(account)}`;
|
||||
}
|
||||
|
||||
function connectWs(account) {
|
||||
if (!config.CONTROLPLANE_URL || !account) return;
|
||||
if (ws && (ws.readyState === 0 || ws.readyState === 1)) return; // CONNECTING / OPEN
|
||||
wsAccount = account;
|
||||
try {
|
||||
const { WebSocket } = require("ws");
|
||||
ws = new WebSocket(wsUrl(account), {
|
||||
headers: cp.machineHeaders(),
|
||||
handshakeTimeout: 8000,
|
||||
});
|
||||
ws.on("open", () => {
|
||||
wsRetry = 0;
|
||||
logger.info(`通知 WebSocket 已连接(${account})`);
|
||||
});
|
||||
ws.on("message", (data) => {
|
||||
try {
|
||||
const msg = JSON.parse(String(data));
|
||||
if (msg.type === "notify" && msg.notification) {
|
||||
handleNotification(msg.notification);
|
||||
}
|
||||
} catch (e) {
|
||||
/* 忽略坏帧 */
|
||||
}
|
||||
});
|
||||
ws.on("ping", () => {
|
||||
try { ws.pong(); } catch (e) { /* 忽略 */ }
|
||||
});
|
||||
ws.on("close", () => { scheduleWsReconnect(wsAccount); });
|
||||
ws.on("error", (e) => { logger.warning(`通知 WS 错误:${e.message}`); });
|
||||
} catch (e) {
|
||||
logger.warning(`通知 WS 连接失败:${e.message}`);
|
||||
scheduleWsReconnect(account);
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleWsReconnect(account) {
|
||||
ws = null;
|
||||
if (wsTimer) { clearTimeout(wsTimer); wsTimer = null; }
|
||||
const delay = Math.min(WS_RETRY_MAX, 5000 * Math.pow(2, Math.min(wsRetry++, 4)));
|
||||
wsTimer = setTimeout(() => connectWs(account), delay);
|
||||
}
|
||||
|
||||
// ==================== 轮询兜底 ====================
|
||||
async function pollOnce() {
|
||||
if (!config.CONTROLPLANE_URL) return;
|
||||
const accts = new Set();
|
||||
try {
|
||||
const set = session.accountSet();
|
||||
if (set && set.size) for (const a of set) accts.add(a);
|
||||
} catch (e) { /* 忽略 */ }
|
||||
const active = config.CONTROLPLANE_ACCOUNT || session.sessActiveAccount();
|
||||
if (active) accts.add(active);
|
||||
if (!accts.size) return;
|
||||
|
||||
for (const account of accts) {
|
||||
try {
|
||||
const r = await cp.request("GET", "/api/notifications", {
|
||||
headers: cp.machineHeaders(),
|
||||
params: { account },
|
||||
timeout: 10,
|
||||
});
|
||||
for (const n of r.notifications || []) handleNotification(n);
|
||||
} catch (e) {
|
||||
logger.warning(`通知拉取失败(${account}):${e.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function start() {
|
||||
const active = config.CONTROLPLANE_ACCOUNT || session.sessActiveAccount();
|
||||
connectWs(active || "");
|
||||
void pollOnce().catch((e) => logger.warning(`通知初始化异常:${e.message}`));
|
||||
setInterval(() => {
|
||||
void pollOnce().catch((e) => logger.warning(`通知周期检查异常:${e.message}`));
|
||||
}, POLL_INTERVAL);
|
||||
}
|
||||
|
||||
module.exports = { start, pollOnce, handleNotification };
|
||||
@@ -0,0 +1,92 @@
|
||||
// 自定义通知弹窗(右下角 toast):无边框、置顶、不抢焦点、按级别配色。
|
||||
// 替代系统原生通知(原生样式跟随 Windows 主题,深色模式下发黑、不可控)。
|
||||
"use strict";
|
||||
|
||||
const { makeLogger } = require("./logger");
|
||||
const logger = makeLogger("notify-toast");
|
||||
|
||||
const W = 380, H = 132, GAP = 10, MARGIN = 16, TTL = 9000;
|
||||
let lastBottom = null;
|
||||
|
||||
function levelColor(level) {
|
||||
return { info: "#2f5cf0", warning: "#d97706", important: "#d6453d" }[level] || "#2f5cf0";
|
||||
}
|
||||
function levelLabel(level) {
|
||||
return { info: "通知", warning: "提醒", important: "重要" }[level] || "通知";
|
||||
}
|
||||
|
||||
function esc(s) {
|
||||
return String(s || "")
|
||||
.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")
|
||||
.replace(/"/g, """);
|
||||
}
|
||||
|
||||
function buildHTML(title, body, level) {
|
||||
const color = levelColor(level);
|
||||
const label = levelLabel(level);
|
||||
return `<!doctype html><html><head><meta charset="utf-8"><style>
|
||||
* { margin:0; padding:0; box-sizing:border-box; font-family:"Segoe UI","Microsoft YaHei",sans-serif; }
|
||||
html,body { background:transparent; }
|
||||
.toast {
|
||||
position:fixed; inset:0; border-radius:14px; overflow:hidden;
|
||||
background:#fff; border:1px solid #e6eaf2;
|
||||
box-shadow:0 12px 32px -14px rgba(20,26,40,.45);
|
||||
display:flex; flex-direction:column;
|
||||
animation: in .28s ease;
|
||||
}
|
||||
@keyframes in { from { transform:translateY(14px); opacity:0 } to { transform:none; opacity:1 } }
|
||||
.bar { padding:9px 12px 2px; display:flex; align-items:center; gap:8px; }
|
||||
.logo { width:20px;height:20px;border-radius:6px;background:linear-gradient(135deg,#2f5cf0,#0f9f9b);
|
||||
color:#fff;font-size:11px;font-weight:800;display:flex;align-items:center;justify-content:center; }
|
||||
.lvl { font-size:11px;font-weight:700;color:${color};letter-spacing:.3px; }
|
||||
.close { margin-left:auto;cursor:pointer;color:#9aa2b4;font-size:14px;line-height:1;padding:2px 5px; }
|
||||
.close:hover { color:#4a5468; }
|
||||
.ttl { padding:0 14px; font-size:14px;font-weight:700;color:#232a3a; }
|
||||
.bdy { padding:4px 14px 12px; font-size:12.5px;color:#3b4358;line-height:1.45;
|
||||
overflow:hidden; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
|
||||
</style></head><body>
|
||||
<div class="toast">
|
||||
<div class="bar">
|
||||
<span class="logo">37</span>
|
||||
<span class="lvl">${label}</span>
|
||||
<span class="close" onclick="window.close()">✕</span>
|
||||
</div>
|
||||
<div class="ttl">${esc(title)}</div>
|
||||
<div class="bdy">${esc(body)}</div>
|
||||
</div>
|
||||
</body></html>`;
|
||||
}
|
||||
|
||||
function show(title, body, level) {
|
||||
try {
|
||||
const { BrowserWindow, screen } = require("electron");
|
||||
const display = screen.getPrimaryDisplay();
|
||||
const wa = display.workArea;
|
||||
const x = wa.x + wa.width - W - MARGIN;
|
||||
if (lastBottom === null) lastBottom = wa.y + wa.height - H - MARGIN;
|
||||
const y = lastBottom;
|
||||
lastBottom = lastBottom - H - GAP;
|
||||
if (lastBottom < wa.y + MARGIN) lastBottom = null; // 满屏后下一轮回到底部
|
||||
|
||||
const win = new BrowserWindow({
|
||||
width: W, height: H, x, y,
|
||||
frame: false, transparent: true, resizable: false, movable: false,
|
||||
alwaysOnTop: true, skipTaskbar: true, hasShadow: false, show: false, focusable: false,
|
||||
backgroundColor: "#00000000",
|
||||
webPreferences: { contextIsolation: true, nodeIntegration: false, sandbox: true },
|
||||
});
|
||||
win.setAlwaysOnTop(true, "pop-up-menu");
|
||||
win.loadURL("data:text/html;charset=utf-8," + encodeURIComponent(buildHTML(title, body, level)));
|
||||
win.once("ready-to-show", () => {
|
||||
try { win.showInactive(); } catch (e) { win.show(); }
|
||||
});
|
||||
const t = setTimeout(() => { try { win.destroy(); } catch (e) { /* 忽略 */ } }, TTL);
|
||||
win.on("closed", () => { clearTimeout(t); });
|
||||
return true;
|
||||
} catch (e) {
|
||||
logger.warning(`自定义通知弹窗失败:${e.message}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { show };
|
||||
@@ -164,6 +164,35 @@ function loginStateTake(s) {
|
||||
return !!exp && exp >= Date.now();
|
||||
}
|
||||
|
||||
// ==================== 离线自动登录(断网 / 服务端不可达时的 7 天离线授权入口) ====================
|
||||
// 服务端探活:用 /api/me/pubkey(无鉴权)判断控制面是否可达
|
||||
async function serverReachable() {
|
||||
try {
|
||||
await cp.request("GET", "/api/me/pubkey", { headers: cp.machineHeaders(), timeout: 4 });
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 无会话且服务端不可达时:若存在有效(未过期、验签通过)离线授权票据,为该账号建立本地会话。
|
||||
// 这样断网/服务端宕机期间,授权期内的用户仍能进入工作台并运行已授权插件(最长离线 7 天)。
|
||||
function tryOfflineSession(res) {
|
||||
try {
|
||||
const st = licensing.licenseStatus();
|
||||
if (st.status === "ok" && st.payload && st.payload.userId) {
|
||||
const acct = st.payload.userId;
|
||||
const token = session.establishSession(acct, "");
|
||||
setSessionCookie(res, token);
|
||||
logger.info(`离线授权自动登录:${acct}(服务端不可达,离线模式,最长 7 天)`);
|
||||
return acct;
|
||||
}
|
||||
} catch (e) {
|
||||
/* 忽略:票据缺失/无效/过期时不自动登录 */
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// ==================== 业务组装 ====================
|
||||
async function dingtalkEstablish(account, nickname, dingtalkUid, res) {
|
||||
if (!account) throw Object.assign(new Error("工号不能为空"), { status: 400 });
|
||||
@@ -211,15 +240,20 @@ async function route(req, res, url) {
|
||||
|
||||
// ---------- 认证 / 会话 ----------
|
||||
if (p === "/api/admin/me" && method === "GET") {
|
||||
const account = session.sessAccount(cookies);
|
||||
let account = session.sessAccount(cookies);
|
||||
// 无会话时先探测服务端:可达走正常登录;不可达且存在有效离线授权票据(最长 7 天)时自动登录
|
||||
const reachable = account ? true : await serverReachable();
|
||||
if (!account && !reachable) account = tryOfflineSession(res);
|
||||
if (!account) {
|
||||
return sendJson(res, 200, { account: "", is_admin: false, dept: "", nickname: "", avatar: "" });
|
||||
}
|
||||
try {
|
||||
const r = await cp.request("GET", "/api/admin/me", { headers: session.cpHeaders(cookies), timeout: 10 });
|
||||
if (r.account === account) return sendJson(res, 200, r);
|
||||
} catch (e) {
|
||||
/* 云端不可达降级 */
|
||||
if (reachable) {
|
||||
try {
|
||||
const r = await cp.request("GET", "/api/admin/me", { headers: session.cpHeaders(cookies), timeout: 10 });
|
||||
if (r.account === account) return sendJson(res, 200, r);
|
||||
} catch (e) {
|
||||
/* 云端不可达降级 */
|
||||
}
|
||||
}
|
||||
return sendJson(res, 200, { account, is_admin: false, dept: "", nickname: "", avatar: "" });
|
||||
}
|
||||
@@ -252,6 +286,24 @@ async function route(req, res, url) {
|
||||
return sendJson(res, 200, { ok: true });
|
||||
}
|
||||
|
||||
// 离线登录:不依赖网络,仅校验本地 7 天离线授权票据(验签 + 未过期),消费票据直接进入工作台
|
||||
if (p === "/api/admin/offline-login" && method === "POST") {
|
||||
const st = licensing.licenseStatus();
|
||||
if (st.status !== "ok" || !st.payload || !st.payload.userId) {
|
||||
const reason =
|
||||
st.status === "missing" ? "本机无离线授权票据,请先联网登录一次以获取 7 天离线授权"
|
||||
: st.status === "expired" ? "离线授权已过期(最长离线 7 天),请联网刷新后重试"
|
||||
: st.status === "invalid" ? "离线授权票据无效,请联网重新登录"
|
||||
: "离线登录不可用,请联网登录";
|
||||
return sendJson(res, 403, { detail: reason });
|
||||
}
|
||||
const acct = st.payload.userId;
|
||||
const token = session.establishSession(acct, "");
|
||||
setSessionCookie(res, token);
|
||||
logger.info(`离线登录成功:${acct}(消费本地 7 天授权票据)`);
|
||||
return sendJson(res, 200, { ok: true, account: acct, offline: true });
|
||||
}
|
||||
|
||||
if (p === "/api/admin/password" && method === "POST") {
|
||||
const body = await readJsonBody(req);
|
||||
const r = await cp.request("POST", "/api/admin/password", {
|
||||
|
||||
@@ -353,6 +353,8 @@ const licenseCls = computed(() => {
|
||||
let wsRetryCount = 0
|
||||
let wsRetryTimer = null
|
||||
function openWS() {
|
||||
// 主动新建连接时,取消上一次待执行的重连(防止新旧连接交替触发 onclose 形成重连死循环)
|
||||
if (wsRetryTimer) { clearTimeout(wsRetryTimer); wsRetryTimer = null }
|
||||
if (window.__ws) { try { window.__ws.close() } catch (_) {} }
|
||||
const ws = connectWS((ev) => {
|
||||
handleEvent(ev)
|
||||
@@ -365,6 +367,8 @@ function openWS() {
|
||||
store.wsOn = false
|
||||
// 未登录被拒(1008)时静默,避免死循环
|
||||
if (!store.current) return
|
||||
// 仅当仍是当前连接时才重连:被 openWS 主动替换/关闭的旧连接不再触发(否则无限闪烁)
|
||||
if (window.__ws !== ws) return
|
||||
if (wsRetryCount >= 5) return // 连续 5 次失败:停止,状态栏保持"本地服务重连中"
|
||||
wsRetryCount++
|
||||
// 指数退避重连(1/2/4/8/16s 封顶),不再整页 reload(避免反复走启动引导)
|
||||
|
||||
@@ -171,6 +171,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 }) })
|
||||
}
|
||||
// 离线登录:凭本机 7 天离线授权票据直接进入(不依赖网络/服务端)
|
||||
export async function adminOfflineLogin() {
|
||||
return j('/api/admin/offline-login', { method: 'POST' })
|
||||
}
|
||||
// v3 钉钉直连接登录:生成钉钉授权 URL(redirect_uri=本机 /auth/done),前端当前窗口跳转到该 URL
|
||||
export async function authDingtalk() {
|
||||
return j('/api/auth/dingtalk')
|
||||
|
||||
@@ -53,6 +53,12 @@
|
||||
<el-button size="large" class="dingtalk" :loading="dingBusy" :icon="ChatDotRound" @click="openDing">
|
||||
钉钉扫码接入
|
||||
</el-button>
|
||||
|
||||
<div class="offline-row">
|
||||
<el-button link type="primary" size="small" :loading="offlineBusy" @click="doOffline">
|
||||
离线登录(凭本机 7 天授权票据进入)
|
||||
</el-button>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- 底部:流程状态 -->
|
||||
@@ -72,7 +78,7 @@
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ChatDotRound } from '@element-plus/icons-vue'
|
||||
import { adminLogin, authDingtalk } from '../api'
|
||||
import { adminLogin, adminOfflineLogin, authDingtalk } from '../api'
|
||||
|
||||
defineProps({ appName: { type: String, default: '' } })
|
||||
const emit = defineEmits(['ok'])
|
||||
@@ -91,6 +97,28 @@ const account = ref('')
|
||||
const password = ref('')
|
||||
const busy = ref(false)
|
||||
const dingBusy = ref(false)
|
||||
const offlineBusy = ref(false)
|
||||
|
||||
// 离线登录:不依赖网络,凭本机 7 天离线授权票据直接进入工作台
|
||||
async function doOffline() {
|
||||
if (offlineBusy.value) return
|
||||
offlineBusy.value = true
|
||||
try {
|
||||
const r = await adminOfflineLogin()
|
||||
ElMessage.success('已离线登录:' + (r.account || ''))
|
||||
emit('ok', {
|
||||
account: r.account || '',
|
||||
dept: '',
|
||||
must_change_pwd: false,
|
||||
nickname: r.nickname || '',
|
||||
avatar: ''
|
||||
})
|
||||
} catch (e) {
|
||||
ElMessage.error('离线登录失败:' + (e.message || e))
|
||||
} finally {
|
||||
offlineBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function doLogin() {
|
||||
if (busy.value) return
|
||||
@@ -307,7 +335,7 @@ async function openDing() {
|
||||
cursor: pointer;
|
||||
transition: all .18s ease;
|
||||
}
|
||||
.doodle-toggle:hover { transform: translateY(-1px) rotate(8deg); box-shadow: 0 4px 10px -4px rgba(var(--primary-rgb), .5); border-color: var(--primary-line); }
|
||||
.doodle-toggle:hover { transform: rotate(8deg); box-shadow: 0 4px 10px -4px rgba(var(--primary-rgb), .5); border-color: var(--primary-line); }
|
||||
.doodle-toggle.off { color: var(--text-disabled); }
|
||||
.doodle-toggle.off:hover { color: var(--primary); border-color: var(--primary-line); }
|
||||
|
||||
@@ -503,7 +531,6 @@ async function openDing() {
|
||||
.primary.el-button:focus {
|
||||
background: var(--primary-hover);
|
||||
color: var(--on-primary);
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 15px 30px -14px rgba(var(--primary-rgb), .85);
|
||||
}
|
||||
|
||||
@@ -558,7 +585,6 @@ async function openDing() {
|
||||
color: var(--primary-strong);
|
||||
border-color: var(--primary-line);
|
||||
background: var(--primary-tint);
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 10px 22px -14px rgba(var(--primary-rgb), .55);
|
||||
}
|
||||
|
||||
@@ -569,6 +595,12 @@ async function openDing() {
|
||||
|
||||
.dingtalk.el-button :deep(.el-icon) { color: var(--primary); }
|
||||
|
||||
/* ---------- 离线登录入口 ---------- */
|
||||
.offline-row {
|
||||
margin-top: 18px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* ---------- 键盘可达 ---------- */
|
||||
.primary.el-button:focus-visible,
|
||||
.dingtalk.el-button:focus-visible {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "37du-electron-shell",
|
||||
"productName": "37du 自动化工作台",
|
||||
"version": "1.0.9",
|
||||
"version": "1.6.1",
|
||||
"description": "37du 执行机 Node/Electron 客户端(替代 Python webhost 底座,插件保持 Python 子进程执行)",
|
||||
"main": "electron/main.js",
|
||||
"private": true,
|
||||
|
||||
@@ -7,270 +7,208 @@
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body {
|
||||
font-family: "Comic Sans MS", "Comic Neue", "Segoe Print", "Marker Felt", "Bradley Hand", cursive;
|
||||
background-color: #fffdf3;
|
||||
background-image:
|
||||
repeating-linear-gradient(transparent 0 31px, rgba(120, 150, 210, .15) 31px 32px),
|
||||
url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='120' height='120' filter='url(%23n)' opacity='0.035'/></svg>");
|
||||
color: #2b2b2b; font-size: 15px; min-height: 100vh;
|
||||
font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
|
||||
background: #f5f7fa; color: #232a3a; font-size: 14px;
|
||||
}
|
||||
::selection { background: #ffe066; color: #2b2b2b; }
|
||||
::selection { background: #dbe6ff; color: #232a3a; }
|
||||
|
||||
/* ===== 手绘通用 ===== */
|
||||
.hand { border: 2.5px solid #2b2b2b; border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px; }
|
||||
.squiggle {
|
||||
display: inline-block; height: 7px; margin-top: 3px;
|
||||
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='7'><path d='M0 3 Q 10 0, 20 3 T 40 3 T 60 3 T 80 3 T 100 3 T 120 3 T 140 3' stroke='%23e8590c' stroke-width='2.6' fill='none' stroke-linecap='round'/></svg>");
|
||||
background-repeat: no-repeat; background-size: 100% 100%;
|
||||
}
|
||||
.pin { position: absolute; font-size: 20px; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); }
|
||||
.tape {
|
||||
position: absolute; width: 92px; height: 26px; z-index: 2;
|
||||
background: rgba(255, 224, 130, .62);
|
||||
border-left: 2px dashed rgba(0,0,0,.18);
|
||||
border-right: 2px dashed rgba(0,0,0,.18);
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,.12);
|
||||
}
|
||||
|
||||
/* ===== 登录页 ===== */
|
||||
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
|
||||
.login-card {
|
||||
position: relative; width: 410px; background: #fffef8;
|
||||
border: 2.5px solid #2b2b2b;
|
||||
border-radius: 15px 255px 15px 255px / 255px 15px 255px 15px;
|
||||
box-shadow: 5px 7px 0 rgba(0,0,0,.12);
|
||||
padding: 44px 38px 36px; transform: rotate(-.6deg);
|
||||
}
|
||||
.login-card .tape { top: -14px; left: 50%; margin-left: -46px; transform: rotate(-3deg); }
|
||||
.login-card .pin { top: -12px; right: 22px; transform: rotate(12deg); }
|
||||
.login-card .emblem {
|
||||
width: 58px; height: 58px; border-radius: 50%;
|
||||
background: #fff; border: 3px solid #2b2b2b;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
font-weight: 800; font-size: 24px; color: #e8590c;
|
||||
transform: rotate(-7deg); box-shadow: 2px 3px 0 rgba(0,0,0,.14);
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.login-card h2 { font-size: 27px; font-weight: 800; letter-spacing: .5px; }
|
||||
.login-card .login-sub { font-size: 13px; color: #868e96; font-weight: 700; margin: 4px 0 20px; }
|
||||
.login-field { position: relative; margin-bottom: 13px; }
|
||||
.login-field input {
|
||||
width: 100%; padding: 11px 44px 11px 14px;
|
||||
border: 2.5px solid #2b2b2b;
|
||||
border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
|
||||
font-family: inherit; font-size: 15px; font-weight: 600; outline: none;
|
||||
background: #fff;
|
||||
}
|
||||
.login-field input:focus { background: #fff9db; }
|
||||
.eye { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); cursor: pointer; font-size: 17px; user-select: none; }
|
||||
.login-card .btn { width: 100%; padding: 12px; font-size: 16px; margin-top: 4px; }
|
||||
.login-hint { margin-top: 14px; font-size: 12.5px; color: #868e96; font-weight: 700; }
|
||||
.login-msg {
|
||||
margin-top: 12px; background: #ffe3e3; color: #c92a2a;
|
||||
padding: 10px 12px; font-weight: 700; font-size: 13px;
|
||||
border: 2.5px dashed #c92a2a; border-radius: 15px 255px 15px 255px / 255px 15px 255px 15px;
|
||||
}
|
||||
|
||||
/* ===== 顶栏(便签条)===== */
|
||||
/* ===== 顶栏 ===== */
|
||||
.header {
|
||||
position: relative; background: #ffe066;
|
||||
border-bottom: 3px solid #2b2b2b;
|
||||
padding: 16px 30px;
|
||||
background: #fff; border-bottom: 1px solid #e8ecf1;
|
||||
padding: 12px 24px;
|
||||
display: flex; align-items: center; justify-content: space-between; gap: 16px;
|
||||
transform: rotate(-.35deg); margin: 0 -4px;
|
||||
box-shadow: 0 2px 8px -6px rgba(35, 42, 58, .25);
|
||||
}
|
||||
.header .pin.l { top: 6px; left: 14px; transform: rotate(-14deg); }
|
||||
.header .pin.r { top: 6px; right: 200px; transform: rotate(10deg); }
|
||||
.header .brand { display: flex; align-items: center; gap: 14px; }
|
||||
.header .brand { display: flex; align-items: center; gap: 12px; }
|
||||
.header .emblem {
|
||||
width: 48px; height: 48px; border-radius: 50%;
|
||||
background: #fff; border: 3px solid #2b2b2b;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
font-weight: 800; font-size: 21px; color: #e8590c;
|
||||
transform: rotate(-6deg); box-shadow: 2px 3px 0 rgba(0,0,0,.14);
|
||||
width: 38px; height: 38px; border-radius: 8px;
|
||||
display: grid; place-items: center;
|
||||
background: linear-gradient(135deg, #2f5cf0 0%, #0f9f9b 140%);
|
||||
color: #fff; font-size: 15px; font-weight: 800;
|
||||
box-shadow: 0 6px 14px -6px rgba(47, 92, 240, .5);
|
||||
}
|
||||
.header h1 { font-size: 23px; font-weight: 800; line-height: 1.1; }
|
||||
.header h1 .squiggle { width: 150px; }
|
||||
.header .sub { font-size: 12.5px; color: #5c5c5c; font-weight: 700; margin-top: 2px; }
|
||||
.header .actions { display: flex; gap: 10px; flex-wrap: wrap; }
|
||||
.header h1 { font-size: 17px; font-weight: 700; line-height: 1.2; }
|
||||
.header .sub { font-size: 12px; color: #8a93a6; margin-top: 1px; }
|
||||
.header .actions { display: flex; gap: 8px; flex-wrap: wrap; }
|
||||
|
||||
/* ===== 统计条 ===== */
|
||||
.stats {
|
||||
display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px;
|
||||
padding: 22px 30px 18px;
|
||||
display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
|
||||
padding: 18px 24px 8px;
|
||||
}
|
||||
.stat {
|
||||
position: relative; background: #fffef8; padding: 12px 16px 13px;
|
||||
border: 2.5px solid #2b2b2b;
|
||||
border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
|
||||
box-shadow: 3px 5px 0 rgba(0,0,0,.1);
|
||||
transition: transform .18s ease, box-shadow .18s ease;
|
||||
background: #fff; border: 1px solid #e8ecf1; border-radius: 10px;
|
||||
padding: 14px 18px; border-left: 4px solid #2f5cf0;
|
||||
box-shadow: 0 2px 8px -6px rgba(35, 42, 58, .2);
|
||||
}
|
||||
.stat:nth-child(odd) { transform: rotate(-1.2deg); }
|
||||
.stat:nth-child(even) { transform: rotate(1deg); }
|
||||
.stat:hover { transform: rotate(0) translateY(-3px); box-shadow: 5px 8px 0 rgba(0,0,0,.14); }
|
||||
.stat .tape { top: -11px; left: 50%; margin-left: -46px; transform: rotate(-2deg); width: 74px; height: 22px; }
|
||||
.stat .k { font-size: 12.5px; font-weight: 700; color: #868e96; letter-spacing: .5px; }
|
||||
.stat .v { font-size: 23px; font-weight: 800; margin-top: 3px; color: #2b2b2b; }
|
||||
.stat:nth-child(1) .v { color: #e8590c; }
|
||||
.stat:nth-child(2) .v { color: #1971c2; }
|
||||
.stat:nth-child(3) .v { color: #2f9e44; }
|
||||
.stat:nth-child(4) .v { color: #9c36b5; }
|
||||
.stat:nth-child(2) { border-left-color: #0f9f9b; }
|
||||
.stat:nth-child(3) { border-left-color: #1d9d5c; }
|
||||
.stat:nth-child(4) { border-left-color: #d97706; }
|
||||
.stat .k { font-size: 12px; color: #8a93a6; }
|
||||
.stat .v { font-size: 24px; font-weight: 700; margin-top: 3px; color: #232a3a; }
|
||||
|
||||
/* ===== 工具栏 ===== */
|
||||
.toolbar {
|
||||
display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
|
||||
padding: 8px 30px 18px;
|
||||
display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
|
||||
padding: 10px 24px 16px;
|
||||
}
|
||||
.toolbar input[type="text"] {
|
||||
padding: 9px 14px; border: 2.5px solid #2b2b2b;
|
||||
border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
|
||||
font-family: inherit; font-size: 14px; font-weight: 600; outline: none;
|
||||
width: 280px; background: #fff;
|
||||
padding: 8px 12px; border: 1px solid #d9dee7; border-radius: 6px;
|
||||
font-family: inherit; font-size: 14px; outline: none;
|
||||
width: 280px; background: #fff; transition: border-color .15s, box-shadow .15s;
|
||||
}
|
||||
.toolbar input[type="text"]:focus { background: #fff9db; }
|
||||
.toolbar .hint { color: #868e96; font-size: 12.5px; font-weight: 700; }
|
||||
.toolbar input[type="text"]:focus { border-color: #2f5cf0; box-shadow: 0 0 0 3px rgba(47, 92, 240, .12); }
|
||||
.toolbar .hint { color: #8a93a6; font-size: 12px; }
|
||||
|
||||
/* ===== 按钮(标记笔)===== */
|
||||
/* ===== 按钮 ===== */
|
||||
.btn {
|
||||
font-family: inherit; font-weight: 700; font-size: 14.5px;
|
||||
border: 2.5px solid #2b2b2b;
|
||||
border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
|
||||
background: #fff; color: #2b2b2b;
|
||||
padding: 9px 18px; cursor: pointer;
|
||||
box-shadow: 2px 3px 0 rgba(0,0,0,.14);
|
||||
transition: transform .12s ease, background .12s ease;
|
||||
font-family: inherit; font-size: 14px;
|
||||
border: 1px solid #d9dee7; border-radius: 6px;
|
||||
background: #fff; color: #3b4358;
|
||||
padding: 8px 16px; cursor: pointer;
|
||||
transition: all .15s;
|
||||
user-select: none;
|
||||
}
|
||||
.btn:hover { transform: rotate(-1.6deg) scale(1.04); }
|
||||
.btn:active { transform: rotate(0) translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.14); }
|
||||
.btn-primary { background: #ffe066; }
|
||||
.btn-primary:hover { background: #ffd43b; }
|
||||
.btn-success { background: #b2f2bb; }
|
||||
.btn-success:hover { background: #8ce99a; }
|
||||
.btn:hover { border-color: #2f5cf0; color: #2f5cf0; background: #f5f8ff; }
|
||||
.btn:active { transform: translateY(1px); }
|
||||
.btn-primary { background: #2f5cf0; border-color: #2f5cf0; color: #fff; }
|
||||
.btn-primary:hover { background: #2246c0; border-color: #2246c0; color: #fff; }
|
||||
.btn-success { background: #1d9d5c; border-color: #1d9d5c; color: #fff; }
|
||||
.btn-success:hover { background: #178048; border-color: #178048; color: #fff; }
|
||||
.btn:disabled { opacity: .5; cursor: not-allowed; }
|
||||
.upload-btn input[type="file"] { display: none; }
|
||||
.tag {
|
||||
display: inline-block; padding: 6px 12px;
|
||||
border: 2.5px solid #2b2b2b;
|
||||
border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
|
||||
font-size: 13px; font-weight: 700; background: #ffd8a8; color: #2b2b2b;
|
||||
transform: rotate(-1deg); box-shadow: 2px 3px 0 rgba(0,0,0,.1);
|
||||
display: inline-block; padding: 4px 10px; border-radius: 4px;
|
||||
font-size: 12px; font-weight: 600; background: #e8f0ff; color: #2f5cf0;
|
||||
border: 1px solid #c9d9ff;
|
||||
}
|
||||
|
||||
/* ===== 状态条(标记笔高亮)===== */
|
||||
.status-bar { display: none; padding: 11px 30px; font-weight: 700; font-size: 14px; }
|
||||
.status-bar.ok { display: block; background: #fff3bf; color: #2b2b2b; border-bottom: 2.5px dashed #f59f00; }
|
||||
.status-bar.err { display: block; background: #ffe3e3; color: #c92a2a; border-bottom: 2.5px dashed #e03131; }
|
||||
/* ===== 状态条 ===== */
|
||||
.status-bar { display: none; padding: 10px 24px; font-size: 13px; }
|
||||
.status-bar.ok { display: block; background: #e6f7ee; color: #1d9d5c; border-bottom: 1px solid #bfe8d2; }
|
||||
.status-bar.err { display: block; background: #fdeeee; color: #d6453d; border-bottom: 1px solid #f5c6c2; }
|
||||
|
||||
.main { padding: 8px 30px 30px; }
|
||||
.main { padding: 6px 24px 26px; }
|
||||
|
||||
/* ===== 主卡片(纸页 + 折角)===== */
|
||||
/* ===== 加载中 ===== */
|
||||
.loading { padding: 70px; text-align: center; font-size: 15px; color: #8a93a6; }
|
||||
|
||||
/* ===== 主卡片 ===== */
|
||||
.card {
|
||||
position: relative; background: #fffef8;
|
||||
border: 2.5px solid #2b2b2b;
|
||||
border-radius: 15px 255px 15px 255px / 255px 15px 255px 15px;
|
||||
box-shadow: 5px 7px 0 rgba(0,0,0,.1);
|
||||
transform: rotate(.2deg);
|
||||
}
|
||||
.card > .tape { top: -13px; left: 50%; margin-left: -46px; transform: rotate(-3deg); }
|
||||
.card::after {
|
||||
content: ""; position: absolute; top: 0; right: 0;
|
||||
width: 0; height: 0;
|
||||
border-style: solid;
|
||||
border-width: 0 0 30px 30px;
|
||||
border-color: transparent transparent #ffe066 transparent;
|
||||
filter: drop-shadow(-2px 2px 1px rgba(0,0,0,.08));
|
||||
}
|
||||
|
||||
/* ===== 加载中(翻本子)===== */
|
||||
.loading {
|
||||
padding: 70px; text-align: center; font-weight: 800; font-size: 18px; color: #495057;
|
||||
}
|
||||
.loading .pen { display: inline-block; animation: pen 1.1s ease-in-out infinite; }
|
||||
@keyframes pen {
|
||||
0%, 100% { transform: rotate(-8deg) translateY(0); }
|
||||
50% { transform: rotate(10deg) translateY(-6px); }
|
||||
background: #fff; border: 1px solid #e8ecf1; border-radius: 10px;
|
||||
box-shadow: 0 2px 8px -6px rgba(35, 42, 58, .2);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* ===== 表格 ===== */
|
||||
table { width: 100%; border-collapse: collapse; }
|
||||
th {
|
||||
background: #fff3bf; color: #2b2b2b; text-align: left; cursor: pointer; user-select: none;
|
||||
padding: 11px 14px; font-weight: 800; letter-spacing: .3px;
|
||||
border-bottom: 3px solid #2b2b2b; font-size: 14px; white-space: nowrap;
|
||||
background: #f7f9fc; color: #4a5468; text-align: left; cursor: pointer; user-select: none;
|
||||
padding: 11px 14px; font-weight: 600; letter-spacing: .2px;
|
||||
border-bottom: 1px solid #e8ecf1; font-size: 13px; white-space: nowrap;
|
||||
}
|
||||
th .arrow { color: #e8590c; margin-left: 3px; }
|
||||
td { padding: 11px 14px; border-bottom: 2px dashed #ced4da; font-weight: 600; vertical-align: middle; }
|
||||
th .arrow { color: #2f5cf0; margin-left: 3px; }
|
||||
td { padding: 11px 14px; border-bottom: 1px solid #f0f2f6; font-weight: 400; vertical-align: middle; }
|
||||
tr:last-child td { border-bottom: none; }
|
||||
tbody tr:hover td { background: #ffecb3; }
|
||||
.fname-cell { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
|
||||
.filename { font-weight: 800; word-break: break-all; }
|
||||
.fname-meta { display: flex; gap: 8px; align-items: center; }
|
||||
tbody tr:hover td { background: #f5f8ff; }
|
||||
/* 文件名列:限宽 + 超长省略号 */
|
||||
.fname-col { min-width: 220px; max-width: 420px; width: 34%; }
|
||||
.fname-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; overflow: hidden; }
|
||||
.filename { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.fname-meta { display: flex; gap: 8px; align-items: center; min-width: 0; }
|
||||
.ext {
|
||||
display: inline-block; padding: 1px 8px;
|
||||
border: 2px solid #2b2b2b; border-radius: 50%;
|
||||
background: #d0ebff; font-size: 10px; font-weight: 800; color: #1971c2;
|
||||
transform: rotate(-4deg);
|
||||
display: inline-block; padding: 1px 7px; flex-shrink: 0;
|
||||
border: 1px solid #c9d9ff; border-radius: 4px;
|
||||
background: #e8f0ff; font-size: 10px; font-weight: 700; color: #2f5cf0;
|
||||
}
|
||||
.sha { font-family: "Courier New", Consolas, monospace; color: #868e96; font-size: 11.5px; cursor: help; font-weight: 700; }
|
||||
tbody tr:hover .sha { color: #2b2b2b; }
|
||||
.empty { padding: 46px 20px; text-align: center; font-weight: 700; font-size: 15px; color: #2b2b2b; }
|
||||
.empty svg { margin-bottom: 14px; }
|
||||
.empty .et { display: inline-block; border: 2.5px dashed #adb5bd;
|
||||
border-radius: 15px 255px 15px 255px / 255px 15px 255px 15px;
|
||||
padding: 10px 26px; background: #fffdf3; }
|
||||
a.dl, a.cp, a.rm { text-decoration: none; font-weight: 800; font-size: 13.5px; padding: 0 3px; margin-right: 6px; }
|
||||
a.dl { color: #1971c2; background: linear-gradient(transparent 62%, #a5d8ff 62%); }
|
||||
a.dl:hover { background: #a5d8ff; }
|
||||
a.cp { color: #2f9e44; background: linear-gradient(transparent 62%, #b2f2bb 62%); }
|
||||
a.cp:hover { background: #b2f2bb; }
|
||||
a.rm { color: #e03131; background: linear-gradient(transparent 62%, #ffc9c9 62%); }
|
||||
a.rm:hover { background: #ffc9c9; }
|
||||
.who { font-weight: 800; }
|
||||
.who.center { color: #1971c2; }
|
||||
.sha {
|
||||
font-family: ui-monospace, Consolas, "Courier New", monospace;
|
||||
color: #9aa2b4; font-size: 11.5px; cursor: help; flex: 1; min-width: 0;
|
||||
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
}
|
||||
tbody tr:hover .sha { color: #4a5468; }
|
||||
.empty { padding: 46px 20px; text-align: center; font-size: 14px; color: #9aa2b4; }
|
||||
.empty .et { display: inline-block; padding: 10px 26px; }
|
||||
a.dl, a.cp, a.rm { font-weight: 600; font-size: 13px; text-decoration: none; margin-right: 10px; }
|
||||
a.dl { color: #2f5cf0; }
|
||||
a.dl:hover { text-decoration: underline; }
|
||||
a.cp { color: #1d9d5c; }
|
||||
a.cp:hover { text-decoration: underline; }
|
||||
a.rm { color: #d6453d; }
|
||||
a.rm:hover { text-decoration: underline; }
|
||||
.who { font-weight: 600; }
|
||||
.who.center { color: #2f5cf0; }
|
||||
|
||||
.footer {
|
||||
display: flex; justify-content: space-between; align-items: center;
|
||||
padding: 12px 18px; border-top: 2.5px dashed #adb5bd;
|
||||
font-weight: 700; font-size: 12.5px; color: #495057;
|
||||
padding: 11px 16px; border-top: 1px solid #f0f2f6;
|
||||
font-size: 12px; color: #9aa2b4;
|
||||
}
|
||||
.footer .dot { color: #e8590c; }
|
||||
|
||||
/* ===== 修改密码弹窗(便签)===== */
|
||||
/* ===== 登录页 ===== */
|
||||
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: #f5f7fa; }
|
||||
.login-card {
|
||||
width: 380px; background: #fff;
|
||||
border: 1px solid #e8ecf1; border-radius: 12px;
|
||||
box-shadow: 0 10px 34px -18px rgba(35, 42, 58, .35);
|
||||
padding: 36px 34px 30px;
|
||||
}
|
||||
.login-card .emblem {
|
||||
width: 48px; height: 48px; border-radius: 12px;
|
||||
display: grid; place-items: center;
|
||||
background: linear-gradient(135deg, #2f5cf0 0%, #0f9f9b 140%);
|
||||
color: #fff; font-size: 18px; font-weight: 800;
|
||||
box-shadow: 0 8px 18px -8px rgba(47, 92, 240, .55);
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.login-card h2 { font-size: 20px; font-weight: 700; }
|
||||
.login-card .login-sub { font-size: 12.5px; color: #8a93a6; margin: 4px 0 22px; }
|
||||
.login-field { position: relative; margin-bottom: 14px; }
|
||||
.login-field input {
|
||||
width: 100%; padding: 10px 40px 10px 12px;
|
||||
border: 1px solid #d9dee7; border-radius: 6px;
|
||||
font-family: inherit; font-size: 14px; outline: none; background: #fff;
|
||||
transition: border-color .15s, box-shadow .15s;
|
||||
}
|
||||
.login-field input:focus { border-color: #2f5cf0; box-shadow: 0 0 0 3px rgba(47, 92, 240, .12); }
|
||||
.eye { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); cursor: pointer; font-size: 15px; color: #8a93a6; user-select: none; }
|
||||
.login-card .btn { width: 100%; padding: 10px; font-size: 15px; margin-top: 2px; }
|
||||
.login-hint { margin-top: 14px; font-size: 12px; color: #9aa2b4; }
|
||||
.login-msg {
|
||||
margin-top: 12px; background: #fdeeee; color: #d6453d;
|
||||
padding: 9px 12px; font-size: 13px;
|
||||
border: 1px solid #f5c6c2; border-radius: 6px;
|
||||
}
|
||||
|
||||
/* ===== 修改密码弹窗 ===== */
|
||||
.mask {
|
||||
position: fixed; inset: 0; background: rgba(43,43,43,.45);
|
||||
position: fixed; inset: 0; background: rgba(20, 26, 40, .45);
|
||||
display: flex; align-items: center; justify-content: center; z-index: 99; padding: 24px;
|
||||
}
|
||||
.modal {
|
||||
position: relative; width: 410px; background: #fffef8;
|
||||
border: 2.5px solid #2b2b2b;
|
||||
border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
|
||||
box-shadow: 6px 8px 0 rgba(0,0,0,.16); padding: 36px 34px 30px;
|
||||
transform: rotate(.5deg);
|
||||
width: 400px; background: #fff;
|
||||
border: 1px solid #e8ecf1; border-radius: 12px;
|
||||
box-shadow: 0 14px 40px -18px rgba(20, 26, 40, .45);
|
||||
padding: 26px 28px 22px;
|
||||
}
|
||||
.modal .tape { top: -13px; left: 50%; margin-left: -46px; transform: rotate(2deg); }
|
||||
.modal h3 { font-size: 21px; font-weight: 800; }
|
||||
.modal .msub { font-size: 12.5px; color: #868e96; font-weight: 700; margin: 3px 0 16px; }
|
||||
.modal h3 { font-size: 17px; font-weight: 700; }
|
||||
.modal .msub { font-size: 12px; color: #8a93a6; margin: 3px 0 16px; }
|
||||
.modal input {
|
||||
width: 100%; padding: 10px 14px; border: 2.5px solid #2b2b2b;
|
||||
border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
|
||||
font-family: inherit; font-size: 14px; font-weight: 600; outline: none;
|
||||
margin-bottom: 12px; background: #fff;
|
||||
width: 100%; padding: 9px 12px; border: 1px solid #d9dee7; border-radius: 6px;
|
||||
font-family: inherit; font-size: 14px; outline: none; margin-bottom: 12px;
|
||||
transition: border-color .15s, box-shadow .15s;
|
||||
}
|
||||
.modal input:focus { background: #fff9db; }
|
||||
.modal .mrow { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
|
||||
.modal input:focus { border-color: #2f5cf0; box-shadow: 0 0 0 3px rgba(47, 92, 240, .12); }
|
||||
.modal .mrow { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
|
||||
.modal .pwd-msg {
|
||||
margin-bottom: 12px; background: #ffe3e3; color: #c92a2a;
|
||||
padding: 9px 12px; font-weight: 700; font-size: 12.5px;
|
||||
border: 2.5px dashed #c92a2a;
|
||||
border-radius: 15px 255px 15px 255px / 255px 15px 255px 15px;
|
||||
margin-bottom: 12px; background: #fdeeee; color: #d6453d;
|
||||
padding: 9px 12px; font-size: 12.5px;
|
||||
border: 1px solid #f5c6c2; border-radius: 6px;
|
||||
}
|
||||
|
||||
@media (max-width: 1000px) {
|
||||
.stats { grid-template-columns: repeat(2, 1fr); }
|
||||
th:nth-child(4), td:nth-child(4), th:nth-child(5), td:nth-child(5) { display: none; }
|
||||
.header .pin.r { display: none; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
@@ -279,8 +217,6 @@
|
||||
<!-- 登录界面 -->
|
||||
<div class="login-wrap" v-if="!loggedIn">
|
||||
<div class="login-card">
|
||||
<span class="tape"></span>
|
||||
<span class="pin">📌</span>
|
||||
<div class="emblem">37</div>
|
||||
<h2>文件服务器管理</h2>
|
||||
<div class="login-sub">37DU 内网文件服务器 · 管理台</div>
|
||||
@@ -300,12 +236,10 @@
|
||||
<!-- 主界面 -->
|
||||
<template v-else>
|
||||
<div class="header">
|
||||
<span class="pin l">📌</span>
|
||||
<span class="pin r">📌</span>
|
||||
<div class="brand">
|
||||
<div class="emblem">37</div>
|
||||
<div>
|
||||
<h1>文件服务器管理 <span class="squiggle"></span></h1>
|
||||
<h1>文件服务器管理</h1>
|
||||
<div class="sub">{{ baseUrl }} · 登录用户:{{ tokenUser }}</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -317,10 +251,10 @@
|
||||
</div>
|
||||
|
||||
<div class="stats">
|
||||
<div class="stat"><span class="tape"></span><div class="k">文件数</div><div class="v">{{ totalCount }}</div></div>
|
||||
<div class="stat"><span class="tape"></span><div class="k">总大小</div><div class="v">{{ totalSizeText }}</div></div>
|
||||
<div class="stat"><span class="tape"></span><div class="k">总下载</div><div class="v">{{ totalDownloads }}</div></div>
|
||||
<div class="stat"><span class="tape"></span><div class="k">最近上传</div><div class="v" style="font-size:15px;line-height:1.4">{{ lastUploadText }}</div></div>
|
||||
<div class="stat"><div class="k">文件数</div><div class="v">{{ totalCount }}</div></div>
|
||||
<div class="stat"><div class="k">总大小</div><div class="v">{{ totalSizeText }}</div></div>
|
||||
<div class="stat"><div class="k">总下载</div><div class="v">{{ totalDownloads }}</div></div>
|
||||
<div class="stat"><div class="k">最近上传</div><div class="v" style="font-size:16px;font-weight:600">{{ lastUploadText }}</div></div>
|
||||
</div>
|
||||
|
||||
<div class="toolbar">
|
||||
@@ -337,24 +271,23 @@
|
||||
<div class="status-bar" :class="statusClass">{{ statusMsg }}</div>
|
||||
|
||||
<div class="main">
|
||||
<div class="loading" v-if="loading"><span class="pen">✏️</span> 翻本子中…</div>
|
||||
<div class="loading" v-if="loading">加载中…</div>
|
||||
<div class="card" v-else>
|
||||
<span class="tape"></span>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:42px">#</th>
|
||||
<th @click="sortBy('filename')">文件名<span class="arrow" v-if="sortKey==='filename'">{{ sortDir===1?'▲':'▼' }}</span></th>
|
||||
<th class="fname-col" @click="sortBy('filename')">文件名<span class="arrow" v-if="sortKey==='filename'">{{ sortDir===1?'▲':'▼' }}</span></th>
|
||||
<th style="width:90px" @click="sortBy('size')">大小<span class="arrow" v-if="sortKey==='size'">{{ sortDir===1?'▲':'▼' }}</span></th>
|
||||
<th style="width:160px" @click="sortBy('created')">上传时间<span class="arrow" v-if="sortKey==='created'">{{ sortDir===1?'▲':'▼' }}</span></th>
|
||||
<th style="width:90px">上传人</th>
|
||||
<th style="width:70px" @click="sortBy('downloads')">下载<span class="arrow" v-if="sortKey==='downloads'">{{ sortDir===1?'▲':'▼' }}</span></th>
|
||||
<th style="width:190px">操作</th>
|
||||
<th style="width:150px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody v-if="sortedFiles.length">
|
||||
<tr v-for="(f, i) in sortedFiles" :key="f.fid">
|
||||
<td style="color:#adb5bd;font-weight:800">{{ i + 1 }}</td>
|
||||
<td style="color:#c0c6d0;font-weight:600">{{ i + 1 }}</td>
|
||||
<td>
|
||||
<div class="fname-cell">
|
||||
<span class="filename">{{ f.filename }}</span>
|
||||
@@ -377,25 +310,13 @@
|
||||
</tbody>
|
||||
<tbody v-else>
|
||||
<tr><td colspan="7">
|
||||
<div class="empty">
|
||||
<svg width="150" height="120" viewBox="0 0 150 120" fill="none" stroke="#2b2b2b" stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M20 36 Q22 31 27 31 L56 31 L67 41 L129 41"/>
|
||||
<path d="M15 41 L135 41 Q139 42 139 46 L139 96 Q139 101 134 101 L16 101 Q11 101 11 96 L11 46 Q11 42 15 41 Z"/>
|
||||
<path d="M18 51 L132 51" stroke="#ffd43b" stroke-width="5" opacity=".65"/>
|
||||
<path d="M96 22 L110 13"/>
|
||||
<path d="M112 28 L128 20"/>
|
||||
<path d="M86 14 L92 4"/>
|
||||
<path d="M102 8 l13 8 -6 10 -13 -8 z" transform="rotate(-12 108 17)"/>
|
||||
<path d="M82 4 l10 6 -5 8 -10 -6 z" transform="rotate(-30 87 11)"/>
|
||||
</svg>
|
||||
<div class="et">📭 暂无文件{{ keyword ? '(与搜索条件匹配)' : '' }}</div>
|
||||
</div>
|
||||
<div class="empty"><div class="et">📭 暂无文件{{ keyword ? '(与搜索条件匹配)' : '' }}</div></div>
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="footer">
|
||||
<span>37DU <span class="dot">✏️</span> 内网文件服务器</span>
|
||||
<span>DOODLE ADMIN v2.2</span>
|
||||
<span>37DU 内网文件服务器</span>
|
||||
<span>ADMIN v2.3</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -403,7 +324,6 @@
|
||||
<!-- 修改密码弹窗 -->
|
||||
<div class="mask" v-if="showPwdModal">
|
||||
<div class="modal">
|
||||
<span class="tape"></span>
|
||||
<h3>修改密码</h3>
|
||||
<div class="msub">修改后需重新登录</div>
|
||||
<div class="pwd-msg" v-if="pwdMsg">{{ pwdMsg }}</div>
|
||||
|
||||
Reference in New Issue
Block a user