From d804696fd0887801bcd3b94a60dbf4720a2747a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E7=8E=8B-=E7=AC=94=E8=AE=B0=E6=9C=AC?= <2161656029@qq.com> Date: Wed, 4 Nov 2026 16:48:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(frontend):=20=E7=AE=A1=E7=90=86=E5=8F=B0?= =?UTF-8?q?=E6=8C=89=E5=8E=9F=E5=9E=8B=E8=90=BD=E5=9C=B0=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E7=8B=AC=E7=AB=8B=E6=B6=88=E6=81=AF=E6=A3=80=E7=B4=A2?= =?UTF-8?q?=E9=A1=B5=E4=B8=8E=E6=BC=94=E7=A4=BA=E6=95=B0=E6=8D=AE=E5=BC=80?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 + frontend/src/App.vue | 336 ++++++++++++--- frontend/src/api.js | 47 +- frontend/src/components/ConfirmDialog.vue | 64 +++ frontend/src/components/DemoBadge.vue | 3 + frontend/src/components/DetailDrawer.vue | 45 ++ frontend/src/components/PageHead.vue | 20 + frontend/src/components/Pagination.vue | 54 +++ frontend/src/components/PlannedNotice.vue | 31 ++ frontend/src/components/SectionState.vue | 40 ++ frontend/src/components/StatCard.vue | 31 ++ frontend/src/components/StatusTag.vue | 17 + frontend/src/demo/config.js | 23 + frontend/src/demo/planned.js | 150 +++++++ frontend/src/main.js | 53 ++- frontend/src/styles/app.css | 218 ++++++++++ frontend/src/styles/prototype.css | 7 + frontend/src/ui.js | 144 +++++++ frontend/src/views/AiView.vue | 124 ++++++ frontend/src/views/AutomationView.vue | 133 ++++++ frontend/src/views/BackupView.vue | 103 +++++ frontend/src/views/BindingsView.vue | 124 ------ frontend/src/views/BootstrapView.vue | 266 ++++++++++-- frontend/src/views/ConnectionsView.vue | 324 ++++++++++++++ frontend/src/views/DashboardView.vue | 251 +++++++++++ frontend/src/views/LoginView.vue | 187 ++++++-- frontend/src/views/LogsView.vue | 104 +++++ frontend/src/views/MessageSearchView.vue | 408 ++++++++++++++++++ frontend/src/views/MessagesView.vue | 501 +++++++++++++++++----- frontend/src/views/OpsView.vue | 160 +++++++ frontend/src/views/OverviewView.vue | 87 ---- frontend/src/views/SecurityView.vue | 155 +++++++ frontend/src/views/SendView.vue | 152 ------- frontend/src/views/SettingsView.vue | 124 ++++++ frontend/vite.config.js | 47 +- 35 files changed, 3903 insertions(+), 633 deletions(-) create mode 100644 frontend/src/components/ConfirmDialog.vue create mode 100644 frontend/src/components/DemoBadge.vue create mode 100644 frontend/src/components/DetailDrawer.vue create mode 100644 frontend/src/components/PageHead.vue create mode 100644 frontend/src/components/Pagination.vue create mode 100644 frontend/src/components/PlannedNotice.vue create mode 100644 frontend/src/components/SectionState.vue create mode 100644 frontend/src/components/StatCard.vue create mode 100644 frontend/src/components/StatusTag.vue create mode 100644 frontend/src/demo/config.js create mode 100644 frontend/src/demo/planned.js create mode 100644 frontend/src/styles/app.css create mode 100644 frontend/src/styles/prototype.css create mode 100644 frontend/src/ui.js create mode 100644 frontend/src/views/AiView.vue create mode 100644 frontend/src/views/AutomationView.vue create mode 100644 frontend/src/views/BackupView.vue delete mode 100644 frontend/src/views/BindingsView.vue create mode 100644 frontend/src/views/ConnectionsView.vue create mode 100644 frontend/src/views/DashboardView.vue create mode 100644 frontend/src/views/LogsView.vue create mode 100644 frontend/src/views/MessageSearchView.vue create mode 100644 frontend/src/views/OpsView.vue delete mode 100644 frontend/src/views/OverviewView.vue create mode 100644 frontend/src/views/SecurityView.vue delete mode 100644 frontend/src/views/SendView.vue create mode 100644 frontend/src/views/SettingsView.vue diff --git a/.gitignore b/.gitignore index 0d9fc04..2f141e0 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,9 @@ node_modules/ .vite/ *.local +# 原型预览产物(仅本机参考,不入库) +frontend/design-preview/ + # 本地运行数据与日志 logs/ data/ diff --git a/frontend/src/App.vue b/frontend/src/App.vue index abad875..e4b109a 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,100 +1,304 @@ - +
+
+ + +
+ QLinker + QQ 消息管理台 +
+
+ +
+ 当前实例 + {{ instanceLabel }} +
+ + + +
+ + + + +
+
+ +
+ + +
+ + +
+
+ + + +
+ {{ toastState.title }} + {{ toastState.body }} + +
+
+ diff --git a/frontend/src/api.js b/frontend/src/api.js index e8d569a..5de8c5a 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -9,19 +9,45 @@ export function setToken(token) { else localStorage.removeItem(TOKEN_KEY) } -/** 后端统一响应:success/code/message/data/requestId。失败时抛出携带 code 与 requestId 的错误。 */ +function buildQuery(params) { + const search = new URLSearchParams() + for (const [key, value] of Object.entries(params || {})) { + if (value === undefined || value === null || value === '' || value === 'all') continue + search.set(key, String(value)) + } + const text = search.toString() + return text ? `?${text}` : '' +} + +/** + * 后端统一响应:success/code/message/data/requestId。 + * 失败时抛出携带 code、requestId、httpStatus 的错误,由 ui.describeError 统一转文案。 + */ export async function request(path, options = {}) { const headers = { 'Content-Type': 'application/json', ...(options.headers || {}) } const token = getToken() if (token) headers.Authorization = `Bearer ${token}` - const response = await fetch(path, { ...options, headers }) + let response + try { + response = await fetch(path, { ...options, headers }) + } catch (e) { + const error = new Error('无法连接后端服务,请确认服务已启动或网络可用') + error.code = 'NETWORK_ERROR' + error.retryable = true + throw error + } + let body = null try { body = await response.json() } catch { - throw new Error(`服务返回非 JSON 响应(HTTP ${response.status})`) + const error = new Error(`服务返回非 JSON 响应(HTTP ${response.status})`) + error.code = 'INVALID_RESPONSE' + error.httpStatus = response.status + throw error } + if (!body || body.success !== true) { const error = new Error(body?.message || `请求失败(HTTP ${response.status})`) error.code = body?.code @@ -47,6 +73,7 @@ export const api = { me: () => request('/api/v1/auth/me'), bindings: () => request('/api/v1/napcat-bindings'), + binding: (uid) => request(`/api/v1/napcat-bindings/${uid}`), createBinding: (payload) => request('/api/v1/napcat-bindings', { method: 'POST', body: JSON.stringify(payload) }), rotateToken: (uid, accessToken) => request(`/api/v1/napcat-bindings/${uid}/access-token`, { @@ -55,13 +82,15 @@ export const api = { }), deactivateBinding: (uid) => request(`/api/v1/napcat-bindings/${uid}`, { method: 'DELETE' }), - messages: (params) => request(`/api/v1/messages?${new URLSearchParams(params)}`), - message: (uid) => request(`/api/v1/messages/${uid}`), + messages: (params) => request(`/api/v1/messages${buildQuery(params)}`), + message: (uid) => request(`/api/v1/messages/${encodeURIComponent(uid)}`), + conversations: (page = 1, pageSize = 50) => + request(`/api/v1/messages/conversations${buildQuery({ page, pageSize })}`), messageStats: () => request('/api/v1/messages/stats'), mediaStats: () => request('/api/v1/media/stats'), - media: (uid) => request(`/api/v1/media/${uid}`), - mediaAccessUrl: (uid) => request(`/api/v1/media/${uid}/access-url`), + media: (uid) => request(`/api/v1/media/${encodeURIComponent(uid)}`), + mediaAccessUrl: (uid) => request(`/api/v1/media/${encodeURIComponent(uid)}/access-url`), prepareText: (payload, idempotencyKey) => request('/api/v1/send/text', { @@ -70,11 +99,11 @@ export const api = { body: JSON.stringify(payload) }), executeSend: (uid, confirmToken) => - request(`/api/v1/send/operations/${uid}/execute`, { + request(`/api/v1/send/operations/${encodeURIComponent(uid)}/execute`, { method: 'POST', body: JSON.stringify({ confirmToken }) }), - sendOperation: (uid) => request(`/api/v1/send/operations/${uid}`), + sendOperation: (uid) => request(`/api/v1/send/operations/${encodeURIComponent(uid)}`), sendOperations: (limit = 50) => request(`/api/v1/send/operations?limit=${limit}`), sendSummary: () => request('/api/v1/send/summary') } diff --git a/frontend/src/components/ConfirmDialog.vue b/frontend/src/components/ConfirmDialog.vue new file mode 100644 index 0000000..4d5541e --- /dev/null +++ b/frontend/src/components/ConfirmDialog.vue @@ -0,0 +1,64 @@ + + + diff --git a/frontend/src/components/DemoBadge.vue b/frontend/src/components/DemoBadge.vue new file mode 100644 index 0000000..1e7bccf --- /dev/null +++ b/frontend/src/components/DemoBadge.vue @@ -0,0 +1,3 @@ + diff --git a/frontend/src/components/DetailDrawer.vue b/frontend/src/components/DetailDrawer.vue new file mode 100644 index 0000000..b98bf83 --- /dev/null +++ b/frontend/src/components/DetailDrawer.vue @@ -0,0 +1,45 @@ + + + diff --git a/frontend/src/components/PageHead.vue b/frontend/src/components/PageHead.vue new file mode 100644 index 0000000..2ed724e --- /dev/null +++ b/frontend/src/components/PageHead.vue @@ -0,0 +1,20 @@ + + + diff --git a/frontend/src/components/Pagination.vue b/frontend/src/components/Pagination.vue new file mode 100644 index 0000000..9a9dd7a --- /dev/null +++ b/frontend/src/components/Pagination.vue @@ -0,0 +1,54 @@ + + + diff --git a/frontend/src/components/PlannedNotice.vue b/frontend/src/components/PlannedNotice.vue new file mode 100644 index 0000000..9133bc6 --- /dev/null +++ b/frontend/src/components/PlannedNotice.vue @@ -0,0 +1,31 @@ + + + + + diff --git a/frontend/src/components/SectionState.vue b/frontend/src/components/SectionState.vue new file mode 100644 index 0000000..c73e43c --- /dev/null +++ b/frontend/src/components/SectionState.vue @@ -0,0 +1,40 @@ + + + diff --git a/frontend/src/components/StatCard.vue b/frontend/src/components/StatCard.vue new file mode 100644 index 0000000..4299af0 --- /dev/null +++ b/frontend/src/components/StatCard.vue @@ -0,0 +1,31 @@ + + + diff --git a/frontend/src/components/StatusTag.vue b/frontend/src/components/StatusTag.vue new file mode 100644 index 0000000..4176f39 --- /dev/null +++ b/frontend/src/components/StatusTag.vue @@ -0,0 +1,17 @@ + + + diff --git a/frontend/src/demo/config.js b/frontend/src/demo/config.js new file mode 100644 index 0000000..f4d4db3 --- /dev/null +++ b/frontend/src/demo/config.js @@ -0,0 +1,23 @@ +import { reactive } from 'vue' + +/** + * 演示数据总开关。 + * + * 默认开启,便于用 file:// 直接预览完整页面;设置 VITE_ENABLE_MOCK=false 构建后默认关闭。 + * 运行时开关保存在 localStorage,关闭后未实现页面整体显示「未开发 / 规划中」, + * 已实现能力继续使用真实接口,不伪造任何成功状态。 + */ +const STORAGE_KEY = 'qlinker.demo-enabled' +const envDefault = import.meta.env.VITE_ENABLE_MOCK !== 'false' +const stored = localStorage.getItem(STORAGE_KEY) + +export const demoState = reactive({ + enabled: stored === null ? envDefault : stored === 'true' +}) + +export function setDemoEnabled(value) { + demoState.enabled = Boolean(value) + localStorage.setItem(STORAGE_KEY, demoState.enabled ? 'true' : 'false') +} + +export const MOCK_NOTE = '当前页面含演示数据,仅用于界面预览,不代表真实业务状态。' diff --git a/frontend/src/demo/planned.js b/frontend/src/demo/planned.js new file mode 100644 index 0000000..3adee81 --- /dev/null +++ b/frontend/src/demo/planned.js @@ -0,0 +1,150 @@ +/** + * 演示数据集(未实现能力的占位内容)。 + * 规则:所有引用处必须同时渲染「演示数据」标识;不得与真实接口返回值混用; + * 关闭 MOCK_ENABLED 后这些数据不再渲染,页面回到「未开发 / 规划中」。 + */ + +export const PLANNED_DEPS = { + dashboard: ['/system/alerts 实时告警', '/messages/stats 今日与时间序列', '/automation/runs 执行统计', '/ai/calls 调用统计'], + automation: ['/automation/rules 规则与草稿', '/automation/rules/{id}/versions 版本', '/automation/debug-runs 调试', '/automation/runs 执行记录'], + ai: ['/ai/providers 与 /ai/providers/{id}/test', '/ai/capabilities', '/ai/calls 与成本统计'], + ops: ['/health 依赖分项(MySQL / MinIO / 队列 / 主机资源)', '/alerts 告警处理(确认 / 分派 / 静默 / 关闭)'], + logs: ['/logs 统一日志', '/traces/{traceId} 链路详情', '/export-tasks 导出任务'], + backup: ['/backups 备份与校验', '/restore-drills 恢复演练'], + security: ['/users /roles /tokens /approvals /audit-events', '紧急停止后端控制'], + settings: ['/settings 实例设置读写'] +} + +export const dashboardTrend24h = [ + 28, 36, 31, 44, 39, 58, 49, 65, 54, 75, 60, 84, + 72, 62, 89, 70, 95, 80, 67, 88, 61, 75, 54, 68 +] + +export const dashboardTrend7d = [62, 74, 58, 83, 91, 76, 88] + +export const dashboardAlerts = [ + { level: 'warning', title: 'NapCat-03 连接不稳定', detail: '连续重连 3 次 · 8 分钟前', status: '警告' }, + { level: 'error', title: '规则「群消息归档」执行失败', detail: '节点:文件上传 · 21 分钟前', status: '失败' }, + { level: 'success', title: '备份任务已完成', detail: '数据完整性检查通过 · 1 小时前', status: '已恢复' } +] + +export const automationSummary = { successRate: 98.6, success: 1266, failed: 18, recent: '群消息智能分流' } + +export const automationRules = [ + { name: '群消息智能分流', trigger: '收到群消息', lastRun: '09:44:12', successRate: '99.2%', status: '运行中', version: 'v2.1' }, + { name: '群消息归档', trigger: '收到群消息', lastRun: '09:42:08', successRate: '96.4%', status: '运行中', version: 'v1.3' }, + { name: '关键词自动回复', trigger: '关键词命中', lastRun: '09:31:46', successRate: '98.8%', status: '已停用', version: 'v1.0' } +] + +export const automationNodes = [ + { id: 'trigger', kind: 'EVENT', title: '收到群消息', sub: '触发器', x: 18, y: 70 }, + { id: 'condition', kind: 'IF', title: '关键词判断', sub: '条件', x: 300, y: 70 }, + { id: 'ai', kind: 'LLM', title: 'AI 内容分类', sub: 'AI 调用', x: 582, y: 70 }, + { id: 'send', kind: 'SEND', title: '发送处理结果', sub: '动作', x: 864, y: 70 } +] + +export const automationRuns = [ + { id: 'run_20261104_01', rule: '群消息智能分流', status: 'SUCCEEDED', startedAt: '09:44:12', duration: '860ms', node: '全部通过' }, + { id: 'run_20261104_02', rule: '群消息归档', status: 'FAILED', startedAt: '09:42:08', duration: '1.4s', node: '文件上传' }, + { id: 'run_20261104_03', rule: '关键词自动回复', status: 'SUCCEEDED', startedAt: '09:31:46', duration: '320ms', node: '全部通过' } +] + +export const aiProviders = [ + { name: 'OpenAI 兼容', protocol: 'OpenAI Compatible', model: 'GPT-4.1', todayCalls: 328, budget: 92, status: '已启用', test: '成功 · 09:12' }, + { name: 'DeepSeek', protocol: 'OpenAI Compatible', model: 'V3 / R1', todayCalls: 241, budget: 86, status: '已启用', test: '成功 · 08:58' }, + { name: 'Qwen', protocol: 'OpenAI Compatible', model: 'Plus', todayCalls: 73, budget: 64, status: '已启用', test: '成功 · 08:40' } +] + +export const aiCapabilities = [ + { name: '消息智能分类', model: 'GPT-4.1', enabled: true, desc: '按规则对入站消息打标签' }, + { name: '自动摘要', model: 'DeepSeek V3', enabled: true, desc: '群聊与长消息摘要' }, + { name: 'AI 回复建议', model: 'DeepSeek R1', enabled: true, desc: '生成建议草稿,不自动发送' }, + { name: '自动发送回复', model: '—', enabled: false, desc: '高风险:当前未启用' } +] + +export const aiCalls = [ + { time: '09:43:20', capability: '消息智能分类', model: 'GPT-4.1', duration: '1.28s', tokens: '1,240', result: '成功' }, + { time: '09:38:12', capability: '自动摘要', model: 'DeepSeek V3', duration: '2.04s', tokens: '3,180', result: '成功' }, + { time: '09:26:44', capability: 'AI 回复建议', model: 'DeepSeek R1', duration: '3.10s', tokens: '2,460', result: '成功' }, + { time: '09:12:03', capability: '消息智能分类', model: 'Qwen Plus', duration: '1.62s', tokens: '980', result: '限流失败' }, + { time: '08:58:37', capability: '自动摘要', model: 'GPT-4.1', duration: '2.38s', tokens: '4,020', result: '成功' } +] + +export const opsDependencies = [ + { name: 'QLinker API', status: '正常', latency: '86 ms' }, + { name: 'MySQL', status: '正常', latency: '12 ms' }, + { name: 'MinIO', status: '正常', latency: '24 ms' }, + { name: 'NapCat 连接', status: '部分异常', latency: '—' }, + { name: '任务队列', status: '正常', latency: '28 条积压' } +] + +export const opsResources = [ + { name: 'CPU', value: '38%', width: 38 }, + { name: '内存', value: '62%', width: 62 }, + { name: '磁盘', value: '42%', width: 42 } +] + +export const opsAlerts = [ + { level: 'warning', title: 'NapCat-03 连续重连', time: '09:36', status: '未确认' }, + { level: 'error', title: '规则执行失败:文件上传节点', time: '09:23', status: '未确认' }, + { level: 'info', title: '备份完整性校验通过', time: '08:40', status: '已关闭' } +] + +export const logRows = [ + { time: '09:44:12', level: 'INFO', source: 'event.ingest', summary: '群消息事件已持久化', trace: 'trc_9f21', cost: '12 ms' }, + { time: '09:42:18', level: 'INFO', source: 'media.download', summary: '图片下载完成并写入对象存储', trace: 'trc_9f18', cost: '860 ms' }, + { time: '09:42:08', level: 'ERROR', source: 'automation.run', summary: '节点「文件上传」执行失败:对象存储超时', trace: 'trc_9f16', cost: '1.4 s' }, + { time: '09:38:12', level: 'INFO', source: 'ai.call', summary: '摘要调用完成,tokens=3180', trace: 'trc_9f12', cost: '2.04 s' }, + { time: '09:26:44', level: 'WARN', source: 'send.operation', summary: '发送结果未知,等待人工核实', trace: 'trc_9f09', cost: '5.0 s' }, + { time: '09:12:03', level: 'WARN', source: 'ai.call', summary: '供应商返回限流,已按策略降级', trace: 'trc_9f04', cost: '1.62 s' }, + { time: '08:58:37', level: 'INFO', source: 'napcat.connection', summary: '反向 WebSocket 连接恢复', trace: 'trc_9ef8', cost: '40 ms' }, + { time: '08:40:00', level: 'INFO', source: 'backup.task', summary: '数据库全量备份完成,校验通过', trace: 'trc_9ef1', cost: '6.2 s' } +] + +export const backupPlans = [ + { name: '数据库全量', scope: '业务库', schedule: '每日 03:30', retention: '14 天', enabled: true }, + { name: '配置与规则', scope: '规则 / 设置', schedule: '每日 04:00', retention: '30 天', enabled: true }, + { name: '对象存储元数据', scope: 'MinIO 元数据', schedule: '每日 04:20', retention: '30 天', enabled: true }, + { name: '媒体文件', scope: 'MinIO 对象', schedule: '每周日 05:00', retention: '8 周', enabled: true } +] + +export const backupRecords = [ + { time: '今天 08:40', scope: '数据库全量', type: '自动', size: '1.8 GB', verify: '校验通过' }, + { time: '今天 04:20', scope: '对象存储元数据', type: '自动', size: '246 MB', verify: '校验通过' }, + { time: '今天 04:00', scope: '配置与规则', type: '自动', size: '12 MB', verify: '校验通过' }, + { time: '昨天 03:30', scope: '数据库全量', type: '自动', size: '1.7 GB', verify: '校验通过' }, + { time: '昨天 05:00', scope: '媒体文件', type: '自动', size: '38 GB', verify: '校验通过' } +] + +export const securityUsers = [ + { name: '王明', account: 'admin', role: '系统管理员', status: '启用', lastLogin: '09:02' }, + { name: '李静', account: 'ops_li', role: '运维管理员', status: '启用', lastLogin: '08:41' }, + { name: '陈晨', account: 'msg_chen', role: '消息运营', status: '启用', lastLogin: '08:20' } +] + +export const securityRoles = [ + { name: '系统管理员', members: 2, scope: '全部资源', changed: '10-28' }, + { name: '运维管理员', members: 3, scope: '连接 / 运维 / 日志', changed: '10-21' }, + { name: '消息运营', members: 5, scope: '消息 / 发送 / 检索', changed: '10-12' } +] + +export const securityTokens = [ + { name: 'napcat-ops', scope: 'NAPCAT_READ', expires: '2026-12-01', status: '有效' }, + { name: 'ci-readonly', scope: 'MESSAGE_READ', expires: '2026-11-09', status: '临期' }, + { name: 'legacy', scope: 'MESSAGE_READ', expires: '2026-10-01', status: '已过期' } +] + +export const securityApprovals = [ + { title: '批量停用 3 个 QQ 账号', submitter: '李静', time: '09:41', risk: '高' }, + { title: '修改 AI 自动发送权限', submitter: '陈晨', time: '09:28', risk: '高' } +] + +export const settingsValues = { + instanceName: '生产实例 · QL-01', + instanceCode: 'QL-01', + timezone: 'Asia/Shanghai', + retention: '365', + theme: 'system', + realtime: true, + mobileNotify: true +} diff --git a/frontend/src/main.js b/frontend/src/main.js index 755908c..ea8126b 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -1,24 +1,47 @@ import { createApp } from 'vue' -import { createRouter, createWebHistory } from 'vue-router' +import { createRouter, createWebHashHistory } from 'vue-router' import App from './App.vue' -import BootstrapView from './views/BootstrapView.vue' -import LoginView from './views/LoginView.vue' -import OverviewView from './views/OverviewView.vue' -import BindingsView from './views/BindingsView.vue' -import MessagesView from './views/MessagesView.vue' -import SendView from './views/SendView.vue' import { getToken } from './api' +import './styles/prototype.css' +import './styles/app.css' +import DashboardView from './views/DashboardView.vue' +import MessagesView from './views/MessagesView.vue' +import MessageSearchView from './views/MessageSearchView.vue' +import ConnectionsView from './views/ConnectionsView.vue' +import AutomationView from './views/AutomationView.vue' +import AiView from './views/AiView.vue' +import OpsView from './views/OpsView.vue' +import LogsView from './views/LogsView.vue' +import BackupView from './views/BackupView.vue' +import SecurityView from './views/SecurityView.vue' +import SettingsView from './views/SettingsView.vue' +import LoginView from './views/LoginView.vue' +import BootstrapView from './views/BootstrapView.vue' + +// 使用 hash 路由:构建产物 dist/index.html 可被 file:// 直接打开预览, +// 部署到任意子路径时也不需要额外的服务端路由重写。 const router = createRouter({ - history: createWebHistory(), + history: createWebHashHistory(), routes: [ - { path: '/', redirect: '/overview' }, - { path: '/bootstrap', component: BootstrapView, meta: { public: true } }, - { path: '/login', component: LoginView, meta: { public: true } }, - { path: '/overview', component: OverviewView }, - { path: '/bindings', component: BindingsView }, - { path: '/messages', component: MessagesView }, - { path: '/send', component: SendView } + { path: '/', redirect: '/dashboard' }, + + { path: '/bootstrap', component: BootstrapView, meta: { public: true, title: '首次初始化' } }, + { path: '/login', component: LoginView, meta: { public: true, title: '管理员登录' } }, + + { path: '/dashboard', component: DashboardView, meta: { title: '工作台', group: '工作空间' } }, + { path: '/messages', component: MessagesView, meta: { title: '消息中心', group: '工作空间' } }, + { path: '/message-search', component: MessageSearchView, meta: { title: '消息检索', group: '工作空间' } }, + { path: '/connections', component: ConnectionsView, meta: { title: '接入管理', group: '工作空间' } }, + { path: '/automation', component: AutomationView, meta: { title: '自动化规则', group: '工作空间' } }, + { path: '/ai', component: AiView, meta: { title: 'AI 能力', group: '工作空间' } }, + { path: '/ops', component: OpsView, meta: { title: '运维监控', group: '工作空间' } }, + { path: '/logs', component: LogsView, meta: { title: '日志中心', group: '工作空间' } }, + { path: '/backup', component: BackupView, meta: { title: '备份与恢复', group: '平台管理' } }, + { path: '/security', component: SecurityView, meta: { title: '安全中心', group: '平台管理' } }, + { path: '/settings', component: SettingsView, meta: { title: '系统设置', group: '平台管理' } }, + + { path: '/:pathMatch(.*)*', redirect: '/dashboard' } ] }) diff --git a/frontend/src/styles/app.css b/frontend/src/styles/app.css new file mode 100644 index 0000000..eefc827 --- /dev/null +++ b/frontend/src/styles/app.css @@ -0,0 +1,218 @@ +/* 在原型 token 之上补齐语义变量与新增组件;所有页面共用同一套颜色与排版。 */ +:root { + --line: light-dark(#e5e9f2, #273247); + --line-soft: light-dark(#edf0f5, #253147); + --line-strong: light-dark(#dce2ed, #3a465d); + --muted: light-dark(#8792a7, #9aa7bd); + --muted-strong: light-dark(#6b788f, #b3bed0); + --card-bg: light-dark(#ffffff, #121b2b); + --field-bg: light-dark(#ffffff, #172235); + --soft-bg: light-dark(#f8faff, #182337); + --primary-soft: light-dark(#eaf0ff, #1c2d52); + --danger: #d94841; + --success: #13865c; +} + +body { min-height: 100vh; } +a { color: inherit; } +button:disabled { cursor: not-allowed; opacity: .55; } + +.brand-text { display: flex; flex-direction: column; line-height: 1.15; } +.brand-text strong { font-size: 18px; letter-spacing: -.4px; } +.brand-text span { font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: 0; } + +.nav-group { display: flex; flex-direction: column; gap: 3px; } +.nav-item .nav-meta { margin-left: auto; font-size: 10px; color: var(--muted); font-weight: 500; } +.nav-item.active .nav-meta { color: inherit; } + +.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; } +.btn.block { width: 100%; justify-content: center; } +.btn.ghost { border-color: transparent; background: transparent; } +.btn.ghost:hover { background: light-dark(#f2f5ff, #1d2a40); border-color: transparent; } + +.topbar .instance strong { font-size: 12px; } +.topbar .instance span { font-size: 11px; color: var(--muted); } +.top-actions .avatar { cursor: pointer; } +.top-actions { position: relative; } +.dropdown { + position: absolute; right: 0; top: 46px; min-width: 210px; z-index: 15; + background: var(--card-bg); border: 1px solid var(--line); border-radius: 12px; + box-shadow: 0 18px 46px #10182822; padding: 8px; +} +.dropdown .dd-head { padding: 9px 10px 11px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; } +.dropdown .dd-head strong { display: block; font-size: 13px; } +.dropdown .dd-head span { font-size: 11px; color: var(--muted); } +.dropdown button { + display: flex; width: 100%; gap: 8px; align-items: center; padding: 9px 10px; + border: 0; background: transparent; color: inherit; border-radius: 8px; text-align: left; +} +.dropdown button:hover { background: light-dark(#f2f5ff, #1d2a40); } + +.demo-badge { + display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 6px; + background: light-dark(#fff5df, #3d2c13); color: #b7791f; font-size: 10px; font-weight: 700; + border: 1px solid light-dark(#f5e2b8, #5a431c); white-space: nowrap; +} +.demo-banner { + display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: -6px 0 18px; + padding: 10px 13px; border-radius: 10px; font-size: 12px; + background: light-dark(#fffaf0, #2c2414); border: 1px solid light-dark(#f3e3c3, #4a3b1c); color: #9a7320; +} +.demo-banner .btn { margin-left: auto; } + +.notice { + border: 1px solid light-dark(#dbe3ff, #314a7a); background: light-dark(#f4f7ff, #1a2b4d); + color: light-dark(#25409a, #b7c9ff); border-radius: 10px; padding: 11px 13px; font-size: 12px; + line-height: 1.6; display: flex; gap: 9px; align-items: flex-start; +} +.notice.warn { border-color: light-dark(#f3e3c3, #5a431c); background: light-dark(#fffaf0, #2c2414); color: #9a7320; } +.notice.danger { border-color: light-dark(#f3d2cf, #5c2a2a); background: light-dark(#fff5f4, #341d1f); color: #b23b34; } +.notice + .notice { margin-top: 10px; } +.notice .btn { margin-left: auto; flex-shrink: 0; } + +.state-block { + display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; + padding: 42px 20px; color: var(--muted); text-align: center; border-radius: 12px; + border: 1px dashed var(--line-strong); background: var(--soft-bg); +} +.state-block strong { color: inherit; font-size: 14px; } +.state-block p { margin: 0; max-width: 560px; line-height: 1.6; font-size: 12px; } +.skeleton { height: 14px; border-radius: 6px; background: light-dark(#eef1f7, #1f2b3d); animation: pulse 1.4s ease-in-out infinite; } +@keyframes pulse { 0%, 100% { opacity: .55 } 50% { opacity: 1 } } + +.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; } +.pager .pager-info { font-size: 12px; color: var(--muted); } +.pager .pager-actions { display: flex; gap: 8px; align-items: center; } +.pager select { height: 34px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--field-bg); color: inherit; } + +.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; } +.form-grid .full { grid-column: 1 / -1; } +.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; } +.fld > label { font-size: 12px; font-weight: 650; color: var(--muted-strong); } +.fld > label .req { color: var(--danger); margin-left: 3px; } +.fld .field { width: 100%; min-width: 0; } +.fld .field.invalid { border-color: #e0827c; box-shadow: 0 0 0 3px #d9484118; } +.fld .field-hint { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.5; } +.fld .field-error { margin: 0; font-size: 11px; color: var(--danger); } +.fld textarea.field { height: auto; min-height: 96px; padding: 9px 11px; resize: vertical; line-height: 1.6; } +.field[disabled], .field:disabled { opacity: .6; } + +.kv { display: flex; flex-direction: column; gap: 9px; } +.kv-row { display: flex; justify-content: space-between; gap: 14px; font-size: 12px; } +.kv-row span:first-child { color: var(--muted); flex-shrink: 0; } +.kv-row span:last-child { text-align: right; word-break: break-all; } + +.drawer-backdrop { + position: fixed; inset: 0; background: #0b122080; z-index: 40; + display: flex; justify-content: flex-end; +} +.drawer { + width: min(720px, 100%); height: 100%; background: var(--card-bg); + border-left: 1px solid var(--line); display: flex; flex-direction: column; + animation: slide-in .18s ease; +} +@keyframes slide-in { from { transform: translateX(24px); opacity: .6 } to { transform: translateX(0); opacity: 1 } } +.drawer-head { padding: 19px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; } +.drawer-head h3 { margin: 0 0 5px; font-size: 17px; } +.drawer-head p { margin: 0; color: var(--muted); font-size: 12px; } +.drawer-body { padding: 18px 22px 32px; overflow: auto; flex: 1; } +.drawer-section { padding: 16px 0; border-bottom: 1px solid var(--line-soft); } +.drawer-section:last-child { border-bottom: 0; } +.drawer-section h4 { margin: 0 0 12px; font-size: 13px; display: flex; align-items: center; gap: 8px; } + +.raw-pre { + margin: 0; padding: 12px; border-radius: 10px; overflow: auto; max-height: 320px; + background: light-dark(#f7f9fd, #0f1929); border: 1px solid var(--line); + font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; line-height: 1.6; + white-space: pre-wrap; word-break: break-all; +} +.segment { + border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; + background: light-dark(#fbfcff, #172235); +} +.segment .seg-head { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; margin-bottom: 6px; } +.segment .seg-body { font-size: 12px; color: var(--muted-strong); word-break: break-all; line-height: 1.6; } +.segment img { max-width: 100%; border-radius: 8px; margin-top: 8px; display: block; } + +.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 8px; } +.bar-chart .bar { flex: 1; background: linear-gradient(180deg, #6d8dff, var(--site-primary)); border-radius: 5px 5px 2px 2px; min-height: 4px; position: relative; } +.bar-chart .bar:hover:after { + content: attr(data-label); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); + background: #172033; color: #fff; font-size: 10px; padding: 3px 6px; border-radius: 5px; white-space: nowrap; +} +.chart-axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 8px; } + +.auth-shell { + min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 420px) minmax(0, 1fr); + background: light-dark(#f4f6fb, #0c1220); +} +.auth-brand { + padding: 38px 34px; background: light-dark(#172554, #0b1120); color: #fff; + display: flex; flex-direction: column; gap: 34px; +} +.auth-brand .brand-text strong { color: #fff; } +.auth-brand .brand-text span { color: #9fb0d8; } +.auth-brand .logo { background: #fff; color: var(--site-primary); box-shadow: none; } +.auth-pitch h1 { font-size: 26px; line-height: 1.35; letter-spacing: -.6px; margin: 0 0 12px; } +.auth-pitch p { color: #b8c6e6; line-height: 1.7; margin: 0 0 22px; font-size: 13px; } +.auth-points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; } +.auth-points li { display: flex; gap: 10px; font-size: 12px; color: #cdd8ef; line-height: 1.6; } +.auth-points li span { width: 6px; height: 6px; border-radius: 50%; background: #7c9aFF; margin-top: 7px; flex-shrink: 0; } +.auth-foot { margin: auto 0 0; font-size: 11px; color: #7f90b8; } +.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; } +.auth-card { + width: min(460px, 100%); background: var(--card-bg); border: 1px solid var(--line); + border-radius: 16px; padding: 28px; box-shadow: 0 22px 60px #10182812; +} +.auth-card-head { margin-bottom: 20px; } +.auth-title { font-size: 23px; margin: 0 0 8px; letter-spacing: -.5px; } +.auth-sub { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; } +.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; } +.auth-form .input { + height: 40px; border: 1px solid var(--line-strong); border-radius: 9px; + background: var(--field-bg); color: inherit; padding: 0 11px; outline: none; width: 100%; +} +.auth-form .input:focus { border-color: #8299ff; box-shadow: 0 0 0 3px #315efb1c; } +.auth-form .input.invalid { border-color: #e0827c; } +.auth-note { font-size: 11px; color: var(--muted); line-height: 1.7; margin: 16px 0 0; } +.auth-note a { color: var(--site-primary); } +.loading-row { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; padding: 10px 0; } +.spinner { + width: 14px; height: 14px; border: 2px solid var(--line-strong); border-top-color: var(--site-primary); + border-radius: 50%; animation: spin .8s linear infinite; +} +@keyframes spin { to { transform: rotate(360deg) } } +.guide-list { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 16px; } +.guide-step { display: flex; gap: 10px; font-size: 12px; color: var(--muted-strong); line-height: 1.55; } +.guide-step b { width: 20px; height: 20px; border-radius: 6px; background: var(--primary-soft); color: var(--site-primary); display: grid; place-items: center; flex-shrink: 0; font-size: 11px; } + +.table-actions { display: flex; gap: 8px; flex-wrap: wrap; } +.tabs { overflow-x: auto; } +.tab:disabled { opacity: .55; cursor: not-allowed; } +.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 4px; } +.filterbar .field { flex: 0 0 auto; } +.filterbar .searchfield { flex: 1 1 240px; } +.filterbar .full { flex-basis: 100%; } +.inline-warn { font-size: 11px; color: #b7791f; } +.switch { cursor: pointer; border: 0; } +.switch.off:after { background: #fff; } + +.status.muted { color: #7a869a; background: light-dark(#f0f2f6, #252f40); } +.small-muted { font-size: 11px; color: var(--muted); } +.two-col > .card, .three-col > .card { min-width: 0; } +.card-head .card-title { display: flex; align-items: center; gap: 8px; } +.scroll-area { max-height: 340px; overflow: auto; } + +@media (max-width: 1200px) { + .auth-shell { grid-template-columns: 1fr; } + .auth-brand { display: none; } + .form-grid { grid-template-columns: 1fr; } +} +@media (max-width: 760px) { + .auth-main { padding: 24px 13px; } + .auth-card { padding: 20px; border-radius: 12px; } + .drawer { width: 100%; } + .topbar .brand-text { display: none; } + .filterbar .field { flex: 1 1 120px; } + .pager { flex-direction: column; align-items: flex-start; } +} diff --git a/frontend/src/styles/prototype.css b/frontend/src/styles/prototype.css new file mode 100644 index 0000000..5dfee5d --- /dev/null +++ b/frontend/src/styles/prototype.css @@ -0,0 +1,7 @@ + +:root{--site-primary:#315efb;--site-on-primary:#ffffff;--site-secondary:#172554;--site-on-secondary:#ffffff;--site-background:#f4f6fb;--site-on-background:#172033;--site-font-body:Inter,"PingFang SC","Microsoft YaHei",sans-serif;--site-font-heading:Inter,"PingFang SC","Microsoft YaHei",sans-serif;--site-heading-scale:1;--site-spacing-scale:1;--site-radius-scale:1;--site-decoration-opacity:1;color-scheme:light dark} +*{box-sizing:border-box}body{margin:0;font-family:var(--site-font-body);background:light-dark(#f4f6fb,#0c1220);color:light-dark(#172033,#e7ecf6);font-size:14px}button,input,select,textarea{font:inherit}button{cursor:pointer}.app{min-height:100vh;background-color:light-dark(#f4f6fb,#0c1220);color:light-dark(#172033,#e7ecf6);display:flex;flex-direction:column}.topbar{height:68px;background:light-dark(#fff,#121b2b);border-bottom:1px solid light-dark(#e5e9f2,#273247);display:flex;align-items:center;padding:0 26px;gap:22px;position:sticky;top:0;z-index:5}.brand{display:flex;align-items:center;gap:10px;min-width:228px;font-weight:800;font-size:19px;letter-spacing:-.4px}.logo{width:34px;height:34px;border-radius:11px;background:var(--site-primary);color:#fff;display:grid;place-items:center;font-weight:900;box-shadow:0 5px 15px #315efb44}.instance{border:1px solid light-dark(#e3e8f2,#344158);border-radius:9px;padding:8px 11px;background:light-dark(#f8faff,#1b2638);color:inherit;display:flex;gap:8px;align-items:center}.global-search{height:38px;max-width:430px;flex:1;display:flex;align-items:center;gap:8px;padding:0 12px;border:1px solid light-dark(#e4e8f0,#334057);border-radius:10px;background:light-dark(#f8f9fc,#192437);color:#8490a6}.global-search input{border:0;outline:0;background:transparent;width:100%;color:inherit}.top-actions{margin-left:auto;display:flex;gap:10px;align-items:center}.icon-btn{position:relative;border:1px solid light-dark(#e5e9f2,#344158);background:light-dark(#fff,#1a2638);color:inherit;border-radius:10px;width:38px;height:38px;display:grid;place-items:center;font-size:17px}.dot{position:absolute;right:7px;top:6px;width:7px;height:7px;border-radius:50%;background:#ef4444;border:1px solid white}.avatar{width:34px;height:34px;border-radius:50%;background:#dbeafe;color:#1d4ed8;display:grid;place-items:center;font-weight:700}.shell{display:flex;min-height:calc(100vh - 68px);flex:1}.sidebar{width:238px;flex-shrink:0;padding:20px 12px;background:light-dark(#fff,#121b2b);border-right:1px solid light-dark(#e5e9f2,#273247);display:flex;flex-direction:column;gap:4px}.nav-label{font-size:11px;color:#98a2b5;font-weight:700;letter-spacing:1px;padding:15px 13px 7px}.nav-item{display:flex;align-items:center;gap:12px;padding:11px 13px;border-radius:9px;color:light-dark(#58657b,#a8b3c8);font-weight:550;text-decoration:none;cursor:pointer;border:0;background:transparent;text-align:left;width:100%}.nav-item:hover{background:light-dark(#f2f5ff,#1d2a40);color:var(--site-primary)}.nav-item.active{background:light-dark(#eaf0ff,#1c2d52);color:light-dark(#254fe3,#9cb5ff);font-weight:700}.nav-icon{width:20px;text-align:center;font-size:16px}.nav-badge{margin-left:auto;background:#fff0ed;color:#d94841;font-size:11px;padding:2px 7px;border-radius:10px}.sidebar-bottom{margin-top:auto;padding:13px;border:1px solid light-dark(#e6eaf2,#2b374d);border-radius:12px;background:light-dark(#f8faff,#182337)}.sidebar-bottom strong{display:block;margin-bottom:6px}.sidebar-bottom p{font-size:12px;line-height:1.6;color:#8a96aa;margin:0 0 10px}.content{min-width:0;flex:1;padding:27px 30px 44px;max-width:1700px;margin:0 auto;width:100%}.page-head{display:flex;align-items:flex-start;justify-content:space-between;gap:20px;margin-bottom:23px}.eyebrow{font-size:12px;color:#8792a7;margin-bottom:7px}.page-title{font-size:calc(27px * var(--site-heading-scale));letter-spacing:-.7px;margin:0 0 7px;font-weight:780}.subtitle{color:#8792a7;margin:0;line-height:1.5}.actions{display:flex;gap:9px;align-items:center;flex-wrap:wrap}.btn{border:1px solid light-dark(#dce2ed,#3a465d);border-radius:9px;padding:9px 13px;background:light-dark(#fff,#1a2638);color:inherit;font-weight:600;display:inline-flex;align-items:center;gap:7px;white-space:nowrap}.btn:hover{border-color:#9bb0ff}.btn.primary{background:var(--site-primary);border-color:var(--site-primary);color:#fff}.btn.subtle{background:light-dark(#f7f9fc,#1a2638)}.btn.danger{color:#d94841}.grid{display:grid;gap:17px}.stats{grid-template-columns:repeat(4,minmax(0,1fr));margin-bottom:18px}.card{background:light-dark(#fff,#121b2b);border:1px solid light-dark(#e5e9f2,#273247);border-radius:14px;padding:19px;min-width:0}.stat-top{display:flex;justify-content:space-between;align-items:center;color:#8792a7;font-size:13px}.stat-icon{width:36px;height:36px;border-radius:10px;display:grid;place-items:center;font-size:17px;background:light-dark(#eef2ff,#1c2d52);color:#4c6fff}.stat-value{font-size:29px;font-weight:780;letter-spacing:-1px;margin:12px 0 6px}.stat-foot{font-size:12px;color:#8b96a9}.up{color:#16a36a;font-weight:700}.down{color:#d97706;font-weight:700}.two-col{grid-template-columns:minmax(0,1.5fr) minmax(290px,1fr)}.three-col{grid-template-columns:repeat(3,minmax(0,1fr))}.card-head{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:16px}.card-title{font-size:15px;font-weight:750;margin:0}.muted{color:#8b96a9}.small{font-size:12px}.link{color:var(--site-primary);font-weight:650;cursor:pointer;border:0;background:none;padding:0}.status{display:inline-flex;align-items:center;gap:6px;padding:4px 8px;border-radius:6px;font-size:11px;font-weight:700;white-space:nowrap}.status:before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor}.success{color:#13865c;background:light-dark(#e8f8f0,#12372d)}.warning{color:#b7791f;background:light-dark(#fff5df,#3d2c13)}.error{color:#d94841;background:light-dark(#fff0ed,#401f24)}.info{color:#315efb;background:light-dark(#edf1ff,#1c2d52)}.neutral{color:#7a869a;background:light-dark(#f0f2f6,#252f40)}table{width:100%;border-collapse:collapse}th{text-align:left;color:#8994a7;font-size:12px;font-weight:650;background:light-dark(#fafbfe,#172235);padding:12px 13px;border-bottom:1px solid light-dark(#e9edf4,#2b374c);white-space:nowrap}td{padding:14px 13px;border-bottom:1px solid light-dark(#edf0f5,#253147);vertical-align:middle}tbody tr:last-child td{border-bottom:0}tbody tr:hover{background:light-dark(#fafbff,#172235)}.table-wrap{overflow:auto;margin:0 -4px}.identity{display:flex;align-items:center;gap:10px;min-width:140px}.mini-avatar{width:34px;height:34px;border-radius:10px;background:#e8edff;color:#315efb;display:grid;place-items:center;font-weight:750;flex-shrink:0}.identity strong{display:block;font-size:13px}.identity span{display:block;color:#8b96a9;font-size:11px;margin-top:4px}.progress{height:6px;border-radius:8px;background:light-dark(#e9edf5,#2b374c);overflow:hidden}.progress span{height:100%;display:block;background:var(--site-primary);border-radius:8px}.activity{display:flex;gap:12px;padding:12px 0;border-bottom:1px solid light-dark(#edf0f5,#253147)}.activity:last-child{border:0}.activity-icon{width:32px;height:32px;border-radius:9px;display:grid;place-items:center;flex-shrink:0}.activity p{margin:0 0 5px;line-height:1.45}.activity small{color:#8b96a9}.pill{display:inline-flex;align-items:center;border:1px solid light-dark(#e3e8f1,#344158);padding:6px 9px;border-radius:8px;color:#7f8ba0;font-size:12px}.filterbar{display:flex;gap:9px;flex-wrap:wrap;margin-bottom:16px}.field{height:38px;padding:0 11px;border:1px solid light-dark(#dfe5ef,#37445b);border-radius:9px;background:light-dark(#fff,#172235);color:inherit;outline:none;min-width:120px}.field:focus{border-color:#8299ff;box-shadow:0 0 0 3px #315efb1c}.searchfield{min-width:210px;flex:1}.tabs{display:flex;gap:5px;border-bottom:1px solid light-dark(#e6eaf2,#2b374c);margin-bottom:16px}.tab{padding:10px 13px;border:0;border-bottom:2px solid transparent;background:transparent;color:#8994a7;font-weight:650}.tab.active{color:var(--site-primary);border-bottom-color:var(--site-primary)}.chat-layout{display:grid;grid-template-columns:minmax(250px,310px) minmax(300px,1fr) minmax(220px,270px);height:620px;overflow:hidden}.chat-list{border-right:1px solid light-dark(#e5e9f2,#273247);min-width:0}.chat-list-head{padding:14px;border-bottom:1px solid light-dark(#e5e9f2,#273247)}.chat-person{display:flex;gap:10px;padding:14px;border-bottom:1px solid light-dark(#edf0f5,#253147);cursor:pointer}.chat-person.active{background:light-dark(#edf2ff,#1a2b4d)}.chat-person .meta{margin-left:auto;text-align:right;font-size:11px;color:#8994a7}.chat-person p{margin:5px 0 0;color:#8994a7;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:145px}.chat-main{display:flex;flex-direction:column;min-width:0}.chat-header{padding:15px 18px;border-bottom:1px solid light-dark(#e5e9f2,#273247);display:flex;justify-content:space-between;align-items:center}.chat-messages{padding:20px;overflow:auto;flex:1;background:light-dark(#fafbfe,#0f1929)}.dayline{text-align:center;color:#9aa4b6;font-size:11px;margin:2px 0 18px}.bubble-row{display:flex;gap:8px;margin:12px 0;align-items:flex-start}.bubble-row.mine{justify-content:flex-end}.bubble{max-width:78%;padding:11px 13px;border-radius:12px;background:light-dark(#fff,#202d41);border:1px solid light-dark(#e7ebf3,#334057);line-height:1.55}.mine .bubble{background:light-dark(#eaf0ff,#1c2d52);border-color:light-dark(#d7e1ff,#314a7a)}.bubble-meta{font-size:10px;color:#929db0;margin-top:5px}.chat-composer{padding:12px;border-top:1px solid light-dark(#e5e9f2,#273247)}.composer-input{width:100%;min-height:65px;resize:vertical;border:1px solid light-dark(#e0e5ee,#37445b);border-radius:9px;background:light-dark(#fff,#172235);padding:10px;color:inherit}.composer-bottom{display:flex;justify-content:space-between;align-items:center;margin-top:9px}.context-panel{border-left:1px solid light-dark(#e5e9f2,#273247);padding:16px;overflow:auto}.context-section{padding:14px 0;border-bottom:1px solid light-dark(#edf0f5,#253147)}.context-section h4{margin:0 0 12px;font-size:12px}.context-line{display:flex;justify-content:space-between;gap:8px;font-size:12px;margin:10px 0}.node-canvas{min-height:430px;background-color:light-dark(#fafbff,#0f1929);background-image:radial-gradient(light-dark(#dce2ee,#2a374d) 1px,transparent 1px);background-size:18px 18px;border:1px solid light-dark(#e3e8f1,#2b374c);border-radius:12px;position:relative;overflow:hidden}.node{position:absolute;width:165px;padding:13px;background:light-dark(#fff,#172235);border:1px solid light-dark(#dce3ef,#3a4861);border-radius:11px;box-shadow:0 7px 20px #1720330a;cursor:pointer}.node.selected{border-color:var(--site-primary);box-shadow:0 0 0 3px #315efb20}.node .node-type{font-size:10px;color:#8994a7;margin-bottom:8px}.node strong{font-size:12px}.node .node-icon{display:inline-grid;place-items:center;width:23px;height:23px;border-radius:7px;margin-right:7px;background:#eaf0ff;color:#315efb}.connector{position:absolute;height:2px;background:#aab7d0;transform-origin:left center}.step-row{display:flex;align-items:center;gap:12px;padding:12px 0;border-bottom:1px solid light-dark(#edf0f5,#253147)}.step-num{width:28px;height:28px;display:grid;place-items:center;border-radius:8px;background:light-dark(#edf1ff,#1c2d52);color:#315efb;font-weight:750}.model-card{border:1px solid light-dark(#e5e9f2,#2b374c);border-radius:12px;padding:15px}.model-logo{width:36px;height:36px;border-radius:10px;background:light-dark(#edf1ff,#1c2d52);color:#315efb;display:grid;place-items:center;font-weight:800;font-size:16px;margin-bottom:13px}.model-card h4{margin:0 0 5px}.model-card p{margin:0 0 12px;color:#8b96a9;font-size:12px}.setting-row{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:16px 0;border-bottom:1px solid light-dark(#edf0f5,#253147)}.setting-row:last-child{border:0}.setting-row p{margin:5px 0 0;font-size:12px;color:#8b96a9}.switch{width:38px;height:22px;border-radius:20px;background:#315efb;padding:3px;display:flex;justify-content:flex-end;flex-shrink:0}.switch:after{content:"";width:16px;height:16px;background:white;border-radius:50%}.switch.off{background:#b7c0ce;justify-content:flex-start}.toast{position:fixed;right:24px;top:82px;background:light-dark(#fff,#1c293c);border:1px solid light-dark(#dfe5ef,#344158);box-shadow:0 14px 40px #10182820;border-radius:12px;padding:14px 17px;z-index:20;display:none;max-width:330px}.toast.show{display:block;animation:appear .2s ease}.toast strong{display:block;margin-bottom:4px}.toast span{color:#8b96a9;font-size:12px}.modal-backdrop{position:fixed;inset:0;background:#0b122080;z-index:30;display:none;align-items:center;justify-content:center;padding:20px}.modal-backdrop.show{display:flex}.modal{background:light-dark(#fff,#121b2b);border:1px solid light-dark(#e5e9f2,#344158);border-radius:16px;width:min(560px,100%);padding:22px;box-shadow:0 25px 80px #0003}.modal-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:15px}.modal h3{margin:0}.modal p{line-height:1.6;color:#8994a7}.modal-foot{display:flex;justify-content:flex-end;gap:8px;margin-top:20px}.hidden{display:none!important}.mobile-nav{display:none} +@keyframes appear{from{transform:translateY(-5px);opacity:0}to{transform:translateY(0);opacity:1}} +@media(max-width:1200px){.sidebar{width:210px}.content{padding:23px 20px}.stats{grid-template-columns:repeat(2,minmax(0,1fr))}.chat-layout{grid-template-columns:240px minmax(300px,1fr)}.context-panel{display:none}.two-col{grid-template-columns:1fr}.three-col{grid-template-columns:repeat(2,minmax(0,1fr))}.brand{min-width:190px}} +@media(max-width:760px){.topbar{height:60px;padding:0 13px;gap:10px}.brand{min-width:0;font-size:17px}.brand .brand-text{display:none}.instance{display:none}.global-search{max-width:none}.top-actions .icon-btn:nth-child(2){display:none}.shell{display:block;min-height:calc(100vh - 60px)}.sidebar{display:none}.content{padding:20px 13px 80px}.page-head{display:block}.page-head .actions{margin-top:15px}.page-title{font-size:24px}.stats{gap:10px}.card{padding:14px;border-radius:12px}.stat-value{font-size:24px}.three-col{grid-template-columns:1fr}.chat-layout{display:flex;flex-direction:column;height:auto}.chat-list{display:none}.chat-main{min-height:570px}.chat-messages{min-height:330px}.chat-header{padding:12px}.node-canvas{min-height:430px}.node{width:140px;padding:10px}.mobile-nav{display:flex;position:fixed;bottom:0;left:0;right:0;z-index:10;background:light-dark(#fff,#121b2b);border-top:1px solid light-dark(#e5e9f2,#273247);justify-content:space-around;padding:8px 4px calc(8px + env(safe-area-inset-bottom))}.mobile-nav button{border:0;background:transparent;color:#8b96a9;font-size:10px;display:flex;flex-direction:column;gap:4px;align-items:center;min-width:52px}.mobile-nav button span{font-size:18px}.mobile-nav button.active{color:var(--site-primary)}.table-wrap{margin:0}.searchfield{min-width:100%}.filterbar .field{flex:1;min-width:100px}.top-actions .avatar{display:none}} + diff --git a/frontend/src/ui.js b/frontend/src/ui.js new file mode 100644 index 0000000..d0ddba5 --- /dev/null +++ b/frontend/src/ui.js @@ -0,0 +1,144 @@ +import { reactive } from 'vue' + +/** 全局轻提示。只在真实操作返回后调用,禁止用它在请求前伪造成功。 */ +export const toastState = reactive({ visible: false, title: '', body: '', tone: 'info' }) + +let toastTimer = 0 + +export function notify(title, body = '', tone = 'info') { + toastState.title = title + toastState.body = body + toastState.tone = tone + toastState.visible = true + window.clearTimeout(toastTimer) + toastTimer = window.setTimeout(() => { + toastState.visible = false + }, 4200) +} + +export function hideToast() { + toastState.visible = false +} + +export function describeError(error) { + const httpStatus = error?.httpStatus + const code = error?.code || '' + let title = '请求失败' + let hint = '请稍后重试;若持续失败,请查看服务端日志。' + + if (code === 'NETWORK_ERROR') { + title = '无法连接后端' + hint = '后端可能未启动或网络不可达。当前页面不会显示任何伪造数据。' + } else if (code === 'UNAUTHENTICATED' || httpStatus === 401) { + title = '会话已过期' + hint = '请重新登录后继续操作。' + } else if (code === 'FORBIDDEN' || httpStatus === 403) { + title = '权限不足' + hint = '当前账号没有执行该操作的权限,如需授权请联系管理员。' + } else if (code === 'RESOURCE_NOT_FOUND' || httpStatus === 404) { + title = '资源不存在或不可见' + hint = '该对象可能已被删除,或不在当前实例的访问范围内。' + } else if (code === 'RESOURCE_CONFLICT' || httpStatus === 409) { + title = '状态冲突' + hint = '对象当前状态不允许该操作,请刷新后确认最新状态。' + } else if (code === 'VALIDATION_ERROR' || httpStatus === 400 || httpStatus === 422) { + title = '请求参数不合法' + hint = '请检查输入内容后重试。' + } else if (httpStatus === 429) { + title = '请求过于频繁' + hint = '已触发限流,请稍后再试。' + } else if (httpStatus >= 500) { + title = '服务异常' + hint = '后端处理失败,请稍后重试并查看服务端日志。' + } + + return { + title, + message: error?.message || '未知错误', + hint, + code: error?.code || (httpStatus ? `HTTP_${httpStatus}` : ''), + requestId: error?.requestId || '' + } +} + +export function formatTime(value) { + if (!value) return '—' + const date = new Date(value) + if (Number.isNaN(date.getTime())) return String(value) + const pad = (n) => String(n).padStart(2, '0') + return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}` +} + +export function formatShortTime(value) { + if (!value) return '—' + const date = new Date(value) + if (Number.isNaN(date.getTime())) return String(value) + const pad = (n) => String(n).padStart(2, '0') + return `${pad(date.getHours())}:${pad(date.getMinutes())}` +} + +export function formatNumber(value) { + if (value === null || value === undefined || value === '') return '—' + const number = Number(value) + if (Number.isNaN(number)) return String(value) + return number.toLocaleString('zh-CN') +} + +export function formatBytes(value) { + const number = Number(value) + if (!number || Number.isNaN(number)) return '—' + const units = ['B', 'KB', 'MB', 'GB', 'TB'] + let size = number + let index = 0 + while (size >= 1024 && index < units.length - 1) { + size /= 1024 + index += 1 + } + return `${size.toFixed(index === 0 ? 0 : 1)} ${units[index]}` +} + +/** 连接状态/消息状态到语义色调;未知值一律灰,不猜成功。 */ +export function statusTone(value) { + const text = String(value || '').toUpperCase() + if (/FAIL|ERROR|OFFLINE|DISCONNECT|UNBOUND|REJECT/.test(text)) return 'error' + if (/WARN|UNKNOWN|PENDING|RETRY|DOWNLOAD|SILENCED/.test(text)) return 'warning' + if (/CONNECT|ONLINE|SUCCESS|SUCCEED|STORED|NORMAL|BOUND|ACTIVE|UP/.test(text)) return 'success' + if (/RUN|PROCESS|SENDING|QUEUED/.test(text)) return 'info' + return 'muted' +} + +export function connectionLabel(value) { + const map = { + forward_websocket: '正向 WebSocket', + reverse_websocket: '反向 WebSocket', + http_callback: 'HTTP 回调' + } + return map[String(value)] || String(value || '—') +} + +export function directionLabel(value) { + const text = String(value || '').toUpperCase() + if (text === 'INBOUND') return '收到' + if (text === 'OUTBOUND') return '发出' + return value || '—' +} + +export function typeLabel(value) { + const text = String(value || '').toUpperCase() + const map = { + TEXT: '文字', + IMAGE: '图片', + FILE: '文件', + RECORD: '语音', + VOICE: '语音', + VIDEO: '视频', + FACE: '表情', + STICKER: '表情', + REPLY: '引用', + FORWARD: '合并转发', + CARD: '卡片', + JSON: '卡片', + UNKNOWN: '未知' + } + return map[text] || String(value || '—') +} diff --git a/frontend/src/views/AiView.vue b/frontend/src/views/AiView.vue new file mode 100644 index 0000000..e34469e --- /dev/null +++ b/frontend/src/views/AiView.vue @@ -0,0 +1,124 @@ + + + diff --git a/frontend/src/views/AutomationView.vue b/frontend/src/views/AutomationView.vue new file mode 100644 index 0000000..9554a00 --- /dev/null +++ b/frontend/src/views/AutomationView.vue @@ -0,0 +1,133 @@ + + + diff --git a/frontend/src/views/BackupView.vue b/frontend/src/views/BackupView.vue new file mode 100644 index 0000000..5c0d4a7 --- /dev/null +++ b/frontend/src/views/BackupView.vue @@ -0,0 +1,103 @@ + + + diff --git a/frontend/src/views/BindingsView.vue b/frontend/src/views/BindingsView.vue deleted file mode 100644 index 5adabe8..0000000 --- a/frontend/src/views/BindingsView.vue +++ /dev/null @@ -1,124 +0,0 @@ - - - diff --git a/frontend/src/views/BootstrapView.vue b/frontend/src/views/BootstrapView.vue index 5e70e7f..28cf0c8 100644 --- a/frontend/src/views/BootstrapView.vue +++ b/frontend/src/views/BootstrapView.vue @@ -1,37 +1,89 @@ diff --git a/frontend/src/views/ConnectionsView.vue b/frontend/src/views/ConnectionsView.vue new file mode 100644 index 0000000..c05721c --- /dev/null +++ b/frontend/src/views/ConnectionsView.vue @@ -0,0 +1,324 @@ + + + diff --git a/frontend/src/views/DashboardView.vue b/frontend/src/views/DashboardView.vue new file mode 100644 index 0000000..6b5a76f --- /dev/null +++ b/frontend/src/views/DashboardView.vue @@ -0,0 +1,251 @@ + + + diff --git a/frontend/src/views/LoginView.vue b/frontend/src/views/LoginView.vue index 035f1c9..395c9c8 100644 --- a/frontend/src/views/LoginView.vue +++ b/frontend/src/views/LoginView.vue @@ -1,35 +1,69 @@