feat: API层与认证流(client拦截/守卫/登录改密实装/域API骨架/vitest)
- 自建轻量 axios client(src/api/client.ts):Bearer 注入、401 清会话跳登录
(login 请求除外)、409 精确匹配"必须先修改初始密码"跳强制改密(区别于并发
冲突 409)、429/网络错误统一 ElMessage、ApiError 标准化、showErrorMessage
可opt-out——模板 utils/http 的 {code,msg,data} 信封与后端裸 HTTP 语义不符故弃用
- Pinia auth store(src/store/modules/auth.ts):token/role/tenant_slug/
must_change 落地并持久化(all-kefu-auth key),login/logout/changePassword/
会话过期/强制改密跳转(动态 import 断循环)
- 路由守卫:token 事实源判定、must_change 全站门(除改密页)、UserInfo 由登录
快照派生(后端无用户信息端点);user store 残留自愈
- 登录页实装(去除角色调试开关)、强制改密页实装;用户菜单/锁屏对接真实 logout
- 域 API 骨架:tenants/config/conversations/stats/settings(类型+端点常量)
- mask 哨兵助手:__SET__ ↔ 已设置 表单语义
- vitest 25 例(client 11/store 8/mask 6);登录页拖拽验证 reset 空引用修复
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* 统计分析 API 骨架(Phase 3 Task 3)
|
||||
*
|
||||
* 端点事实源:app/platform/routes/stats_routes.py + app/platform/stats.py
|
||||
* (平台合并统计 / 单租户统计,?from/&to= 闭区间)。本文件只建类型与
|
||||
* 端点常量——调用函数在 Task 4(仪表盘)与 Task 8(统计分析)实装。
|
||||
*/
|
||||
|
||||
/** 指标卡(None 项为 null——如无推送时成功率无定义) */
|
||||
export interface StatsCards {
|
||||
conversations: number
|
||||
leads: number
|
||||
high_intent: number
|
||||
push_success_rate: number | null
|
||||
}
|
||||
|
||||
/** 漏斗计数 */
|
||||
export interface StatsFunnel {
|
||||
conversations: number
|
||||
leads: number
|
||||
evaluated: number
|
||||
push_succeeded: number
|
||||
}
|
||||
|
||||
/** 按日趋势行 */
|
||||
export interface StatsTrendPoint {
|
||||
date: string
|
||||
conversations: number
|
||||
leads: number
|
||||
}
|
||||
|
||||
/** 分布视图(intent 按枚举键、source/site 计数表、country Top 数组) */
|
||||
export interface StatsDistributions {
|
||||
intent: Record<string, number>
|
||||
source: Record<string, number>
|
||||
site: Record<string, number>
|
||||
country: Array<{ country: string; count: number }>
|
||||
}
|
||||
|
||||
/** 推送健康计数 */
|
||||
export interface PushHealth {
|
||||
pending: number
|
||||
success: number
|
||||
failed: number
|
||||
skipped: number
|
||||
duplicated: number
|
||||
}
|
||||
|
||||
/** 统计响应(平台合并与单租户同构) */
|
||||
export interface StatsResponse {
|
||||
cards: StatsCards
|
||||
funnel: StatsFunnel
|
||||
trend: StatsTrendPoint[]
|
||||
distributions: StatsDistributions
|
||||
push_health: PushHealth
|
||||
}
|
||||
|
||||
/** 统计查询参数(from/to 闭区间,ISO 日期) */
|
||||
export interface StatsParams {
|
||||
from?: string
|
||||
to?: string
|
||||
}
|
||||
|
||||
/** 统计端点(platform 合并版仅超管;单租户版超管或本租户管理员) */
|
||||
export const STATS_ENDPOINTS = {
|
||||
platform: '/api/platform/stats',
|
||||
tenant: (slug: string) => `/api/platform/tenants/${slug}/stats`
|
||||
} as const
|
||||
Reference in New Issue
Block a user