refactor(chat): split sessions by vip status

This commit is contained in:
2026-06-22 15:11:57 +08:00
parent b105ba3457
commit 6ff1accad5
5 changed files with 225 additions and 81 deletions
+4 -2
View File
@@ -9,7 +9,8 @@
*
* 鉴权生命周期事件(本轮新增):
* - `ChatGuestLogin`:游客进入 /chat —— 拉本地消息 + 初始化配额(不连 WS)
* - `ChatNonGuestLogin`:非游客进入 /chat —— 拉服务器端首屏 + 连 WStoken 在 payload
* - `ChatNonVipLogin`:非 VIP 用户进入 /chat —— 拉服务器端首屏,不连 WS
* - `ChatVipLogin`VIP 用户进入 /chat —— 拉服务器端首屏 + 连 WStoken 在 payload
* - `ChatLogout`:登出 / 切换用户 —— 断 WS + 清消息
*
* 设计:所有WS / 历史 / 配额相关副作用全部通过派发事件给 chat 机器处理,
@@ -18,7 +19,8 @@
export type ChatEvent =
// 鉴权生命周期(登录态变化后由 ChatAuthSync 派)
| { type: "ChatGuestLogin" }
| { type: "ChatNonGuestLogin"; token: string; isVip: boolean }
| { type: "ChatNonVipLogin"; token: string }
| { type: "ChatVipLogin"; token: string }
| { type: "ChatLogout" }
// 业务事件
| { type: "ChatSendMessage"; content: string }