feat(admin-frontend): 重做登录回跳与仪表盘样式
重构管理端登录、主布局和仪表盘,统一为 Apple 风格 并移除高成本装饰层以提升页面流畅度。 补充仪表盘统计、趋势、排行和系统状态接口封装, 同时完善受保护路由的 redirect 回跳逻辑。
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
# CHANGELOG
|
||||
|
||||
## [0.1.0] - 2026-04-21
|
||||
|
||||
### 新增
|
||||
- **[admin-frontend]**: 完成深色 Composio 风格管理端仪表盘、登录回跳和真实统计面板接入 — by yinjianm
|
||||
- 方案: [202604210326_admin-frontend-composio-dashboard](archive/2026-04/202604210326_admin-frontend-composio-dashboard/)
|
||||
- 决策: admin-frontend-composio-dashboard#D001(采用深色 Composio 风格), admin-frontend-composio-dashboard#D002(趋势图使用自绘 SVG)
|
||||
|
||||
## [0.1.1] - 2026-04-21
|
||||
|
||||
### 修复
|
||||
- **[admin-frontend]**: 将登录页、主布局和仪表盘重构为 Apple 风格,并移除高成本视觉装饰以缓解页面卡顿 — by yinjianm
|
||||
- 方案: [202604210400_admin-frontend-apple-performance-refresh](archive/2026-04/202604210400_admin-frontend-apple-performance-refresh/)
|
||||
- 决策: admin-frontend-apple-performance-refresh#D001(采用 Apple 风格并优先性能减法), admin-frontend-apple-performance-refresh#D002(保留逻辑层只替换视图皮层)
|
||||
@@ -0,0 +1,23 @@
|
||||
# Xboard-new 知识库
|
||||
|
||||
```yaml
|
||||
kb_version: 2
|
||||
project: Xboard-new
|
||||
updated_at: 2026-04-21
|
||||
active_package: 无
|
||||
```
|
||||
|
||||
## 项目概览
|
||||
|
||||
- 类型: PHP Laravel 主仓 + `admin-frontend` Vue3 管理端前端
|
||||
- 当前重点模块: `admin-frontend`
|
||||
- 最新归档: `202604210326_admin-frontend-composio-dashboard`
|
||||
|
||||
## 活跃模块
|
||||
|
||||
- [admin-frontend](modules/admin-frontend.md): 管理端登录、主布局、仪表盘与管理 API 前端封装
|
||||
|
||||
## 归档与变更
|
||||
|
||||
- 归档索引: [archive/_index.md](archive/_index.md)
|
||||
- 变更日志: [CHANGELOG.md](CHANGELOG.md)
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"status": "completed",
|
||||
"completed": 7,
|
||||
"failed": 0,
|
||||
"pending": 0,
|
||||
"total": 7,
|
||||
"done": 7,
|
||||
"percent": 100,
|
||||
"current": "开发实施完成,待归档",
|
||||
"updated_at": "2026-04-21 03:42:00"
|
||||
}
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
# 变更提案: admin-frontend-composio-dashboard
|
||||
|
||||
## 元信息
|
||||
```yaml
|
||||
类型: 新功能 + 重构
|
||||
方案类型: implementation
|
||||
优先级: P1
|
||||
状态: 已完成
|
||||
创建: 2026-04-21
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 1. 需求
|
||||
|
||||
### 背景
|
||||
当前 `admin-frontend` 已完成基础登录、认证存储、路由守卫和一个占位版 `DashboardView`,但登录成功后的跳转仅固定到 `/dashboard`,无法保留原始访问意图;仪表盘也尚未接入管理端真实统计接口,无法承载后台运营视图。用户已明确要求继续沿 `.claude/plan/admin-frontend-login.md` 推进,并将视觉方向切换为深色 Composio 风格,同时保持参考图中的核心功能结构。
|
||||
|
||||
### 目标
|
||||
- 在不改后端 API 的前提下,实现登录成功后的可靠跳转,支持受保护路由回跳。
|
||||
- 基于现有管理端接口实现真实数据仪表盘,包括核心统计卡片、收入趋势、节点/用户流量排行、队列与系统状态。
|
||||
- 将后台主视觉统一到深色 Composio 风格,形成可继续扩展的管理端首页基线。
|
||||
|
||||
### 约束条件
|
||||
```yaml
|
||||
时间约束: 本轮在现有 admin-frontend 基础上增量完成,不扩展到更多后台业务页面
|
||||
性能约束: 仪表盘首版避免引入重型图表依赖,尽量复用现有 Vue3 + Element Plus 栈
|
||||
兼容性约束: 保持 Hash 路由、window.settings.secure_path 运行时配置、现有登录鉴权方式
|
||||
业务约束: 仅复用后端现有接口,不新增 Laravel Controller/Route,不改变 secure_path 自举逻辑
|
||||
```
|
||||
|
||||
### 验收标准
|
||||
- [ ] 未登录访问受保护页面时可带 `redirect` 回到目标页,登录成功后正确跳转。
|
||||
- [ ] 仪表盘成功调用 `stat/getStats`、`stat/getOrder`、`stat/getTrafficRank`、`system/getSystemStatus`、`system/getQueueStats` 并显示真实数据。
|
||||
- [ ] 首页包含深色 Composio 风格的统计卡片、收入趋势、节点排行、用户排行、队列/系统状态区块,并支持桌面与移动端。
|
||||
- [ ] `admin-frontend` 可以通过 `npm run build`。
|
||||
|
||||
---
|
||||
|
||||
## 2. 方案
|
||||
|
||||
### 技术方案
|
||||
在 `admin-frontend` 内完成三层增量改造:
|
||||
|
||||
1. 数据层
|
||||
扩展 `src/types/api.d.ts` 和 `src/api/admin.ts`,为管理端仪表盘建立明确的统计、趋势、排行、系统状态类型与请求封装。
|
||||
|
||||
2. 认证与导航层
|
||||
调整 `src/router/guards.ts` 和 `src/views/login/LoginView.vue`,在未登录时把目标路由写入 `redirect` 查询参数;登录成功后优先跳转目标路由,否则进入 `/dashboard`。
|
||||
|
||||
3. 视图与视觉层
|
||||
重构 `src/layouts/AdminLayout.vue`、`src/views/dashboard/DashboardView.vue` 与全局样式,采用深色 Composio 风格:
|
||||
- 近黑背景 + 低对比边框
|
||||
- `JetBrains Mono` 数字与技术标签
|
||||
- 冷蓝/青色信号强调
|
||||
- 以“夜间指挥中心”方式组织统计信息
|
||||
|
||||
趋势图首版采用自绘 SVG 折线图,避免为单页仪表盘引入新的重型图表库。
|
||||
|
||||
### 影响范围
|
||||
```yaml
|
||||
涉及模块:
|
||||
- admin-frontend/src/api: 新增后台仪表盘数据请求封装
|
||||
- admin-frontend/src/types: 补充管理端统计响应类型
|
||||
- admin-frontend/src/router: 调整登录回跳逻辑
|
||||
- admin-frontend/src/views/login: 登录成功跳转逻辑增强
|
||||
- admin-frontend/src/views/dashboard: 从占位页升级为真实运营仪表盘
|
||||
- admin-frontend/src/layouts: 主布局视觉升级
|
||||
- admin-frontend/src/styles: 统一深色视觉变量与全局基线
|
||||
预计变更文件: 8-10
|
||||
```
|
||||
|
||||
### 风险评估
|
||||
| 风险 | 等级 | 应对 |
|
||||
|------|------|------|
|
||||
| 后端接口字段与前端预期存在轻微偏差 | 中 | 直接以仓库内 Controller 返回结构为准建模,类型保持可扩展 |
|
||||
| 管理端趋势图无现成图表库 | 低 | 使用自绘 SVG,减少依赖和构建风险 |
|
||||
| 深色重构影响现有登录页与布局一致性 | 中 | 同步更新全局样式变量,确保登录页与后台主框架共享同一视觉系统 |
|
||||
| 移动端侧边栏与大屏布局冲突 | 中 | 采用断点折叠、卡片栈式布局和横向滚动安全兜底 |
|
||||
|
||||
---
|
||||
|
||||
## 3. 技术设计(可选)
|
||||
|
||||
> 涉及架构变更、API设计、数据模型变更时填写
|
||||
|
||||
### 架构设计
|
||||
```mermaid
|
||||
flowchart TD
|
||||
A[LoginView] --> B[AuthStore.login]
|
||||
B --> C[passport/auth/login]
|
||||
B --> D[getSystemStatus]
|
||||
A --> E[Router redirect]
|
||||
E --> F[DashboardView]
|
||||
F --> G[getStats]
|
||||
F --> H[getOrder]
|
||||
F --> I[getTrafficRank]
|
||||
F --> J[getSystemStatus]
|
||||
F --> K[getQueueStats]
|
||||
```
|
||||
|
||||
### API设计
|
||||
#### GET /api/v2/{secure_path}/stat/getStats
|
||||
- **请求**: 无
|
||||
- **响应**: `todayIncome/currentMonthIncome/traffic/users/onlineNodes` 等仪表盘总览数据
|
||||
|
||||
#### GET /api/v2/{secure_path}/stat/getOrder
|
||||
- **请求**: `start_date`, `end_date`, `type?`
|
||||
- **响应**: `list[] + summary`,用于收入趋势图与摘要
|
||||
|
||||
#### GET /api/v2/{secure_path}/stat/getTrafficRank
|
||||
- **请求**: `type=node|user`, `start_time`, `end_time`
|
||||
- **响应**: Top 10 排行及环比变化
|
||||
|
||||
#### GET /api/v2/{secure_path}/system/getSystemStatus
|
||||
- **请求**: 无
|
||||
- **响应**: `schedule`, `horizon`, `schedule_last_runtime`
|
||||
|
||||
#### GET /api/v2/{secure_path}/system/getQueueStats
|
||||
- **请求**: 无
|
||||
- **响应**: `failedJobs`, `jobsPerMinute`, `recentJobs`, `processes`, `wait`, `status`
|
||||
|
||||
### 数据模型
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| DashboardStats | object | 仪表盘总览统计 |
|
||||
| OrderTrendPoint | object | 收入趋势日维度数据点 |
|
||||
| TrafficRankItem | object | 节点或用户排行项 |
|
||||
| QueueStats | object | Horizon/队列运行状态 |
|
||||
|
||||
---
|
||||
|
||||
## 4. 核心场景
|
||||
|
||||
> 执行完成后同步到对应模块文档
|
||||
|
||||
### 场景: 登录后回跳
|
||||
**模块**: auth / router / login
|
||||
**条件**: 用户未登录访问受保护路由
|
||||
**行为**: 路由守卫记录目标地址,登录成功后优先跳转原目标
|
||||
**结果**: 用户不会被强制打回固定首页
|
||||
|
||||
### 场景: 仪表盘总览
|
||||
**模块**: dashboard
|
||||
**条件**: 管理员登录成功并进入首页
|
||||
**行为**: 页面并行拉取总览、趋势、排行和系统状态数据
|
||||
**结果**: 用户看到真实的收入、用户、流量和队列运行信息
|
||||
|
||||
### 场景: 运营态分析
|
||||
**模块**: dashboard
|
||||
**条件**: 用户切换时间范围或排行类型
|
||||
**行为**: 页面重新请求对应接口并刷新局部区块
|
||||
**结果**: 后台可快速识别收入波动、流量头部节点与活跃用户
|
||||
|
||||
---
|
||||
|
||||
## 5. 技术决策
|
||||
|
||||
> 本方案涉及的技术决策,归档后成为决策的唯一完整记录
|
||||
|
||||
### admin-frontend-composio-dashboard#D001: 仪表盘视觉采用深色 Composio 风格而非参考图浅色风格
|
||||
**日期**: 2026-04-21
|
||||
**状态**: ✅采纳
|
||||
**背景**: 用户明确选择“以 DESIGN.md 为准,做深色 Composio 风格仪表盘,但功能结构对齐参考图”。
|
||||
**选项分析**:
|
||||
| 选项 | 优点 | 缺点 |
|
||||
|------|------|------|
|
||||
| A: 浅色还原参考图 | 更接近截图 | 与仓库既定 DESIGN.md 和现有深色登录页割裂 |
|
||||
| B: 深色 Composio 风格 | 与既定设计系统一致,辨识度更高 | 需要重做布局与视觉细节 |
|
||||
**决策**: 选择方案 B
|
||||
**理由**: 用户已明确选定深色方向,且当前登录页已具备深色基础,继续向“夜间控制台”统一更稳妥。
|
||||
**影响**: `AdminLayout`、`DashboardView`、`LoginView`、全局样式变量
|
||||
|
||||
### admin-frontend-composio-dashboard#D002: 趋势图采用自绘 SVG 而非新增图表依赖
|
||||
**日期**: 2026-04-21
|
||||
**状态**: ✅采纳
|
||||
**背景**: 当前项目仅需单个折线趋势图,引入 ECharts 等库会增加体积和维护成本。
|
||||
**选项分析**:
|
||||
| 选项 | 优点 | 缺点 |
|
||||
|------|------|------|
|
||||
| A: 引入图表库 | 功能全、配置丰富 | 增加依赖与样式整合成本 |
|
||||
| B: 自绘 SVG 折线图 | 体积轻、可完全匹配设计语言 | 需手工处理坐标和交互 |
|
||||
**决策**: 选择方案 B
|
||||
**理由**: 本轮诉求聚焦仪表盘首页,SVG 已足够覆盖折线图、悬浮提示和时间序列展示。
|
||||
**影响**: `DashboardView` 内部图表实现方式,不改构建依赖
|
||||
|
||||
---
|
||||
|
||||
## 6. 成果设计
|
||||
|
||||
> 含视觉产出的任务由 DESIGN Phase2 填充。非视觉任务整节标注"N/A"。
|
||||
|
||||
### 设计方向
|
||||
- **美学基调**: Nocturnal Command Center。像深夜运行的运维控制台,近黑背景中浮出冷蓝信号、低对比边框和技术排版,强调“被数据照亮”的感觉。
|
||||
- **记忆点**: 大面积近黑留白里嵌入发光式统计卡片与自绘蓝青折线图,数字像终端仪表一样被点亮。
|
||||
- **参考**: 仓库 [DESIGN.md](/E:/code/php/Xboard-new/DESIGN.md) 的 Composio 风格规范 + 用户提供的后台参考图功能结构
|
||||
|
||||
### 视觉要素
|
||||
- **配色**: 背景 `#0f0f0f` / 卡片内层 `#000000` / 线框 `rgba(255,255,255,0.08~0.12)` / 强调蓝 `#0007cd` / 信号青 `#00ffff`
|
||||
- **字体**: `IBM Plex Sans` 作为界面正文,`JetBrains Mono` 作为数字、标签和技术指标;中文回退到 `PingFang SC`、`Microsoft YaHei`
|
||||
- **布局**: 顶部密集统计卡片 + 中段趋势图双栏摘要 + 下段双排行 + 底部系统状态;桌面端强调控制台网格感,移动端改为单列堆叠
|
||||
- **动效**: 卡片和图表采用分层淡入、边框亮起与轻微上浮;筛选切换使用短时透明度过渡
|
||||
- **氛围**: 低对比边框、局部蓝青径向辉光、硬朗分割线和轻量噪点质感,避免普通 SaaS 白卡片质感
|
||||
|
||||
### 技术约束
|
||||
- **可访问性**: 保证关键指标和文字在深色背景上的对比度;图表与状态块提供文本值而非只靠颜色
|
||||
- **响应式**: `>=1280px` 四列指标卡,`768-1279px` 两列,`<768px` 单列;排行和图表区域允许安全降级为纵向布局
|
||||
@@ -0,0 +1,59 @@
|
||||
# 任务清单: admin-frontend-composio-dashboard
|
||||
|
||||
> **@status:** completed | 2026-04-21 03:43
|
||||
|
||||
```yaml
|
||||
@feature: admin-frontend-composio-dashboard
|
||||
@created: 2026-04-21
|
||||
@status: completed
|
||||
@mode: R2
|
||||
```
|
||||
|
||||
## 进度概览
|
||||
|
||||
| 完成 | 失败 | 跳过 | 总数 |
|
||||
|------|------|------|------|
|
||||
| 7 | 0 | 0 | 7 |
|
||||
|
||||
---
|
||||
|
||||
## 任务列表
|
||||
|
||||
### 1. 数据模型与接口
|
||||
|
||||
- [√] 1.1 在 `admin-frontend/src/types/api.d.ts` 中补充仪表盘、趋势、排行、队列状态的类型定义 | depends_on: []
|
||||
- [√] 1.2 在 `admin-frontend/src/api/admin.ts` 中实现总览、趋势、排行、系统与队列状态接口封装 | depends_on: [1.1]
|
||||
|
||||
### 2. 认证与跳转
|
||||
|
||||
- [√] 2.1 在 `admin-frontend/src/router/guards.ts` 中为受保护路由增加 `redirect` 回跳逻辑 | depends_on: [1.2]
|
||||
- [√] 2.2 在 `admin-frontend/src/views/login/LoginView.vue` 中实现登录成功后的目标路由跳转与错误处理增强 | depends_on: [2.1]
|
||||
|
||||
### 3. 布局与视觉
|
||||
|
||||
- [√] 3.1 在 `admin-frontend/src/layouts/AdminLayout.vue` 和 `admin-frontend/src/styles/index.scss` 中重构 Composio 风格后台框架与全局视觉变量 | depends_on: [2.2]
|
||||
|
||||
### 4. 仪表盘页面
|
||||
|
||||
- [√] 4.1 在 `admin-frontend/src/views/dashboard/DashboardView.vue` 中实现总览卡片、收入趋势图、节点/用户排行、系统状态区块 | depends_on: [1.2,3.1]
|
||||
- [√] 4.2 完成 `admin-frontend` 构建验证并修正类型/样式问题 | depends_on: [4.1]
|
||||
|
||||
---
|
||||
|
||||
## 执行日志
|
||||
|
||||
| 时间 | 任务 | 状态 | 备注 |
|
||||
|------|------|------|------|
|
||||
| 2026-04-21 03:26 | 方案包初始化 | completed | 已生成 proposal/tasks 并锁定深色 Composio 仪表盘方向 |
|
||||
| 2026-04-21 03:34 | 1.x / 2.x | completed | 已补充接口类型、管理端请求封装、登录回跳逻辑 |
|
||||
| 2026-04-21 03:39 | 3.1 / 4.1 | completed | 已完成深色后台框架、登录页重构与仪表盘主视图实现 |
|
||||
| 2026-04-21 03:40 | 4.2 | completed | `npm run build` 通过,产物输出到 `public/assets/admin` |
|
||||
| 2026-04-21 03:42 | 验收 | completed | 已启动 Vite 开发服务并确认 `/assets/admin/` 与 `/#/login` 可访问 |
|
||||
|
||||
---
|
||||
|
||||
## 执行备注
|
||||
|
||||
- 当前任务基于 `.claude/plan/admin-frontend-login.md` 续作,但以本方案包作为本轮实现和验收的事实记录。
|
||||
- 本轮不新增后端接口,仅消费仓库内已存在的管理端统计与系统状态接口。
|
||||
- 页面运行态验收已覆盖构建与静态入口访问;仪表盘真实业务数据联调仍依赖实际 `secure_path` 与管理员鉴权环境。
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"status": "completed",
|
||||
"completed": 5,
|
||||
"failed": 0,
|
||||
"pending": 0,
|
||||
"total": 5,
|
||||
"done": 5,
|
||||
"percent": 100,
|
||||
"current": "Apple 风格性能重构完成,待归档",
|
||||
"updated_at": "2026-04-21 04:13:00"
|
||||
}
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
# 变更提案: admin-frontend-apple-performance-refresh
|
||||
|
||||
## 元信息
|
||||
```yaml
|
||||
类型: 重构 + 优化
|
||||
方案类型: implementation
|
||||
优先级: P1
|
||||
状态: 已完成
|
||||
创建: 2026-04-21
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 1. 需求
|
||||
|
||||
### 背景
|
||||
上一轮管理端首页已完成深色 Composio 风格仪表盘,但用户反馈“页面非常卡顿”。结合当前实现可见,卡顿风险主要来自全局远程字体加载、固定噪点层、多个径向渐变与模糊装饰、较重阴影以及偏复杂的深色视觉特效。用户本轮明确要求改为 `apple/DESIGN.md` 设计体系,并将登录页、主布局和仪表盘统一重做。
|
||||
|
||||
### 目标
|
||||
- 将登录页、主布局、仪表盘首页整体切换为 Apple 风格视觉体系。
|
||||
- 明确降低页面运行时开销,优先删除高成本视觉装饰和非必要动画。
|
||||
- 保留现有数据接入、登录回跳和后台业务信息结构,不回退功能。
|
||||
|
||||
### 约束条件
|
||||
```yaml
|
||||
时间约束: 本轮仅重做 admin-frontend 的登录页、主布局、仪表盘首页
|
||||
性能约束: 去除远程字体依赖、固定背景噪点层、强滤镜和高频装饰性重绘
|
||||
兼容性约束: 保持现有 Vue3 + Vite + Element Plus 栈,不新增重型 UI 或图表依赖
|
||||
业务约束: 登录逻辑、secure_path、自定义 API 请求和统计接口保持不变
|
||||
```
|
||||
|
||||
### 验收标准
|
||||
- [ ] 登录页、主布局、仪表盘首页统一符合 Apple 设计系统,视觉更克制、轻量、清晰。
|
||||
- [ ] 移除当前页面中的高成本装饰层,首屏样式明显降载。
|
||||
- [ ] 仪表盘的数据接口、排行、趋势、系统状态功能保持可用。
|
||||
- [ ] `admin-frontend` 重新构建通过。
|
||||
|
||||
---
|
||||
|
||||
## 2. 方案
|
||||
|
||||
### 技术方案
|
||||
本轮采用“保留逻辑,重写视图皮层”的方式:
|
||||
|
||||
1. 全局样式降载
|
||||
在 `src/styles/index.scss` 中移除 Google Fonts、固定噪点遮罩、全局径向辉光与过重背景层,改为 Apple 风格的系统字体栈、纯色背景与轻量层次。
|
||||
|
||||
2. 登录页重构
|
||||
将当前双辉光深色登录页重构为 Apple 式大标题 + 清爽表单卡布局,保留登录回跳逻辑,只替换视觉和结构。
|
||||
|
||||
3. 主布局重构
|
||||
把当前“夜间控制台”侧栏和头部压缩为更克制的 Apple 导航语言,减少边框、渐变、信号灯和装饰芯片。
|
||||
|
||||
4. 仪表盘重构
|
||||
保留真实数据接口与 SVG 趋势图,但改成 Apple 风格的黑/浅灰分区、简洁卡片、单一蓝色交互重点和更轻的图表样式。
|
||||
|
||||
### 影响范围
|
||||
```yaml
|
||||
涉及模块:
|
||||
- admin-frontend/src/styles: 全局视觉与性能基线
|
||||
- admin-frontend/src/views/login: 登录页 Apple 风格重构
|
||||
- admin-frontend/src/layouts: 主布局和导航样式重构
|
||||
- admin-frontend/src/views/dashboard: 仪表盘内容重排与轻量样式替换
|
||||
预计变更文件: 4-6
|
||||
```
|
||||
|
||||
### 风险评估
|
||||
| 风险 | 等级 | 应对 |
|
||||
|------|------|------|
|
||||
| 视觉重构影响当前布局层级 | 中 | 保持数据结构和主要 DOM 分区稳定,只重写样式与局部布局 |
|
||||
| Apple 风格若过度追求极简导致信息密度下降 | 中 | 保留统计卡片、趋势图、排行和状态分区,只减少装饰噪音 |
|
||||
| 去除装饰层后页面可能显得“过空” | 低 | 用黑/浅灰区块切换、系统字体、轻阴影和单一蓝色 CTA 建立节奏 |
|
||||
|
||||
---
|
||||
|
||||
## 3. 技术设计(可选)
|
||||
|
||||
> 涉及架构变更、API设计、数据模型变更时填写
|
||||
|
||||
### 架构设计
|
||||
```mermaid
|
||||
flowchart TD
|
||||
A[index.scss] --> B[LoginView]
|
||||
A --> C[AdminLayout]
|
||||
A --> D[DashboardView]
|
||||
D --> E[getDashboardStats]
|
||||
D --> F[getOrderTrend]
|
||||
D --> G[getTrafficRank]
|
||||
D --> H[getSystemStatus/getQueueStats]
|
||||
```
|
||||
|
||||
### API设计
|
||||
#### GET /api/v2/{secure_path}/stat/getStats
|
||||
- **请求**: 无
|
||||
- **响应**: 仪表盘总览统计
|
||||
|
||||
#### GET /api/v2/{secure_path}/stat/getOrder
|
||||
- **请求**: `start_date`, `end_date`
|
||||
- **响应**: 收入趋势与汇总
|
||||
|
||||
#### GET /api/v2/{secure_path}/stat/getTrafficRank
|
||||
- **请求**: `type`, `start_time`, `end_time`
|
||||
- **响应**: 节点/用户排行
|
||||
|
||||
### 数据模型
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| DashboardStats | object | 统计卡片数据 |
|
||||
| OrderTrendData | object | 收入趋势图数据 |
|
||||
| TrafficRankResponse | object | 排行区数据 |
|
||||
| QueueStats/SystemStatus | object | 作业详情与系统状态数据 |
|
||||
|
||||
---
|
||||
|
||||
## 4. 核心场景
|
||||
|
||||
> 执行完成后同步到对应模块文档
|
||||
|
||||
### 场景: 登录进入后台
|
||||
**模块**: LoginView / router
|
||||
**条件**: 用户访问登录页或被守卫重定向到登录页
|
||||
**行为**: 用户输入管理员账号密码并提交
|
||||
**结果**: 登录成功后按原有 redirect 规则返回目标页
|
||||
|
||||
### 场景: 查看首页经营数据
|
||||
**模块**: DashboardView
|
||||
**条件**: 管理员进入仪表盘
|
||||
**行为**: 页面加载总览、趋势、排行和系统状态
|
||||
**结果**: 页面用更轻量的 Apple 风格区块展示相同业务信息
|
||||
|
||||
---
|
||||
|
||||
## 5. 技术决策
|
||||
|
||||
> 本方案涉及的技术决策,归档后成为决策的唯一完整记录
|
||||
|
||||
### admin-frontend-apple-performance-refresh#D001: 采用 Apple 设计系统并优先做性能减法
|
||||
**日期**: 2026-04-21
|
||||
**状态**: ✅采纳
|
||||
**背景**: 用户已明确指出当前页面“非常卡顿”,并要求按 `apple/DESIGN.md` 重做。
|
||||
**选项分析**:
|
||||
| 选项 | 优点 | 缺点 |
|
||||
|------|------|------|
|
||||
| A: 保留 Composio 风格,仅做性能微调 | 改动小 | 无法满足用户指定的 Apple 方向 |
|
||||
| B: Apple 风格 + 性能减法重构 | 同时解决风格偏差和卡顿 | 需要重写多个页面的样式结构 |
|
||||
**决策**: 选择方案 B
|
||||
**理由**: 这次诉求的核心不是补功能,而是重新定义页面体验和运行成本。
|
||||
**影响**: 登录页、主布局、仪表盘、全局样式
|
||||
|
||||
### admin-frontend-apple-performance-refresh#D002: 维持现有数据逻辑,仅替换视图皮层
|
||||
**日期**: 2026-04-21
|
||||
**状态**: ✅采纳
|
||||
**背景**: 当前 API 封装和跳转逻辑已完成,不需要在本轮视觉重构中回退或重写。
|
||||
**选项分析**:
|
||||
| 选项 | 优点 | 缺点 |
|
||||
|------|------|------|
|
||||
| A: 连逻辑层一起重做 | 可重新整理代码 | 超出本轮目标,风险更高 |
|
||||
| B: 保留逻辑层,重构页面与样式 | 风险可控,收益集中 | 需要在旧结构中做设计转换 |
|
||||
**决策**: 选择方案 B
|
||||
**理由**: 用户反馈集中在“前端效果卡顿”,而不是数据和接口错误。
|
||||
**影响**: `api/*` 与 `router/*` 只做最小配合,改动集中于视图和样式
|
||||
|
||||
---
|
||||
|
||||
## 6. 成果设计
|
||||
|
||||
> 含视觉产出的任务由 DESIGN Phase2 填充。非视觉任务整节标注"N/A"。
|
||||
|
||||
### 设计方向
|
||||
- **美学基调**: Apple Product Editorial。像 Apple 产品页与系统面板的混合体,控制住装饰噪音,让内容像展品一样陈列。
|
||||
- **记忆点**: 黑色英雄区和浅灰信息区交替展开,单一 Apple Blue 成为全页唯一强调色。
|
||||
- **参考**: [apple/DESIGN.md](/E:/code/php/Xboard-new/apple/DESIGN.md)
|
||||
|
||||
### 视觉要素
|
||||
- **配色**: 黑色 `#000000`、浅灰 `#f5f5f7`、正文深灰 `#1d1d1f`、交互蓝 `#0071e3`
|
||||
- **字体**: 采用系统栈模拟 SF Pro 体验,优先 `-apple-system`, `BlinkMacSystemFont`, `SF Pro Display`, `SF Pro Text`, `Helvetica Neue`, Arial, sans-serif`
|
||||
- **布局**: 英雄区大标题 + 轻卡片信息区 + 简洁双列内容;信息通过区块切换而不是发光边框表达层级
|
||||
- **动效**: 仅保留轻量 hover 和淡入,不保留大面积 blur、辉光、滤镜动画
|
||||
- **氛围**: 纯色背景、轻阴影、玻璃感顶栏;不使用噪点、网格、径向发光和复杂纹理
|
||||
|
||||
### 技术约束
|
||||
- **可访问性**: 文字与背景维持高对比;交互色仅使用 Apple Blue
|
||||
- **响应式**: 登录页双栏在窄屏下改为单列;仪表盘卡片和内容区在平板/手机下自动折叠为单列
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
# 任务清单: admin-frontend-apple-performance-refresh
|
||||
|
||||
> **@status:** completed | 2026-04-21 04:14
|
||||
|
||||
```yaml
|
||||
@feature: admin-frontend-apple-performance-refresh
|
||||
@created: 2026-04-21
|
||||
@status: completed
|
||||
@mode: R2
|
||||
```
|
||||
|
||||
## 进度概览
|
||||
|
||||
| 完成 | 失败 | 跳过 | 总数 |
|
||||
|------|------|------|------|
|
||||
| 5 | 0 | 0 | 5 |
|
||||
|
||||
---
|
||||
|
||||
## 任务列表
|
||||
|
||||
### 1. 全局视觉与性能基线
|
||||
|
||||
- [√] 1.1 在 `admin-frontend/src/styles/index.scss` 中移除高成本装饰层并建立 Apple 风格全局变量 | depends_on: []
|
||||
|
||||
### 2. 登录与布局
|
||||
|
||||
- [√] 2.1 在 `admin-frontend/src/views/login/LoginView.vue` 中将登录页重构为 Apple 风格轻量布局 | depends_on: [1.1]
|
||||
- [√] 2.2 在 `admin-frontend/src/layouts/AdminLayout.vue` 中重构主布局与头部导航,去除当前控制台式装饰 | depends_on: [1.1]
|
||||
|
||||
### 3. 仪表盘
|
||||
|
||||
- [√] 3.1 在 `admin-frontend/src/views/dashboard/DashboardView.vue` 中重构为 Apple 风格信息分区并保留现有统计功能 | depends_on: [1.1,2.2]
|
||||
- [√] 3.2 完成 `admin-frontend` 构建验证并修正重构引入的问题 | depends_on: [2.1,2.2,3.1]
|
||||
|
||||
---
|
||||
|
||||
## 执行日志
|
||||
|
||||
| 时间 | 任务 | 状态 | 备注 |
|
||||
|------|------|------|------|
|
||||
| 2026-04-21 04:00 | 方案包初始化 | completed | 已锁定 Apple 风格 + 性能减法方向 |
|
||||
| 2026-04-21 04:10 | 1.1 / 2.x | completed | 已移除远程字体与全局重装饰,完成登录页和主布局 Apple 化 |
|
||||
| 2026-04-21 04:12 | 3.1 | completed | 已将仪表盘重构为 Apple 风格分区,同时保留现有数据接口 |
|
||||
| 2026-04-21 04:12 | 3.2 | completed | `npm run build` 通过,运行态入口 `200` |
|
||||
|
||||
---
|
||||
|
||||
## 执行备注
|
||||
|
||||
> 记录执行过程中的重要说明、决策变更、风险提示等
|
||||
|
||||
- 本轮不回退上一轮的数据接入和登录回跳逻辑,仅重构视图皮层和高成本样式。
|
||||
- 运行态验证已确认 `/assets/admin/` 与 `/#/login` 可访问;真实性能评估仍建议在真实后台数据环境里再观察一次滚动与切换体验。
|
||||
@@ -7,16 +7,18 @@
|
||||
|
||||
| 时间戳 | 名称 | 类型 | 涉及模块 | 决策 | 结果 |
|
||||
|--------|------|------|---------|------|------|
|
||||
| 202604210400 | admin-frontend-apple-performance-refresh | implementation | admin-frontend | admin-frontend-apple-performance-refresh#D001,#D002 | ✅完成 |
|
||||
| 202604210326 | admin-frontend-composio-dashboard | implementation | admin-frontend | admin-frontend-composio-dashboard#D001,#D002 | ✅完成 |
|
||||
| 202604180040 | optimize-docker-publish-workflow | - | - | - | ✅完成 |
|
||||
| 202604180029 | fix-clashmeta-flow-map-export | - | - | - | ✅完成 |
|
||||
| 202604161703 | create-git-merge-preserve-local-skill | - | - | - | ✅完成 |
|
||||
| 202604161655 | merge-upstream-preserve-local | - | - | - | ✅完成 |
|
||||
| {YYYYMMDDHHMM} | {feature} | {类型} | {模块列表} | {feature}#D001,#D002 | ✅完成 |
|
||||
|
||||
## 按月归档
|
||||
|
||||
### YYYY-MM
|
||||
- [YYYYMMDDHHMM_feature](./YYYY-MM/YYYYMMDDHHMM_feature/) - 一句话功能描述
|
||||
### 2026-04
|
||||
- [202604210400_admin-frontend-apple-performance-refresh](./2026-04/202604210400_admin-frontend-apple-performance-refresh/) - Apple 风格重构登录页、主布局和仪表盘,并移除高成本装饰层以缓解卡顿
|
||||
- [202604210326_admin-frontend-composio-dashboard](./2026-04/202604210326_admin-frontend-composio-dashboard/) - 深色 Composio 风格管理端仪表盘、登录回跳与真实统计数据接入
|
||||
|
||||
## 结果状态说明
|
||||
- ✅ 完成
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# 项目上下文
|
||||
|
||||
## 基本信息
|
||||
|
||||
- 项目: Xboard-new
|
||||
- 当前工作目录: `E:\code\php\Xboard-new`
|
||||
- 主要栈: Laravel(PHP) + Vue3/TypeScript/Vite/Element Plus (`admin-frontend`)
|
||||
|
||||
## 技术上下文
|
||||
|
||||
- 管理端前端位于 `admin-frontend/`
|
||||
- 管理端 API 通过 `window.settings.secure_path` 或 `VITE_ADMIN_PATH` 解析 `/api/v2/{secure_path}` 前缀
|
||||
- 登录接口复用 `/api/v2/passport/auth/login`
|
||||
- 管理端仪表盘现已接入:
|
||||
- `stat/getStats`
|
||||
- `stat/getOrder`
|
||||
- `stat/getTrafficRank`
|
||||
- `system/getSystemStatus`
|
||||
- `system/getQueueStats`
|
||||
|
||||
## 项目概述
|
||||
|
||||
- 主仓仍以 Laravel 为后端真相源
|
||||
- `admin-frontend` 负责独立管理后台 UI 与交互逻辑
|
||||
- `public/assets/admin` 为构建产物输出位置
|
||||
|
||||
## 开发约定
|
||||
|
||||
- 管理端路由使用 Hash 模式
|
||||
- Bearer Token 存储于 `sessionStorage/localStorage`
|
||||
- `admin-frontend` 的视觉方向当前以 Apple 风格为基线,优先纯色分区、系统字体栈和低装饰成本
|
||||
|
||||
## 当前约束
|
||||
|
||||
- 本地预览环境默认缺少真实 `secure_path` 与管理员凭证
|
||||
- 后端接口契约以仓库内 Controller/Route 为准,不在前端推断字段
|
||||
@@ -0,0 +1,5 @@
|
||||
# 模块索引
|
||||
|
||||
| 模块名 | 说明 | 最近更新 |
|
||||
|--------|------|----------|
|
||||
| [admin-frontend](admin-frontend.md) | 管理端前端登录、布局、仪表盘与管理 API 封装 | 2026-04-21 |
|
||||
@@ -0,0 +1,22 @@
|
||||
# admin-frontend
|
||||
|
||||
## 职责
|
||||
|
||||
- 提供 Vue3 管理端登录页、认证状态、路由守卫和主布局
|
||||
- 封装管理端统计/系统状态接口
|
||||
- 渲染后台仪表盘、排行、队列和系统运行状态
|
||||
|
||||
## 行为规范
|
||||
|
||||
- 登录成功后优先跳转 `redirect` 指定路由,否则回到 `/dashboard`
|
||||
- 受保护路由在未登录时会自动附加 `redirect` 查询参数
|
||||
- API 基础路径使用 `/api/v2/{secure_path}`,其中 `secure_path` 来自运行时配置
|
||||
- 仪表盘以真实后端接口返回值为准,不在前端伪造业务统计
|
||||
- 当前首页视觉基线为 Apple 风格:纯色分区、系统字体栈、单一蓝色强调和轻量层次
|
||||
- 性能优化优先级高于装饰性表达,避免远程字体、全局模糊背景和固定特效层
|
||||
|
||||
## 依赖关系
|
||||
|
||||
- 依赖 `src/api/client.ts` 处理 axios 与认证头
|
||||
- 依赖 Laravel 注入的 `window.settings`
|
||||
- 构建输出到 `public/assets/admin`
|
||||
@@ -1,2 +1,2 @@
|
||||
VITE_API_BASE_URL=/api/v2
|
||||
VITE_ADMIN_PATH=
|
||||
VITE_ADMIN_PATH=adminadmin
|
||||
|
||||
@@ -1,8 +1,55 @@
|
||||
import { adminClient } from './client'
|
||||
import type { ApiResponse, SystemStatus } from '@/types/api'
|
||||
import type {
|
||||
ApiResponse,
|
||||
DashboardStats,
|
||||
OrderTrendData,
|
||||
QueueStats,
|
||||
SystemStatus,
|
||||
TrafficRankResponse,
|
||||
} from '@/types/api'
|
||||
|
||||
export function getSystemStatus(): Promise<ApiResponse<SystemStatus>> {
|
||||
function unwrap<T>(url: string, params?: Record<string, unknown>): Promise<ApiResponse<T>> {
|
||||
return adminClient
|
||||
.get<ApiResponse<SystemStatus>>('/system/getSystemStatus')
|
||||
.get<ApiResponse<T>>(url, { params })
|
||||
.then((res) => res.data)
|
||||
}
|
||||
|
||||
export function getDashboardStats(): Promise<ApiResponse<DashboardStats>> {
|
||||
return unwrap<DashboardStats>('/stat/getStats')
|
||||
}
|
||||
|
||||
export function getOrderTrend(params: {
|
||||
startDate: string
|
||||
endDate: string
|
||||
type?: 'paid_total' | 'paid_count' | 'commission_total' | 'commission_count'
|
||||
}): Promise<ApiResponse<OrderTrendData>> {
|
||||
return unwrap<OrderTrendData>('/stat/getOrder', {
|
||||
start_date: params.startDate,
|
||||
end_date: params.endDate,
|
||||
type: params.type,
|
||||
})
|
||||
}
|
||||
|
||||
export function getTrafficRank(params: {
|
||||
type: 'node' | 'user'
|
||||
startTime: number
|
||||
endTime: number
|
||||
}): Promise<TrafficRankResponse> {
|
||||
return adminClient
|
||||
.get<TrafficRankResponse>('/stat/getTrafficRank', {
|
||||
params: {
|
||||
type: params.type,
|
||||
start_time: params.startTime,
|
||||
end_time: params.endTime,
|
||||
},
|
||||
})
|
||||
.then((res) => res.data)
|
||||
}
|
||||
|
||||
export function getSystemStatus(): Promise<ApiResponse<SystemStatus>> {
|
||||
return unwrap<SystemStatus>('/system/getSystemStatus')
|
||||
}
|
||||
|
||||
export function getQueueStats(): Promise<ApiResponse<QueueStats>> {
|
||||
return unwrap<QueueStats>('/system/getQueueStats')
|
||||
}
|
||||
|
||||
@@ -2,6 +2,18 @@ import axios from 'axios'
|
||||
import type { ApiResponse } from '@/types/api'
|
||||
import { getApiBaseUrl, getSecurePath } from '@/utils/runtime'
|
||||
import { getToken, removeToken } from '@/utils/token'
|
||||
import { buildLoginHash, DEFAULT_AFTER_LOGIN, normalizeRedirectTarget } from '@/utils/navigation'
|
||||
|
||||
function redirectToLogin(): void {
|
||||
const currentTarget = normalizeRedirectTarget(
|
||||
window.location.hash.replace(/^#/, ''),
|
||||
DEFAULT_AFTER_LOGIN,
|
||||
)
|
||||
|
||||
window.location.hash = currentTarget === DEFAULT_AFTER_LOGIN
|
||||
? '#/login'
|
||||
: buildLoginHash(currentTarget)
|
||||
}
|
||||
|
||||
function handleError(error: unknown): never {
|
||||
if (axios.isAxiosError(error)) {
|
||||
@@ -10,7 +22,7 @@ function handleError(error: unknown): never {
|
||||
|
||||
if (status === 401 || status === 403) {
|
||||
removeToken()
|
||||
window.location.hash = '#/login'
|
||||
redirectToLogin()
|
||||
}
|
||||
|
||||
throw new Error(data?.message || error.message || '请求失败')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
@@ -8,22 +8,33 @@ import {
|
||||
SwitchButton,
|
||||
Fold,
|
||||
Expand,
|
||||
Sunny,
|
||||
Moon,
|
||||
} from '@element-plus/icons-vue'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const auth = useAuthStore()
|
||||
const app = useAppStore()
|
||||
const isMobile = ref(false)
|
||||
|
||||
const sidebarWidth = computed(() => app.sidebarCollapsed ? '64px' : '220px')
|
||||
const sidebarWidth = computed(() => app.sidebarCollapsed ? '72px' : '220px')
|
||||
const currentTitle = computed(() => String(route.meta.title || '控制台'))
|
||||
const currentKicker = computed(() => String(route.meta.kicker || 'Xboard Admin'))
|
||||
|
||||
const menuItems = [
|
||||
{ index: '/dashboard', title: '仪表盘', icon: Odometer },
|
||||
]
|
||||
|
||||
function syncViewport() {
|
||||
isMobile.value = window.innerWidth < 960
|
||||
if (isMobile.value) {
|
||||
app.sidebarCollapsed = true
|
||||
}
|
||||
}
|
||||
|
||||
function handleMenuSelect(index: string) {
|
||||
if (isMobile.value) {
|
||||
app.sidebarCollapsed = true
|
||||
}
|
||||
router.push(index)
|
||||
}
|
||||
|
||||
@@ -31,20 +42,34 @@ function handleLogout() {
|
||||
auth.logout()
|
||||
router.push('/login')
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
syncViewport()
|
||||
window.addEventListener('resize', syncViewport)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('resize', syncViewport)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElContainer class="admin-layout">
|
||||
<ElAside :width="sidebarWidth" class="admin-aside">
|
||||
<div class="aside-logo">
|
||||
<h1 v-if="!app.sidebarCollapsed">Xboard</h1>
|
||||
<span v-else>X</span>
|
||||
<div class="aside-mark">X</div>
|
||||
<div v-if="!app.sidebarCollapsed" class="aside-brand">
|
||||
<p>Xboard</p>
|
||||
<h1>{{ app.title }}</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ElMenu
|
||||
:default-active="route.path"
|
||||
:collapse="app.sidebarCollapsed"
|
||||
:collapse-transition="false"
|
||||
router
|
||||
class="admin-menu"
|
||||
@select="handleMenuSelect"
|
||||
>
|
||||
<ElMenuItem
|
||||
@@ -58,7 +83,7 @@ function handleLogout() {
|
||||
</ElMenu>
|
||||
</ElAside>
|
||||
|
||||
<ElContainer>
|
||||
<ElContainer class="admin-stage">
|
||||
<ElHeader class="admin-header">
|
||||
<div class="header-left">
|
||||
<ElIcon
|
||||
@@ -68,20 +93,19 @@ function handleLogout() {
|
||||
<Fold v-if="!app.sidebarCollapsed" />
|
||||
<Expand v-else />
|
||||
</ElIcon>
|
||||
<ElBreadcrumb separator="/">
|
||||
<ElBreadcrumbItem :to="{ path: '/dashboard' }">首页</ElBreadcrumbItem>
|
||||
<ElBreadcrumbItem v-if="route.name !== 'Dashboard'">
|
||||
{{ route.name }}
|
||||
</ElBreadcrumbItem>
|
||||
</ElBreadcrumb>
|
||||
|
||||
<div class="page-copy">
|
||||
<p>{{ currentKicker }}</p>
|
||||
<h2>{{ currentTitle }}</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="header-right">
|
||||
<ElIcon class="theme-btn" @click="app.toggleTheme">
|
||||
<Sunny v-if="app.isDark" />
|
||||
<Moon v-else />
|
||||
</ElIcon>
|
||||
<ElButton text @click="handleLogout">
|
||||
<div class="header-info">
|
||||
<span class="header-info__label">secure_path</span>
|
||||
<strong>/{{ app.securePath || 'admin' }}</strong>
|
||||
</div>
|
||||
<ElButton text class="logout-btn" @click="handleLogout">
|
||||
<ElIcon><SwitchButton /></ElIcon>
|
||||
退出
|
||||
</ElButton>
|
||||
@@ -98,83 +122,179 @@ function handleLogout() {
|
||||
<style scoped>
|
||||
.admin-layout {
|
||||
height: 100vh;
|
||||
background: #f5f5f7;
|
||||
}
|
||||
|
||||
.admin-aside {
|
||||
background: var(--el-bg-color);
|
||||
border-right: 1px solid var(--el-border-color-light);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #ffffff;
|
||||
border-right: 1px solid rgba(0, 0, 0, 0.06);
|
||||
overflow: hidden;
|
||||
transition: width 0.3s;
|
||||
padding: 18px 12px 12px;
|
||||
box-shadow: 0 0 1px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.aside-logo {
|
||||
height: 56px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-bottom: 1px solid var(--el-border-color-light);
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: var(--el-text-color-primary);
|
||||
gap: 12px;
|
||||
padding: 12px 8px 20px;
|
||||
}
|
||||
|
||||
.aside-logo h1 {
|
||||
.aside-mark {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: 999px;
|
||||
background: #1d1d1f;
|
||||
color: #ffffff;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.aside-brand {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.aside-brand p {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
color: var(--xboard-text-muted);
|
||||
}
|
||||
|
||||
.aside-brand h1 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
line-height: 1.1;
|
||||
color: var(--xboard-text-strong);
|
||||
}
|
||||
|
||||
.admin-menu {
|
||||
flex: 1;
|
||||
background: #ffffff;
|
||||
border-right: 0;
|
||||
}
|
||||
|
||||
.admin-menu :deep(.el-menu-item) {
|
||||
margin-bottom: 8px;
|
||||
border-radius: 12px;
|
||||
color: var(--xboard-text-secondary);
|
||||
height: 44px;
|
||||
}
|
||||
|
||||
.admin-menu :deep(.el-menu-item.is-active) {
|
||||
background: rgba(0, 113, 227, 0.08);
|
||||
color: #0071e3;
|
||||
}
|
||||
|
||||
.admin-stage {
|
||||
background: #f5f5f7;
|
||||
}
|
||||
|
||||
.admin-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background: var(--el-bg-color);
|
||||
border-bottom: 1px solid var(--el-border-color-light);
|
||||
padding: 0 20px;
|
||||
height: 56px;
|
||||
background: rgba(255, 255, 255, 0.72);
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
|
||||
backdrop-filter: saturate(180%) blur(20px);
|
||||
padding: 0 24px;
|
||||
height: 64px;
|
||||
}
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
gap: 18px;
|
||||
}
|
||||
|
||||
.collapse-btn {
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
color: var(--el-text-color-regular);
|
||||
color: var(--xboard-text-secondary);
|
||||
}
|
||||
|
||||
.collapse-btn:hover {
|
||||
color: var(--el-color-primary);
|
||||
color: #0071e3;
|
||||
}
|
||||
|
||||
.page-copy {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.page-copy p {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
color: var(--xboard-text-muted);
|
||||
}
|
||||
|
||||
.page-copy h2 {
|
||||
margin: 0;
|
||||
font-size: 28px;
|
||||
line-height: 1.1;
|
||||
color: var(--xboard-text-strong);
|
||||
}
|
||||
|
||||
.header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.theme-btn {
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
color: var(--el-text-color-regular);
|
||||
.header-info {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.theme-btn:hover {
|
||||
color: var(--el-color-primary);
|
||||
.header-info__label {
|
||||
font-size: 12px;
|
||||
color: var(--xboard-text-secondary);
|
||||
}
|
||||
|
||||
.header-info strong {
|
||||
font-size: 14px;
|
||||
color: var(--xboard-text-strong);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.logout-btn {
|
||||
color: #0071e3;
|
||||
}
|
||||
|
||||
.admin-main {
|
||||
background: var(--el-bg-color-page);
|
||||
background: #f5f5f7;
|
||||
overflow-y: auto;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
@media (max-width: 959px) {
|
||||
.admin-aside {
|
||||
position: fixed;
|
||||
z-index: 100;
|
||||
z-index: 30;
|
||||
height: 100vh;
|
||||
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.admin-header {
|
||||
padding: 0 18px;
|
||||
}
|
||||
|
||||
.page-copy h2 {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.header-info {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.admin-main {
|
||||
padding: 18px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,30 +1,38 @@
|
||||
import type { Router } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { hasToken } from '@/utils/token'
|
||||
import { normalizeRedirectTarget } from '@/utils/navigation'
|
||||
|
||||
export function setupGuards(router: Router) {
|
||||
router.beforeEach(async (to) => {
|
||||
const auth = useAuthStore()
|
||||
const redirectTarget = normalizeRedirectTarget(to.query.redirect)
|
||||
|
||||
if (to.meta.public) {
|
||||
if (hasToken() && !auth.validated) {
|
||||
const ok = await auth.validateAdmin()
|
||||
if (ok) return '/dashboard'
|
||||
if (ok) return redirectTarget
|
||||
}
|
||||
if (auth.validated) {
|
||||
return '/dashboard'
|
||||
return redirectTarget
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
if (!hasToken()) {
|
||||
return '/login'
|
||||
return {
|
||||
path: '/login',
|
||||
query: { redirect: to.fullPath },
|
||||
}
|
||||
}
|
||||
|
||||
if (!auth.validated) {
|
||||
const ok = await auth.validateAdmin()
|
||||
if (!ok) {
|
||||
return '/login'
|
||||
return {
|
||||
path: '/login',
|
||||
query: { redirect: to.fullPath },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,11 @@ const routes: RouteRecordRaw[] = [
|
||||
path: '/login',
|
||||
name: 'Login',
|
||||
component: () => import('@/views/login/LoginView.vue'),
|
||||
meta: { public: true },
|
||||
meta: { public: true, title: '管理员登录', kicker: 'Xboard Admin' },
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
name: 'AdminRoot',
|
||||
component: () => import('@/layouts/AdminLayout.vue'),
|
||||
children: [
|
||||
{
|
||||
@@ -20,6 +21,7 @@ const routes: RouteRecordRaw[] = [
|
||||
path: 'dashboard',
|
||||
name: 'Dashboard',
|
||||
component: () => import('@/views/dashboard/DashboardView.vue'),
|
||||
meta: { title: '仪表盘', kicker: 'Overview' },
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Vendored
+127
-7
@@ -1,14 +1,46 @@
|
||||
@use 'element-plus/theme-chalk/src/mixins/config' as *;
|
||||
|
||||
:root {
|
||||
--xboard-primary: #409eff;
|
||||
--xboard-sidebar-bg: #ffffff;
|
||||
--xboard-header-bg: #ffffff;
|
||||
--xboard-font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text',
|
||||
'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif;
|
||||
--xboard-font-mono: 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
|
||||
--xboard-bg: #f5f5f7;
|
||||
--xboard-surface: #ffffff;
|
||||
--xboard-surface-soft: #fbfbfd;
|
||||
--xboard-surface-dark: #000000;
|
||||
--xboard-text-strong: #1d1d1f;
|
||||
--xboard-text-secondary: rgba(29, 29, 31, 0.8);
|
||||
--xboard-text-muted: rgba(29, 29, 31, 0.56);
|
||||
--xboard-text-on-dark: #ffffff;
|
||||
--xboard-text-on-dark-muted: rgba(255, 255, 255, 0.72);
|
||||
--xboard-primary: #0071e3;
|
||||
--xboard-link: #0066cc;
|
||||
--xboard-link-dark: #2997ff;
|
||||
--xboard-border: rgba(0, 0, 0, 0.08);
|
||||
--xboard-border-strong: rgba(0, 0, 0, 0.12);
|
||||
--xboard-shadow: 0 6px 30px rgba(0, 0, 0, 0.08);
|
||||
--xboard-success: #23863f;
|
||||
--xboard-warning: #b05a00;
|
||||
--xboard-danger: #c93428;
|
||||
--el-color-primary: #0071e3;
|
||||
--el-color-primary-light-3: #2997ff;
|
||||
--el-color-primary-light-5: #4da1ff;
|
||||
--el-bg-color: #ffffff;
|
||||
--el-bg-color-page: #f5f5f7;
|
||||
--el-bg-color-overlay: #ffffff;
|
||||
--el-border-color: rgba(0, 0, 0, 0.1);
|
||||
--el-border-color-light: rgba(0, 0, 0, 0.08);
|
||||
--el-border-color-lighter: rgba(0, 0, 0, 0.06);
|
||||
--el-fill-color-blank: #ffffff;
|
||||
--el-fill-color-light: rgba(0, 0, 0, 0.03);
|
||||
--el-text-color-primary: #1d1d1f;
|
||||
--el-text-color-regular: rgba(29, 29, 31, 0.8);
|
||||
--el-text-color-secondary: rgba(29, 29, 31, 0.56);
|
||||
--el-mask-color: rgba(255, 255, 255, 0.78);
|
||||
}
|
||||
|
||||
html.dark {
|
||||
--xboard-sidebar-bg: #1d1e1f;
|
||||
--xboard-header-bg: #1d1e1f;
|
||||
color-scheme: light;
|
||||
}
|
||||
|
||||
* {
|
||||
@@ -22,11 +54,99 @@ body,
|
||||
#app {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
|
||||
'Noto Sans', sans-serif;
|
||||
font-family: var(--xboard-font-sans);
|
||||
background: var(--xboard-bg);
|
||||
color: var(--xboard-text-strong);
|
||||
}
|
||||
|
||||
body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#app {
|
||||
isolation: isolate;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
button,
|
||||
input,
|
||||
textarea,
|
||||
select {
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.mono {
|
||||
font-family: var(--xboard-font-mono);
|
||||
}
|
||||
|
||||
.positive {
|
||||
color: var(--xboard-success);
|
||||
}
|
||||
|
||||
.negative {
|
||||
color: var(--xboard-danger);
|
||||
}
|
||||
|
||||
.neutral {
|
||||
color: var(--xboard-text-secondary);
|
||||
}
|
||||
|
||||
.el-card,
|
||||
.el-menu,
|
||||
.el-input__wrapper,
|
||||
.el-select__wrapper,
|
||||
.el-button,
|
||||
.el-alert {
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.el-card {
|
||||
background: #ffffff;
|
||||
border-color: var(--xboard-border);
|
||||
box-shadow: var(--xboard-shadow);
|
||||
}
|
||||
|
||||
.el-input__wrapper,
|
||||
.el-select__wrapper,
|
||||
.el-textarea__inner {
|
||||
background: #ffffff;
|
||||
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08) inset !important;
|
||||
}
|
||||
|
||||
.el-button--primary {
|
||||
background: #0071e3;
|
||||
border-color: #0071e3;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.el-button.is-text {
|
||||
color: var(--xboard-link);
|
||||
}
|
||||
|
||||
.el-checkbox__label,
|
||||
.el-form-item__label {
|
||||
color: var(--xboard-text-secondary) !important;
|
||||
}
|
||||
|
||||
.el-breadcrumb__item:last-child .el-breadcrumb__inner,
|
||||
.el-alert__title {
|
||||
color: var(--xboard-text-strong);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgba(0, 0, 0, 0.18);
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
Vendored
+99
-3
@@ -1,8 +1,9 @@
|
||||
export interface ApiResponse<T = unknown> {
|
||||
status: 'success' | 'fail'
|
||||
message: string
|
||||
status?: 'success' | 'fail' | string
|
||||
message?: string
|
||||
data: T
|
||||
error?: string | null
|
||||
code?: number
|
||||
}
|
||||
|
||||
export interface LoginRequest {
|
||||
@@ -16,8 +17,103 @@ export interface LoginResponse {
|
||||
is_admin: boolean
|
||||
}
|
||||
|
||||
export interface TrafficAmount {
|
||||
upload: number
|
||||
download: number
|
||||
total: number
|
||||
}
|
||||
|
||||
export interface DashboardStats {
|
||||
todayIncome: number
|
||||
dayIncomeGrowth: number
|
||||
currentMonthIncome: number
|
||||
lastMonthIncome: number
|
||||
monthIncomeGrowth: number
|
||||
lastMonthIncomeGrowth: number
|
||||
currentMonthCommissionPayout: number
|
||||
lastMonthCommissionPayout: number
|
||||
commissionGrowth: number
|
||||
commissionPendingTotal: number
|
||||
currentMonthNewUsers: number
|
||||
totalUsers: number
|
||||
activeUsers: number
|
||||
userGrowth: number
|
||||
onlineUsers: number
|
||||
onlineDevices: number
|
||||
ticketPendingTotal: number
|
||||
onlineNodes: number
|
||||
todayTraffic: TrafficAmount
|
||||
monthTraffic: TrafficAmount
|
||||
totalTraffic: TrafficAmount
|
||||
}
|
||||
|
||||
export interface OrderTrendPoint {
|
||||
date: string
|
||||
paid_total: number
|
||||
paid_count: number
|
||||
commission_total: number
|
||||
commission_count: number
|
||||
avg_order_amount: number
|
||||
avg_commission_amount: number
|
||||
value?: number
|
||||
type?: string
|
||||
}
|
||||
|
||||
export interface OrderTrendSummary {
|
||||
paid_total: number
|
||||
paid_count: number
|
||||
commission_total: number
|
||||
commission_count: number
|
||||
start_date: string
|
||||
end_date: string
|
||||
avg_paid_amount: number
|
||||
avg_commission_amount: number
|
||||
commission_rate: number
|
||||
}
|
||||
|
||||
export interface OrderTrendData {
|
||||
list: OrderTrendPoint[]
|
||||
summary: OrderTrendSummary
|
||||
}
|
||||
|
||||
export interface TrafficRankItem {
|
||||
id: string
|
||||
name: string
|
||||
value: number
|
||||
previousValue: number
|
||||
change: number
|
||||
timestamp: string
|
||||
}
|
||||
|
||||
export interface TrafficRankResponse {
|
||||
timestamp: string
|
||||
data: TrafficRankItem[]
|
||||
}
|
||||
|
||||
export interface SystemStatus {
|
||||
[key: string]: unknown
|
||||
schedule: boolean
|
||||
horizon: boolean
|
||||
schedule_last_runtime: number | string | null
|
||||
}
|
||||
|
||||
export interface QueueWaitEntry {
|
||||
[key: string]: string | number | null | undefined
|
||||
}
|
||||
|
||||
export interface QueueStats {
|
||||
failedJobs: number
|
||||
jobsPerMinute: number
|
||||
pausedMasters: number
|
||||
periods: {
|
||||
failedJobs: number
|
||||
recentJobs: number
|
||||
}
|
||||
processes: number
|
||||
queueWithMaxRuntime?: string | null
|
||||
queueWithMaxThroughput?: string | null
|
||||
recentJobs: number
|
||||
status: boolean
|
||||
wait?: QueueWaitEntry[]
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
+1
-6
@@ -11,15 +11,11 @@ export {}
|
||||
/* prettier-ignore */
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
ElAlert: typeof import('element-plus/es')['ElAlert']
|
||||
ElAside: typeof import('element-plus/es')['ElAside']
|
||||
ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb']
|
||||
ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem']
|
||||
ElButton: typeof import('element-plus/es')['ElButton']
|
||||
ElCard: typeof import('element-plus/es')['ElCard']
|
||||
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
|
||||
ElCol: typeof import('element-plus/es')['ElCol']
|
||||
ElContainer: typeof import('element-plus/es')['ElContainer']
|
||||
ElDivider: typeof import('element-plus/es')['ElDivider']
|
||||
ElForm: typeof import('element-plus/es')['ElForm']
|
||||
ElFormItem: typeof import('element-plus/es')['ElFormItem']
|
||||
ElHeader: typeof import('element-plus/es')['ElHeader']
|
||||
@@ -28,7 +24,6 @@ declare module 'vue' {
|
||||
ElMain: typeof import('element-plus/es')['ElMain']
|
||||
ElMenu: typeof import('element-plus/es')['ElMenu']
|
||||
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
|
||||
ElRow: typeof import('element-plus/es')['ElRow']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
}
|
||||
|
||||
@@ -0,0 +1,239 @@
|
||||
import type {
|
||||
OrderTrendPoint,
|
||||
QueueStats,
|
||||
QueueWaitEntry,
|
||||
} from '@/types/api'
|
||||
|
||||
export type TimePreset = '1d' | '7d' | '30d' | '90d'
|
||||
|
||||
export interface DateRangePreset {
|
||||
startDate: string
|
||||
endDate: string
|
||||
startTime: number
|
||||
endTime: number
|
||||
}
|
||||
|
||||
export interface ChartLabelPoint {
|
||||
index: number
|
||||
label: string
|
||||
xPercent: number
|
||||
}
|
||||
|
||||
export interface TrendChartPoint {
|
||||
index: number
|
||||
x: number
|
||||
y: number
|
||||
value: number
|
||||
date: string
|
||||
label: string
|
||||
}
|
||||
|
||||
export interface TrendChartModel {
|
||||
path: string
|
||||
areaPath: string
|
||||
points: TrendChartPoint[]
|
||||
gridLines: Array<{ label: string; y: number }>
|
||||
labels: ChartLabelPoint[]
|
||||
}
|
||||
|
||||
const TREND_WIDTH = 760
|
||||
const TREND_HEIGHT = 260
|
||||
const PADDING_X = 24
|
||||
const PADDING_TOP = 18
|
||||
const PADDING_BOTTOM = 34
|
||||
|
||||
function formatDateToken(date: Date): string {
|
||||
return [
|
||||
date.getFullYear(),
|
||||
String(date.getMonth() + 1).padStart(2, '0'),
|
||||
String(date.getDate()).padStart(2, '0'),
|
||||
].join('-')
|
||||
}
|
||||
|
||||
function toNumber(value: unknown): number {
|
||||
const numeric = Number(value)
|
||||
return Number.isFinite(numeric) ? numeric : 0
|
||||
}
|
||||
|
||||
export function getDateRangeFromPreset(preset: TimePreset): DateRangePreset {
|
||||
const days = { '1d': 1, '7d': 7, '30d': 30, '90d': 90 }[preset]
|
||||
const end = new Date()
|
||||
end.setHours(23, 59, 59, 999)
|
||||
|
||||
const start = new Date(end)
|
||||
start.setDate(start.getDate() - (days - 1))
|
||||
start.setHours(0, 0, 0, 0)
|
||||
|
||||
return {
|
||||
startDate: formatDateToken(start),
|
||||
endDate: formatDateToken(end),
|
||||
startTime: Math.floor(start.getTime() / 1000),
|
||||
endTime: Math.floor(end.getTime() / 1000),
|
||||
}
|
||||
}
|
||||
|
||||
export function formatCurrency(value: number): string {
|
||||
const amount = (value || 0) / 100
|
||||
return new Intl.NumberFormat('zh-CN', {
|
||||
style: 'currency',
|
||||
currency: 'CNY',
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
}).format(amount)
|
||||
}
|
||||
|
||||
export function formatCompactCurrency(value: number): string {
|
||||
const amount = (value || 0) / 100
|
||||
const absolute = Math.abs(amount)
|
||||
if (absolute >= 1_000_000) return `¥${(amount / 1_000_000).toFixed(1)}m`
|
||||
if (absolute >= 1_000) return `¥${(amount / 1_000).toFixed(1)}k`
|
||||
return formatCurrency(value)
|
||||
}
|
||||
|
||||
export function formatCompactNumber(value: number): string {
|
||||
return new Intl.NumberFormat('zh-CN', {
|
||||
notation: value >= 10_000 ? 'compact' : 'standard',
|
||||
maximumFractionDigits: value >= 10_000 ? 1 : 0,
|
||||
}).format(value || 0)
|
||||
}
|
||||
|
||||
export function formatTraffic(bytes: number): string {
|
||||
const value = Math.max(0, bytes || 0)
|
||||
const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']
|
||||
let size = value
|
||||
let index = 0
|
||||
|
||||
while (size >= 1024 && index < units.length - 1) {
|
||||
size /= 1024
|
||||
index += 1
|
||||
}
|
||||
|
||||
const digits = size >= 100 || index === 0 ? 0 : size >= 10 ? 1 : 2
|
||||
return `${size.toFixed(digits)} ${units[index]}`
|
||||
}
|
||||
|
||||
export function formatPercent(value: number, signed: boolean = true): string {
|
||||
const numeric = Number.isFinite(value) ? value : 0
|
||||
const prefix = signed && numeric > 0 ? '+' : ''
|
||||
return `${prefix}${numeric.toFixed(1)}%`
|
||||
}
|
||||
|
||||
export function formatDateTime(value: number | string | null | undefined): string {
|
||||
if (value === null || value === undefined || value === '') {
|
||||
return 'N/A'
|
||||
}
|
||||
|
||||
const numeric = Number(value)
|
||||
const timeValue = Number.isFinite(numeric)
|
||||
? (numeric > 1_000_000_000_000 ? numeric : numeric * 1000)
|
||||
: Date.parse(String(value))
|
||||
|
||||
if (!Number.isFinite(timeValue)) {
|
||||
return 'N/A'
|
||||
}
|
||||
|
||||
return new Intl.DateTimeFormat('zh-CN', {
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
}).format(new Date(timeValue))
|
||||
}
|
||||
|
||||
function getVisibleLabels(points: TrendChartPoint[]): ChartLabelPoint[] {
|
||||
if (points.length <= 1) {
|
||||
return points.map((point) => ({
|
||||
index: point.index,
|
||||
label: point.label,
|
||||
xPercent: 50,
|
||||
}))
|
||||
}
|
||||
|
||||
const step = Math.max(1, Math.ceil(points.length / 6))
|
||||
return points
|
||||
.filter((_, index) => index === 0 || index === points.length - 1 || index % step === 0)
|
||||
.map((point) => ({
|
||||
index: point.index,
|
||||
label: point.label,
|
||||
xPercent: ((point.x - PADDING_X) / (TREND_WIDTH - PADDING_X * 2)) * 100,
|
||||
}))
|
||||
}
|
||||
|
||||
export function buildTrendChart(points: OrderTrendPoint[]): TrendChartModel {
|
||||
if (!points.length) {
|
||||
return {
|
||||
path: '',
|
||||
areaPath: '',
|
||||
points: [],
|
||||
gridLines: [],
|
||||
labels: [],
|
||||
}
|
||||
}
|
||||
|
||||
const values = points.map((point) => Math.max(0, toNumber(point.paid_total)))
|
||||
const maxValue = Math.max(...values, 1)
|
||||
const innerWidth = TREND_WIDTH - PADDING_X * 2
|
||||
const innerHeight = TREND_HEIGHT - PADDING_TOP - PADDING_BOTTOM
|
||||
const stepX = values.length > 1 ? innerWidth / (values.length - 1) : innerWidth / 2
|
||||
|
||||
const chartPoints = points.map((point, index) => {
|
||||
const normalized = maxValue === 0 ? 0 : values[index] / maxValue
|
||||
return {
|
||||
index,
|
||||
value: values[index],
|
||||
date: point.date,
|
||||
label: point.date.slice(5),
|
||||
x: PADDING_X + stepX * index,
|
||||
y: PADDING_TOP + innerHeight - normalized * innerHeight,
|
||||
}
|
||||
})
|
||||
|
||||
const path = chartPoints
|
||||
.map((point, index) => `${index === 0 ? 'M' : 'L'} ${point.x.toFixed(2)} ${point.y.toFixed(2)}`)
|
||||
.join(' ')
|
||||
|
||||
const areaPath = chartPoints.length
|
||||
? `${path} L ${chartPoints[chartPoints.length - 1].x.toFixed(2)} ${(TREND_HEIGHT - PADDING_BOTTOM).toFixed(2)} L ${chartPoints[0].x.toFixed(2)} ${(TREND_HEIGHT - PADDING_BOTTOM).toFixed(2)} Z`
|
||||
: ''
|
||||
|
||||
const gridLines = [1, 0.75, 0.5, 0.25, 0].map((ratio) => ({
|
||||
label: formatCompactCurrency(maxValue * ratio),
|
||||
y: PADDING_TOP + innerHeight - innerHeight * ratio,
|
||||
}))
|
||||
|
||||
return {
|
||||
path,
|
||||
areaPath,
|
||||
points: chartPoints,
|
||||
gridLines,
|
||||
labels: getVisibleLabels(chartPoints),
|
||||
}
|
||||
}
|
||||
|
||||
function extractQueueWaitEntry(wait?: QueueWaitEntry[]): QueueWaitEntry | null {
|
||||
if (!Array.isArray(wait) || !wait.length) {
|
||||
return null
|
||||
}
|
||||
|
||||
return wait[0]
|
||||
}
|
||||
|
||||
export function getQueueWaitSeconds(queueStats: QueueStats | null): number | null {
|
||||
const waitEntry = extractQueueWaitEntry(queueStats?.wait)
|
||||
if (!waitEntry) {
|
||||
return null
|
||||
}
|
||||
|
||||
const value = toNumber(waitEntry.wait ?? waitEntry.value ?? waitEntry.time)
|
||||
return Number.isFinite(value) ? value : null
|
||||
}
|
||||
|
||||
export function getQueueWaitName(queueStats: QueueStats | null): string {
|
||||
const waitEntry = extractQueueWaitEntry(queueStats?.wait)
|
||||
if (!waitEntry) {
|
||||
return 'N/A'
|
||||
}
|
||||
|
||||
const queueName = waitEntry.name ?? waitEntry.queue ?? waitEntry.label
|
||||
return typeof queueName === 'string' && queueName ? queueName : 'N/A'
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
export const DEFAULT_AFTER_LOGIN = '/dashboard'
|
||||
|
||||
export function normalizeRedirectTarget(value: unknown, fallback: string = DEFAULT_AFTER_LOGIN): string {
|
||||
if (typeof value !== 'string') {
|
||||
return fallback
|
||||
}
|
||||
|
||||
const normalized = value.trim().replace(/^#/, '')
|
||||
if (!normalized || !normalized.startsWith('/') || normalized.startsWith('//')) {
|
||||
return fallback
|
||||
}
|
||||
|
||||
if (normalized.startsWith('/login')) {
|
||||
return fallback
|
||||
}
|
||||
|
||||
return normalized
|
||||
}
|
||||
|
||||
export function buildLoginHash(redirect?: string): string {
|
||||
const safeTarget = normalizeRedirectTarget(redirect, '')
|
||||
return safeTarget ? `#/login?redirect=${encodeURIComponent(safeTarget)}` : '#/login'
|
||||
}
|
||||
@@ -7,13 +7,13 @@ export function getApiBaseUrl(): string {
|
||||
export function initSecurePath(): string {
|
||||
if (window.settings?.secure_path) {
|
||||
cachedSecurePath = window.settings.secure_path
|
||||
return cachedSecurePath
|
||||
return window.settings.secure_path
|
||||
}
|
||||
|
||||
const envPath = import.meta.env.VITE_ADMIN_PATH
|
||||
if (envPath) {
|
||||
cachedSecurePath = envPath
|
||||
return cachedSecurePath
|
||||
return envPath
|
||||
}
|
||||
|
||||
console.error('[Xboard] secure_path 未配置。请设置 window.settings.secure_path 或环境变量 VITE_ADMIN_PATH')
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Lock, Message, Right } from '@element-plus/icons-vue'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import { DEFAULT_AFTER_LOGIN, normalizeRedirectTarget } from '@/utils/navigation'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const auth = useAuthStore()
|
||||
const app = useAppStore()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const loading = ref(false)
|
||||
const errorMessage = ref('')
|
||||
|
||||
const form = reactive({
|
||||
email: '',
|
||||
@@ -17,6 +23,13 @@ const form = reactive({
|
||||
remember: false,
|
||||
})
|
||||
|
||||
const redirectTarget = computed(() => normalizeRedirectTarget(route.query.redirect))
|
||||
const redirectHint = computed(() => (
|
||||
redirectTarget.value === DEFAULT_AFTER_LOGIN
|
||||
? '登录后将进入仪表盘总览'
|
||||
: `登录后将返回 ${redirectTarget.value}`
|
||||
))
|
||||
|
||||
const rules: FormRules = {
|
||||
email: [
|
||||
{ required: true, message: '请输入邮箱', trigger: 'blur' },
|
||||
@@ -33,12 +46,14 @@ async function onSubmit() {
|
||||
if (!valid) return
|
||||
|
||||
loading.value = true
|
||||
errorMessage.value = ''
|
||||
try {
|
||||
await auth.login(form.email, form.password, form.remember)
|
||||
ElMessage.success('登录成功')
|
||||
router.push('/dashboard')
|
||||
await router.replace(redirectTarget.value)
|
||||
} catch (err: unknown) {
|
||||
const msg = err instanceof Error ? err.message : '登录失败'
|
||||
errorMessage.value = msg
|
||||
ElMessage.error(msg)
|
||||
} finally {
|
||||
loading.value = false
|
||||
@@ -47,12 +62,34 @@ async function onSubmit() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="login-container">
|
||||
<div class="login-card">
|
||||
<div class="login-header">
|
||||
<h1 class="login-title">Xboard Admin</h1>
|
||||
<p class="login-subtitle">管理后台</p>
|
||||
<div class="login-page">
|
||||
<section class="login-hero">
|
||||
<p class="login-eyebrow">XBOARD ADMIN</p>
|
||||
<h1 class="login-headline">管理后台,像产品页一样安静。</h1>
|
||||
<p class="login-description">
|
||||
页面重新回到 Apple 式的信息编排方式。减少装饰层和不必要的视觉负担,让登录入口更直接。
|
||||
</p>
|
||||
<div class="login-meta">
|
||||
<span>secure_path /{{ app.securePath || 'admin' }}</span>
|
||||
<span>{{ redirectHint }}</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="login-panel">
|
||||
<div class="login-header">
|
||||
<p class="login-panel-kicker">Sign in</p>
|
||||
<h2 class="login-title">管理员登录</h2>
|
||||
<p class="login-subtitle">使用具备后台权限的账号进入 {{ app.title }}。</p>
|
||||
</div>
|
||||
|
||||
<ElAlert
|
||||
v-if="errorMessage"
|
||||
:title="errorMessage"
|
||||
type="error"
|
||||
show-icon
|
||||
:closable="false"
|
||||
class="login-alert"
|
||||
/>
|
||||
|
||||
<ElForm
|
||||
ref="formRef"
|
||||
@@ -66,7 +103,7 @@ async function onSubmit() {
|
||||
<ElInput
|
||||
v-model="form.email"
|
||||
placeholder="admin@example.com"
|
||||
prefix-icon="Message"
|
||||
:prefix-icon="Message"
|
||||
/>
|
||||
</ElFormItem>
|
||||
|
||||
@@ -75,74 +112,168 @@ async function onSubmit() {
|
||||
v-model="form.password"
|
||||
type="password"
|
||||
placeholder="请输入密码"
|
||||
prefix-icon="Lock"
|
||||
:prefix-icon="Lock"
|
||||
show-password
|
||||
/>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem>
|
||||
<div class="login-form-meta">
|
||||
<ElCheckbox v-model="form.remember">记住登录</ElCheckbox>
|
||||
</ElFormItem>
|
||||
<span class="login-meta-text">{{ redirectHint }}</span>
|
||||
</div>
|
||||
|
||||
<ElFormItem>
|
||||
<ElButton
|
||||
type="primary"
|
||||
:loading="loading"
|
||||
class="login-btn"
|
||||
@click="onSubmit"
|
||||
>
|
||||
{{ loading ? '登录中...' : '登 录' }}
|
||||
</ElButton>
|
||||
</ElFormItem>
|
||||
<ElButton
|
||||
type="primary"
|
||||
:loading="loading"
|
||||
class="login-btn"
|
||||
@click="onSubmit"
|
||||
>
|
||||
<span>{{ loading ? '登录中...' : '继续' }}</span>
|
||||
<ElIcon><Right /></ElIcon>
|
||||
</ElButton>
|
||||
</ElForm>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.login-container {
|
||||
.login-page {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
|
||||
padding: 20px;
|
||||
gap: 28px;
|
||||
padding: 40px 32px;
|
||||
}
|
||||
|
||||
.login-card {
|
||||
width: 100%;
|
||||
.login-hero,
|
||||
.login-panel {
|
||||
width: min(100%, 560px);
|
||||
}
|
||||
|
||||
.login-hero {
|
||||
padding: 48px;
|
||||
border-radius: 28px;
|
||||
background: #000000;
|
||||
color: var(--xboard-text-on-dark);
|
||||
display: grid;
|
||||
gap: 18px;
|
||||
}
|
||||
|
||||
.login-eyebrow,
|
||||
.login-panel-kicker {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.28em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.login-headline {
|
||||
margin: 0;
|
||||
font-size: clamp(40px, 5vw, 56px);
|
||||
line-height: 1.07;
|
||||
letter-spacing: -0.28px;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.login-description {
|
||||
margin: 0;
|
||||
max-width: 420px;
|
||||
padding: 40px;
|
||||
background: var(--el-bg-color);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
|
||||
line-height: 1.47;
|
||||
color: var(--xboard-text-on-dark-muted);
|
||||
}
|
||||
|
||||
.login-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.login-meta span {
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
color: rgba(255, 255, 255, 0.72);
|
||||
border-radius: 999px;
|
||||
padding: 10px 16px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.login-panel {
|
||||
border-radius: 28px;
|
||||
background: #ffffff;
|
||||
box-shadow: var(--xboard-shadow);
|
||||
padding: 40px 36px;
|
||||
}
|
||||
|
||||
.login-header {
|
||||
text-align: center;
|
||||
margin-bottom: 32px;
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
color: var(--el-text-color-primary);
|
||||
margin: 0 0 8px;
|
||||
margin: 0;
|
||||
font-size: 34px;
|
||||
line-height: 1.12;
|
||||
letter-spacing: -0.32px;
|
||||
color: var(--xboard-text-strong);
|
||||
}
|
||||
|
||||
.login-subtitle {
|
||||
font-size: 14px;
|
||||
color: var(--el-text-color-secondary);
|
||||
margin: 0;
|
||||
color: var(--xboard-text-secondary);
|
||||
}
|
||||
|
||||
.login-alert {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.login-form-meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.login-meta-text {
|
||||
color: var(--xboard-text-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
width: 100%;
|
||||
height: 44px;
|
||||
border-radius: 999px;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.login-card {
|
||||
@media (max-width: 980px) {
|
||||
.login-page {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.login-hero,
|
||||
.login-panel {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.login-page {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.login-hero,
|
||||
.login-panel {
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.login-form-meta {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
+313
@@ -0,0 +1,313 @@
|
||||
# Design System Inspired by Apple
|
||||
|
||||
## 1. Visual Theme & Atmosphere
|
||||
|
||||
Apple's website is a masterclass in controlled drama — vast expanses of pure black and near-white serve as cinematic backdrops for products that are photographed as if they were sculptures in a gallery. The design philosophy is reductive to its core: every pixel exists in service of the product, and the interface itself retreats until it becomes invisible. This is not minimalism as aesthetic preference; it is minimalism as reverence for the object.
|
||||
|
||||
The typography anchors everything. San Francisco (SF Pro Display for large sizes, SF Pro Text for body) is Apple's proprietary typeface, engineered with optical sizing that automatically adjusts letterforms depending on point size. At display sizes (56px), weight 600 with a tight line-height of 1.07 and subtle negative letter-spacing (-0.28px) creates headlines that feel machined rather than typeset — precise, confident, and unapologetically direct. At body sizes (17px), the tracking loosens slightly (-0.374px) and line-height opens to 1.47, creating a reading rhythm that is comfortable without ever feeling slack.
|
||||
|
||||
The color story is starkly binary. Product sections alternate between pure black (`#000000`) backgrounds with white text and light gray (`#f5f5f7`) backgrounds with near-black text (`#1d1d1f`). This creates a cinematic pacing — dark sections feel immersive and premium, light sections feel open and informational. The only chromatic accent is Apple Blue (`#0071e3`), reserved exclusively for interactive elements: links, buttons, and focus states. This singular accent color in a sea of neutrals gives every clickable element unmistakable visibility.
|
||||
|
||||
**Key Characteristics:**
|
||||
- SF Pro Display/Text with optical sizing — letterforms adapt automatically to size context
|
||||
- Binary light/dark section rhythm: black (`#000000`) alternating with light gray (`#f5f5f7`)
|
||||
- Single accent color: Apple Blue (`#0071e3`) reserved exclusively for interactive elements
|
||||
- Product-as-hero photography on solid color fields — no gradients, no textures, no distractions
|
||||
- Extremely tight headline line-heights (1.07-1.14) creating compressed, billboard-like impact
|
||||
- Full-width section layout with centered content — the viewport IS the canvas
|
||||
- Pill-shaped CTAs (980px radius) creating soft, approachable action buttons
|
||||
- Generous whitespace between sections allowing each product moment to breathe
|
||||
|
||||
## 2. Color Palette & Roles
|
||||
|
||||
### Primary
|
||||
- **Pure Black** (`#000000`): Hero section backgrounds, immersive product showcases. The darkest canvas for the brightest products.
|
||||
- **Light Gray** (`#f5f5f7`): Alternate section backgrounds, informational areas. Not white — the slight blue-gray tint prevents sterility.
|
||||
- **Near Black** (`#1d1d1f`): Primary text on light backgrounds, dark button fills. Slightly warmer than pure black for comfortable reading.
|
||||
|
||||
### Interactive
|
||||
- **Apple Blue** (`#0071e3`): `--sk-focus-color`, primary CTA backgrounds, focus rings. The ONLY chromatic color in the interface.
|
||||
- **Link Blue** (`#0066cc`): `--sk-body-link-color`, inline text links. Slightly darker than Apple Blue for text-level readability.
|
||||
- **Bright Blue** (`#2997ff`): Links on dark backgrounds. Higher luminance for contrast on black sections.
|
||||
|
||||
### Text
|
||||
- **White** (`#ffffff`): Text on dark backgrounds, button text on blue/dark CTAs.
|
||||
- **Near Black** (`#1d1d1f`): Primary body text on light backgrounds.
|
||||
- **Black 80%** (`rgba(0, 0, 0, 0.8)`): Secondary text, nav items on light backgrounds. Slightly softened.
|
||||
- **Black 48%** (`rgba(0, 0, 0, 0.48)`): Tertiary text, disabled states, carousel controls.
|
||||
|
||||
### Surface & Dark Variants
|
||||
- **Dark Surface 1** (`#272729`): Card backgrounds in dark sections.
|
||||
- **Dark Surface 2** (`#262628`): Subtle surface variation in dark contexts.
|
||||
- **Dark Surface 3** (`#28282a`): Elevated cards on dark backgrounds.
|
||||
- **Dark Surface 4** (`#2a2a2d`): Highest dark surface elevation.
|
||||
- **Dark Surface 5** (`#242426`): Deepest dark surface tone.
|
||||
|
||||
### Button States
|
||||
- **Button Active** (`#ededf2`): Active/pressed state for light buttons.
|
||||
- **Button Default Light** (`#fafafc`): Search/filter button backgrounds.
|
||||
- **Overlay** (`rgba(210, 210, 215, 0.64)`): Media control scrims, overlays.
|
||||
- **White 32%** (`rgba(255, 255, 255, 0.32)`): Hover state on dark modal close buttons.
|
||||
|
||||
### Shadows
|
||||
- **Card Shadow** (`rgba(0, 0, 0, 0.22) 3px 5px 30px 0px`): Soft, diffused elevation for product cards. Offset and wide blur create a natural, photographic shadow.
|
||||
|
||||
## 3. Typography Rules
|
||||
|
||||
### Font Family
|
||||
- **Display**: `SF Pro Display`, with fallbacks: `SF Pro Icons, Helvetica Neue, Helvetica, Arial, sans-serif`
|
||||
- **Body**: `SF Pro Text`, with fallbacks: `SF Pro Icons, Helvetica Neue, Helvetica, Arial, sans-serif`
|
||||
- SF Pro Display is used at 20px and above; SF Pro Text is optimized for 19px and below.
|
||||
|
||||
### Hierarchy
|
||||
|
||||
| Role | Font | Size | Weight | Line Height | Letter Spacing | Notes |
|
||||
|------|------|------|--------|-------------|----------------|-------|
|
||||
| Display Hero | SF Pro Display | 56px (3.50rem) | 600 | 1.07 (tight) | -0.28px | Product launch headlines, maximum impact |
|
||||
| Section Heading | SF Pro Display | 40px (2.50rem) | 600 | 1.10 (tight) | normal | Feature section titles |
|
||||
| Tile Heading | SF Pro Display | 28px (1.75rem) | 400 | 1.14 (tight) | 0.196px | Product tile headlines |
|
||||
| Card Title | SF Pro Display | 21px (1.31rem) | 700 | 1.19 (tight) | 0.231px | Bold card headings |
|
||||
| Sub-heading | SF Pro Display | 21px (1.31rem) | 400 | 1.19 (tight) | 0.231px | Regular card headings |
|
||||
| Nav Heading | SF Pro Text | 34px (2.13rem) | 600 | 1.47 | -0.374px | Large navigation headings |
|
||||
| Sub-nav | SF Pro Text | 24px (1.50rem) | 300 | 1.50 | normal | Light sub-navigation text |
|
||||
| Body | SF Pro Text | 17px (1.06rem) | 400 | 1.47 | -0.374px | Standard reading text |
|
||||
| Body Emphasis | SF Pro Text | 17px (1.06rem) | 600 | 1.24 (tight) | -0.374px | Emphasized body text, labels |
|
||||
| Button Large | SF Pro Text | 18px (1.13rem) | 300 | 1.00 (tight) | normal | Large button text, light weight |
|
||||
| Button | SF Pro Text | 17px (1.06rem) | 400 | 2.41 (relaxed) | normal | Standard button text |
|
||||
| Link | SF Pro Text | 14px (0.88rem) | 400 | 1.43 | -0.224px | Body links, "Learn more" |
|
||||
| Caption | SF Pro Text | 14px (0.88rem) | 400 | 1.29 (tight) | -0.224px | Secondary text, descriptions |
|
||||
| Caption Bold | SF Pro Text | 14px (0.88rem) | 600 | 1.29 (tight) | -0.224px | Emphasized captions |
|
||||
| Micro | SF Pro Text | 12px (0.75rem) | 400 | 1.33 | -0.12px | Fine print, footnotes |
|
||||
| Micro Bold | SF Pro Text | 12px (0.75rem) | 600 | 1.33 | -0.12px | Bold fine print |
|
||||
| Nano | SF Pro Text | 10px (0.63rem) | 400 | 1.47 | -0.08px | Legal text, smallest size |
|
||||
|
||||
### Principles
|
||||
- **Optical sizing as philosophy**: SF Pro automatically switches between Display and Text optical sizes. Display versions have wider letter spacing and thinner strokes optimized for large sizes; Text versions are tighter and sturdier for small sizes. This means the font literally changes its DNA based on context.
|
||||
- **Weight restraint**: The scale spans 300 (light) to 700 (bold) but most text lives at 400 (regular) and 600 (semibold). Weight 300 appears only on large decorative text. Weight 700 is rare, used only for bold card titles.
|
||||
- **Negative tracking at all sizes**: Unlike most systems that only track headlines, Apple applies subtle negative letter-spacing even at body sizes (-0.374px at 17px, -0.224px at 14px, -0.12px at 12px). This creates universally tight, efficient text.
|
||||
- **Extreme line-height range**: Headlines compress to 1.07 while body text opens to 1.47, and some button contexts stretch to 2.41. This dramatic range creates clear visual hierarchy through rhythm alone.
|
||||
|
||||
## 4. Component Stylings
|
||||
|
||||
### Buttons
|
||||
|
||||
**Primary Blue (CTA)**
|
||||
- Background: `#0071e3` (Apple Blue)
|
||||
- Text: `#ffffff`
|
||||
- Padding: 8px 15px
|
||||
- Radius: 8px
|
||||
- Border: 1px solid transparent
|
||||
- Font: SF Pro Text, 17px, weight 400
|
||||
- Hover: background brightens slightly
|
||||
- Active: `#ededf2` background shift
|
||||
- Focus: `2px solid var(--sk-focus-color, #0071E3)` outline
|
||||
- Use: Primary call-to-action ("Buy", "Shop iPhone")
|
||||
|
||||
**Primary Dark**
|
||||
- Background: `#1d1d1f`
|
||||
- Text: `#ffffff`
|
||||
- Padding: 8px 15px
|
||||
- Radius: 8px
|
||||
- Font: SF Pro Text, 17px, weight 400
|
||||
- Use: Secondary CTA, dark variant
|
||||
|
||||
**Pill Link (Learn More / Shop)**
|
||||
- Background: transparent
|
||||
- Text: `#0066cc` (light bg) or `#2997ff` (dark bg)
|
||||
- Radius: 980px (full pill)
|
||||
- Border: 1px solid `#0066cc`
|
||||
- Font: SF Pro Text, 14px-17px
|
||||
- Hover: underline decoration
|
||||
- Use: "Learn more" and "Shop" links — the signature Apple inline CTA
|
||||
|
||||
**Filter / Search Button**
|
||||
- Background: `#fafafc`
|
||||
- Text: `rgba(0, 0, 0, 0.8)`
|
||||
- Padding: 0px 14px
|
||||
- Radius: 11px
|
||||
- Border: 3px solid `rgba(0, 0, 0, 0.04)`
|
||||
- Focus: `2px solid var(--sk-focus-color, #0071E3)` outline
|
||||
- Use: Search bars, filter controls
|
||||
|
||||
**Media Control**
|
||||
- Background: `rgba(210, 210, 215, 0.64)`
|
||||
- Text: `rgba(0, 0, 0, 0.48)`
|
||||
- Radius: 50% (circular)
|
||||
- Active: scale(0.9), background shifts
|
||||
- Focus: `2px solid var(--sk-focus-color, #0071e3)` outline, white bg, black text
|
||||
- Use: Play/pause, carousel arrows
|
||||
|
||||
### Cards & Containers
|
||||
- Background: `#f5f5f7` (light) or `#272729`-`#2a2a2d` (dark)
|
||||
- Border: none (borders are rare in Apple's system)
|
||||
- Radius: 5px-8px
|
||||
- Shadow: `rgba(0, 0, 0, 0.22) 3px 5px 30px 0px` for elevated product cards
|
||||
- Content: centered, generous padding
|
||||
- Hover: no standard hover state — cards are static, links within them are interactive
|
||||
|
||||
### Navigation
|
||||
- Background: `rgba(0, 0, 0, 0.8)` (translucent dark) with `backdrop-filter: saturate(180%) blur(20px)`
|
||||
- Height: 48px (compact)
|
||||
- Text: `#ffffff` at 12px, weight 400
|
||||
- Active: underline on hover
|
||||
- Logo: Apple logomark (SVG) centered or left-aligned, 17x48px viewport
|
||||
- Mobile: collapses to hamburger with full-screen overlay menu
|
||||
- The nav floats above content, maintaining its dark translucent glass regardless of section background
|
||||
|
||||
### Image Treatment
|
||||
- Products on solid-color fields (black or white) — no backgrounds, no context, just the object
|
||||
- Full-bleed section images that span the entire viewport width
|
||||
- Product photography at extremely high resolution with subtle shadows
|
||||
- Lifestyle images confined to rounded-corner containers (12px+ radius)
|
||||
|
||||
### Distinctive Components
|
||||
|
||||
**Product Hero Module**
|
||||
- Full-viewport-width section with solid background (black or `#f5f5f7`)
|
||||
- Product name as the primary headline (SF Pro Display, 56px, weight 600)
|
||||
- One-line descriptor below in lighter weight
|
||||
- Two pill CTAs side by side: "Learn more" (outline) and "Buy" / "Shop" (filled)
|
||||
|
||||
**Product Grid Tile**
|
||||
- Square or near-square card on contrasting background
|
||||
- Product image dominating 60-70% of the tile
|
||||
- Product name + one-line description below
|
||||
- "Learn more" and "Shop" link pair at bottom
|
||||
|
||||
**Feature Comparison Strip**
|
||||
- Horizontal scroll of product variants
|
||||
- Each variant as a vertical card with image, name, and key specs
|
||||
- Minimal chrome — the products speak for themselves
|
||||
|
||||
## 5. Layout Principles
|
||||
|
||||
### Spacing System
|
||||
- Base unit: 8px
|
||||
- Scale: 2px, 4px, 5px, 6px, 7px, 8px, 9px, 10px, 11px, 14px, 15px, 17px, 20px, 24px
|
||||
- Notable characteristic: the scale is dense at small sizes (2-11px) with granular 1px increments, then jumps in larger steps. This allows precise micro-adjustments for typography and icon alignment.
|
||||
|
||||
### Grid & Container
|
||||
- Max content width: approximately 980px (the recurring "980px radius" in pill buttons echoes this width)
|
||||
- Hero: full-viewport-width sections with centered content block
|
||||
- Product grids: 2-3 column layouts within centered container
|
||||
- Single-column for hero moments — one product, one message, full attention
|
||||
- No visible grid lines or gutters — spacing creates implied structure
|
||||
|
||||
### Whitespace Philosophy
|
||||
- **Cinematic breathing room**: Each product section occupies a full viewport height (or close to it). The whitespace between products is not empty — it is the pause between scenes in a film.
|
||||
- **Vertical rhythm through color blocks**: Rather than using spacing alone to separate sections, Apple uses alternating background colors (black, `#f5f5f7`, white). Each color change signals a new "scene."
|
||||
- **Compression within, expansion between**: Text blocks are tightly set (negative letter-spacing, tight line-heights) while the space surrounding them is vast. This creates a tension between density and openness.
|
||||
|
||||
### Border Radius Scale
|
||||
- Micro (5px): Small containers, link tags
|
||||
- Standard (8px): Buttons, product cards, image containers
|
||||
- Comfortable (11px): Search inputs, filter buttons
|
||||
- Large (12px): Feature panels, lifestyle image containers
|
||||
- Full Pill (980px): CTA links ("Learn more", "Shop"), navigation pills
|
||||
- Circle (50%): Media controls (play/pause, arrows)
|
||||
|
||||
## 6. Depth & Elevation
|
||||
|
||||
| Level | Treatment | Use |
|
||||
|-------|-----------|-----|
|
||||
| Flat (Level 0) | No shadow, solid background | Standard content sections, text blocks |
|
||||
| Navigation Glass | `backdrop-filter: saturate(180%) blur(20px)` on `rgba(0,0,0,0.8)` | Sticky navigation bar — the glass effect |
|
||||
| Subtle Lift (Level 1) | `rgba(0, 0, 0, 0.22) 3px 5px 30px 0px` | Product cards, floating elements |
|
||||
| Media Control | `rgba(210, 210, 215, 0.64)` background with scale transforms | Play/pause buttons, carousel controls |
|
||||
| Focus (Accessibility) | `2px solid #0071e3` outline | Keyboard focus on all interactive elements |
|
||||
|
||||
**Shadow Philosophy**: Apple uses shadow extremely sparingly. The primary shadow (`3px 5px 30px` with 0.22 opacity) is soft, wide, and offset — mimicking a diffused studio light casting a natural shadow beneath a physical object. This reinforces the "product as physical sculpture" metaphor. Most elements have NO shadow at all; elevation comes from background color contrast (dark card on darker background, or light card on slightly different gray).
|
||||
|
||||
### Decorative Depth
|
||||
- Navigation glass: the translucent, blurred navigation bar is the most recognizable depth element, creating a sense of floating UI above scrolling content
|
||||
- Section color transitions: depth is implied by the alternation between black and light gray sections rather than by shadows
|
||||
- Product photography shadows: the products themselves cast shadows in their photography, so the UI doesn't need to add synthetic ones
|
||||
|
||||
## 7. Do's and Don'ts
|
||||
|
||||
### Do
|
||||
- Use SF Pro Display at 20px+ and SF Pro Text below 20px — respect the optical sizing boundary
|
||||
- Apply negative letter-spacing at all text sizes (not just headlines) — Apple tracks tight universally
|
||||
- Use Apple Blue (`#0071e3`) ONLY for interactive elements — it must be the singular accent
|
||||
- Alternate between black and light gray (`#f5f5f7`) section backgrounds for cinematic rhythm
|
||||
- Use 980px pill radius for CTA links — the signature Apple link shape
|
||||
- Keep product imagery on solid-color fields with no competing visual elements
|
||||
- Use the translucent dark glass (`rgba(0,0,0,0.8)` + blur) for sticky navigation
|
||||
- Compress headline line-heights to 1.07-1.14 — Apple headlines are famously tight
|
||||
|
||||
### Don't
|
||||
- Don't introduce additional accent colors — the entire chromatic budget is spent on blue
|
||||
- Don't use heavy shadows or multiple shadow layers — Apple's shadow system is one soft diffused shadow or nothing
|
||||
- Don't use borders on cards or containers — Apple almost never uses visible borders (except on specific buttons)
|
||||
- Don't apply wide letter-spacing to SF Pro — it is designed to run tight at every size
|
||||
- Don't use weight 800 or 900 — the maximum is 700 (bold), and even that is rare
|
||||
- Don't add textures, patterns, or gradients to backgrounds — solid colors only
|
||||
- Don't make the navigation opaque — the glass blur effect is essential to the Apple UI identity
|
||||
- Don't center-align body text — Apple body copy is left-aligned; only headlines center
|
||||
- Don't use rounded corners larger than 12px on rectangular elements (980px is for pills only)
|
||||
|
||||
## 8. Responsive Behavior
|
||||
|
||||
### Breakpoints
|
||||
| Name | Width | Key Changes |
|
||||
|------|-------|-------------|
|
||||
| Small Mobile | <360px | Minimum supported, single column |
|
||||
| Mobile | 360-480px | Standard mobile layout |
|
||||
| Mobile Large | 480-640px | Wider single column, larger images |
|
||||
| Tablet Small | 640-834px | 2-column product grids begin |
|
||||
| Tablet | 834-1024px | Full tablet layout, expanded nav |
|
||||
| Desktop Small | 1024-1070px | Standard desktop layout begins |
|
||||
| Desktop | 1070-1440px | Full layout, max content width |
|
||||
| Large Desktop | >1440px | Centered with generous margins |
|
||||
|
||||
### Touch Targets
|
||||
- Primary CTAs: 8px 15px padding creating ~44px touch height
|
||||
- Navigation links: 48px height with adequate spacing
|
||||
- Media controls: 50% radius circular buttons, minimum 44x44px
|
||||
- "Learn more" pills: generous padding for comfortable tapping
|
||||
|
||||
### Collapsing Strategy
|
||||
- Hero headlines: 56px Display → 40px → 28px on mobile, maintaining tight line-height proportionally
|
||||
- Product grids: 3-column → 2-column → single column stacked
|
||||
- Navigation: full horizontal nav → compact mobile menu (hamburger)
|
||||
- Product hero modules: full-bleed maintained at all sizes, text scales down
|
||||
- Section backgrounds: maintain full-width color blocks at all breakpoints — the cinematic rhythm never breaks
|
||||
- Image sizing: products scale proportionally, never crop — the product silhouette is sacred
|
||||
|
||||
### Image Behavior
|
||||
- Product photography maintains aspect ratio at all breakpoints
|
||||
- Hero product images scale down but stay centered
|
||||
- Full-bleed section backgrounds persist at every size
|
||||
- Lifestyle images may crop on mobile but maintain their rounded corners
|
||||
- Lazy loading for below-fold product images
|
||||
|
||||
## 9. Agent Prompt Guide
|
||||
|
||||
### Quick Color Reference
|
||||
- Primary CTA: Apple Blue (`#0071e3`)
|
||||
- Page background (light): `#f5f5f7`
|
||||
- Page background (dark): `#000000`
|
||||
- Heading text (light): `#1d1d1f`
|
||||
- Heading text (dark): `#ffffff`
|
||||
- Body text: `rgba(0, 0, 0, 0.8)` on light, `#ffffff` on dark
|
||||
- Link (light bg): `#0066cc`
|
||||
- Link (dark bg): `#2997ff`
|
||||
- Focus ring: `#0071e3`
|
||||
- Card shadow: `rgba(0, 0, 0, 0.22) 3px 5px 30px 0px`
|
||||
|
||||
### Example Component Prompts
|
||||
- "Create a hero section on black background. Headline at 56px SF Pro Display weight 600, line-height 1.07, letter-spacing -0.28px, color white. One-line subtitle at 21px SF Pro Display weight 400, line-height 1.19, color white. Two pill CTAs: 'Learn more' (transparent bg, white text, 1px solid white border, 980px radius) and 'Buy' (Apple Blue #0071e3 bg, white text, 8px radius, 8px 15px padding)."
|
||||
- "Design a product card: #f5f5f7 background, 8px border-radius, no border, no shadow. Product image top 60% of card on solid background. Title at 28px SF Pro Display weight 400, letter-spacing 0.196px, line-height 1.14. Description at 14px SF Pro Text weight 400, color rgba(0,0,0,0.8). 'Learn more' and 'Shop' links in #0066cc at 14px."
|
||||
- "Build the Apple navigation: sticky, 48px height, background rgba(0,0,0,0.8) with backdrop-filter: saturate(180%) blur(20px). Links at 12px SF Pro Text weight 400, white text. Apple logo left, links centered, search and bag icons right."
|
||||
- "Create an alternating section layout: first section black bg with white text and centered product image, second section #f5f5f7 bg with #1d1d1f text. Each section near full-viewport height with 56px headline and two pill CTAs below."
|
||||
- "Design a 'Learn more' link: text #0066cc on light bg or #2997ff on dark bg, 14px SF Pro Text, underline on hover. After the text, include a right-arrow chevron character (>). Wrap in a container with 980px border-radius for pill shape when used as a standalone CTA."
|
||||
|
||||
### Iteration Guide
|
||||
1. Every interactive element gets Apple Blue (`#0071e3`) — no other accent colors
|
||||
2. Section backgrounds alternate: black for immersive moments, `#f5f5f7` for informational moments
|
||||
3. Typography optical sizing: SF Pro Display at 20px+, SF Pro Text below — never mix
|
||||
4. Negative letter-spacing at all sizes: -0.28px at 56px, -0.374px at 17px, -0.224px at 14px, -0.12px at 12px
|
||||
5. The navigation glass effect (translucent dark + blur) is non-negotiable — it defines the Apple web experience
|
||||
6. Products always appear on solid color fields — never on gradients, textures, or lifestyle backgrounds in hero modules
|
||||
7. Shadow is rare and always soft: `3px 5px 30px 0.22 opacity` or nothing at all
|
||||
8. Pill CTAs use 980px radius — this creates the signature Apple rounded-rectangle-that-looks-like-a-capsule shape
|
||||
Reference in New Issue
Block a user