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,98 @@
|
||||
/**
|
||||
* 会话与线索 API 骨架(Phase 3 Task 3)
|
||||
*
|
||||
* 端点事实源:app/platform/routes/data_routes.py
|
||||
* (会话列表/详情/删除、推送日志)。本文件只建类型与端点常量——
|
||||
* 调用函数在 Task 5(会话与线索)实装。
|
||||
*/
|
||||
|
||||
/** 意向层级(Evaluation.intent_level) */
|
||||
export type IntentLevel = 'high' | 'medium' | 'low' | 'none' | null
|
||||
|
||||
/** 联系方式(评估产出) */
|
||||
export interface ContactInfo {
|
||||
email?: string | null
|
||||
whatsapp?: string | null
|
||||
phone?: string | null
|
||||
}
|
||||
|
||||
/** 会话列表行(GET /api/platform/tenants/{slug}/conversations) */
|
||||
export interface ConversationListItem {
|
||||
id: string
|
||||
session_id: string
|
||||
status: string
|
||||
source: string
|
||||
site: string | null
|
||||
ip: string
|
||||
device: string
|
||||
country: string | null
|
||||
intent_level: IntentLevel
|
||||
reasoning: string | null
|
||||
contact_info: ContactInfo | null
|
||||
email_sent: boolean
|
||||
message_count: number
|
||||
preview: string
|
||||
created_at: string | null
|
||||
}
|
||||
|
||||
/** 会话列表查询参数(intent 白名单校验在后端;from/to 为闭区间日期) */
|
||||
export interface ConversationListParams {
|
||||
intent?: string
|
||||
site?: string
|
||||
from?: string
|
||||
to?: string
|
||||
page?: number
|
||||
page_size?: number
|
||||
}
|
||||
|
||||
/** 会话列表响应 */
|
||||
export interface ConversationListResponse {
|
||||
total: number
|
||||
page: number
|
||||
page_size: number
|
||||
items: ConversationListItem[]
|
||||
}
|
||||
|
||||
/** 会话详情消息行(时间升序) */
|
||||
export interface ConversationMessage {
|
||||
role: 'user' | 'assistant' | 'system' | string
|
||||
content: string
|
||||
created_at: string | null
|
||||
}
|
||||
|
||||
/** 会话详情响应(GET .../conversations/{convId}) */
|
||||
export interface ConversationDetailResponse extends ConversationListItem {
|
||||
client_info: Record<string, unknown>
|
||||
messages: ConversationMessage[]
|
||||
profile: {
|
||||
chips: Record<string, unknown>
|
||||
summary: string | null
|
||||
} | null
|
||||
}
|
||||
|
||||
/** 推送日志行(GET .../push-logs) */
|
||||
export interface PushLogItem {
|
||||
id: number
|
||||
conversation_id: string
|
||||
status: string
|
||||
error: string | null
|
||||
created_at: string | null
|
||||
}
|
||||
|
||||
/** 推送日志响应 */
|
||||
export interface PushLogResponse {
|
||||
total: number
|
||||
page: number
|
||||
page_size: number
|
||||
items: PushLogItem[]
|
||||
}
|
||||
|
||||
/** 会话与线索端点 */
|
||||
export const CONVERSATION_ENDPOINTS = {
|
||||
list: (slug: string) => `/api/platform/tenants/${slug}/conversations`,
|
||||
detail: (slug: string, convId: string) =>
|
||||
`/api/platform/tenants/${slug}/conversations/${convId}`,
|
||||
remove: (slug: string, convId: string) =>
|
||||
`/api/platform/tenants/${slug}/conversations/${convId}`,
|
||||
pushLogs: (slug: string) => `/api/platform/tenants/${slug}/push-logs`
|
||||
} as const
|
||||
Reference in New Issue
Block a user