fix(chat): constrain auth state transitions

This commit is contained in:
2026-06-23 14:10:59 +08:00
parent ebd44c4980
commit 7dd4878d7d
2 changed files with 7 additions and 14 deletions
+6 -13
View File
@@ -7,7 +7,12 @@
* - `ChatGuestLogin` → 游客会话(断 WS = 不连)
* - `ChatNonVipLogin { token }` → 非 VIP 用户会话(不连 WS)
* - `ChatVipLogin { token }` → VIP 用户会话(连 WS
* - `ChatLogout` → 登出(机器自动 cleanup WS actor
* - `ChatLogout` → 正式登录用户登出(机器自动 cleanup WS actor
*
* 登录态流转约束:
* - 未登录:可以进入游客登录 / 其他登录。
* - 游客登录:只可以升级为其他登录,不响应退出。
* - 其他登录:可以退出,也可以在非 VIP / VIP 间切换,不响应游客登录。
*
* 状态结构(parent state 模式):
* - `idle`:屏没挂 / 登出
@@ -364,10 +369,6 @@ export const chatMachine = setup({
guestSession: {
on: {
ChatLogout: {
target: "#chat.idle",
actions: "clearChatSession",
},
ChatNonVipLogin: {
target: "#chat.nonVipUserSession",
actions: "startUserSession",
@@ -468,10 +469,6 @@ export const chatMachine = setup({
target: "#chat.idle",
actions: "clearChatSession",
},
ChatGuestLogin: {
target: "#chat.guestSession",
actions: "startGuestSession",
},
ChatNonVipLogin: {
target: "#chat.nonVipUserSession",
reenter: true,
@@ -595,10 +592,6 @@ export const chatMachine = setup({
target: "#chat.idle",
actions: "clearChatSession",
},
ChatGuestLogin: {
target: "#chat.guestSession",
actions: "startGuestSession",
},
ChatNonVipLogin: {
target: "#chat.nonVipUserSession",
actions: "startUserSession",