refactor(chat): remove vip websocket session flow
This commit is contained in:
@@ -8,19 +8,17 @@
|
||||
* chat 机器不感知鉴权。
|
||||
*
|
||||
* 鉴权生命周期事件(本轮新增):
|
||||
* - `ChatGuestLogin`:游客进入 /chat —— 拉本地消息 + 初始化配额(不连 WS)
|
||||
* - `ChatNonVipLogin`:非 VIP 用户进入 /chat —— 拉服务器端首屏,不连 WS
|
||||
* - `ChatVipLogin`:VIP 用户进入 /chat —— 拉服务器端首屏 + 连 WS(token 在 payload)
|
||||
* - `ChatLogout`:正式登录用户登出 —— 断 WS + 清消息
|
||||
* - `ChatGuestLogin`:游客进入 /chat —— 拉服务器端首屏,不连 WS
|
||||
* - `ChatUserLogin`:其他登录用户进入 /chat —— 拉服务器端首屏,不连 WS
|
||||
* - `ChatLogout`:正式登录用户登出 —— 清消息
|
||||
*
|
||||
* 设计:所有WS / 历史 / 配额相关副作用全部通过派发事件给 chat 机器处理,
|
||||
* chat-screen 不直接创建 ChatWebSocket / 不读 AuthStorage(除 token 取值)。
|
||||
* 设计:所有历史 / 配额相关副作用全部通过派发事件给 chat 机器处理,
|
||||
* chat-screen 不直接读 AuthStorage(除 token 取值)。
|
||||
*/
|
||||
export type ChatEvent =
|
||||
// 鉴权生命周期(登录态变化后由 ChatAuthSync 派)
|
||||
| { type: "ChatGuestLogin" }
|
||||
| { type: "ChatNonVipLogin"; token: string }
|
||||
| { type: "ChatVipLogin"; token: string }
|
||||
| { type: "ChatUserLogin"; token: string }
|
||||
| { type: "ChatLogout" }
|
||||
// 业务事件
|
||||
| { type: "ChatSendMessage"; content: string }
|
||||
@@ -32,26 +30,4 @@ export type ChatEvent =
|
||||
type: "ChatQueuedHttpDone";
|
||||
output: import("./chat-machine.helpers").HttpSendOutput;
|
||||
}
|
||||
| { type: "ChatQueuedSendError"; content: string; errorMessage: string }
|
||||
| { type: "ChatImageReceived"; url: string }
|
||||
| {
|
||||
type: "ChatPaywallStatusReceived";
|
||||
lockDetail: {
|
||||
locked: boolean;
|
||||
showContent: boolean;
|
||||
showUpgrade: boolean;
|
||||
reason: string | null;
|
||||
hint: string | null;
|
||||
detail: Record<string, unknown> | null;
|
||||
};
|
||||
}
|
||||
// WebSocket / AI 推句(由 chat 机器内部 actor 派回 —— "机器自驱动")
|
||||
| {
|
||||
type: "ChatAISentenceReceived";
|
||||
index: number;
|
||||
text: string;
|
||||
total: number;
|
||||
done: boolean;
|
||||
}
|
||||
| { type: "ChatWebSocketError"; errorMessage: string }
|
||||
| { type: "ChatWebSocketConnected"; userId: string };
|
||||
| { type: "ChatQueuedSendError"; content: string; errorMessage: string };
|
||||
|
||||
Reference in New Issue
Block a user