@jetthai/cuora 1.1.428-dev.0 → 1.1.428-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/docs/kibana/play-providerId-error.md +202 -0
- package/docs/kibana/play-selectedWalletType.md +1 -0
- package/docs/kibana/play-selectedWalletType_2.md +1 -0
- package/docs/kibana/play-selectedWalletType_analysis.md +565 -0
- package/package.json +1 -1
- package/src/machine/game_v2_1.js +6 -4
- /package/{doc → docs}/kibana/crypto-way-deposit-amount-bug-analysis.md +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.1.428-dev.2](https://github.com/jetthai/cuora-module/compare/v1.1.428-dev.1...v1.1.428-dev.2) (2026-04-13)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **game:** 防止 connectGame 將字串 "null" 的 providerId 送至後端 ([6bd8b60](https://github.com/jetthai/cuora-module/commit/6bd8b6017f351bd53295abb494835c66c65561fe))
|
|
11
|
+
|
|
12
|
+
### [1.1.428-dev.1](https://github.com/jetthai/cuora-module/compare/v1.1.428-dev.0...v1.1.428-dev.1) (2026-04-13)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **game:** 防止 selectedWalletType 為 null 送至後端 ([e62d195](https://github.com/jetthai/cuora-module/commit/e62d195cc12a0ec1021480e4c76b62005925da54))
|
|
18
|
+
|
|
5
19
|
### [1.1.428-dev.0](https://github.com/jetthai/cuora-module/compare/v1.1.427...v1.1.428-dev.0) (2026-04-13)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# /play API providerId=null 問題分析
|
|
2
|
+
|
|
3
|
+
## Kibana 原始日誌
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
2026-04-12 15:43:19.243 [69dbbd97a2e6bc7e5b55e1bfd646452a][78866ac2-f985-4cce-81bd-e39f3fb94d0c][DEBUG][logoutPlayer][http-nio-15050-exec-19] - Request IP:【10.8.19.124】,Request URL:【http://gameprovider-connector-vd.default.svc.cluster.local/game-provider/forward-game】,Request Param:【[FrowardGameRequestBean(uuid=null, providerId=null, gameTypeId=live, gameId=SMG_titaniumLiveGames_MP_Baccarat, uidSite=btkmn08d74kzqpwz2gq@BTK, mappingId=8, isDemo=false, returnUrl=https://www.be-ttk-222.com/play, lang=ko_KR, isMobile=null, ip=211.223.151.97, ipAddress=null, selectedWalletType=ACTIVITY, userTags={=[DEPOSIT_5_9, DEPOSITED_YESTERDAY, AFTERNOON_HIGHLY_ACTIVE, LOYAL_CUSTOMER, FIRST_WITHDRAW_IN_30_DAYS]})]】,Time:【2026-04-12 15:43:19.243】
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
### 關鍵欄位
|
|
10
|
+
|
|
11
|
+
| 欄位 | 值 | 說明 |
|
|
12
|
+
| -------------------- | ----------------------------------- | ------------------------------------------- |
|
|
13
|
+
| `providerId` | `null` | **異常** — 不應為空 |
|
|
14
|
+
| `uuid` | `null` | **異常** — 不應為空 |
|
|
15
|
+
| `gameId` | `SMG_titaniumLiveGames_MP_Baccarat` | 正常 |
|
|
16
|
+
| `gameTypeId` | `live` | 正常 |
|
|
17
|
+
| `uidSite` | `btkmn08d74kzqpwz2gq@BTK` | 已登入的 BTK 品牌用戶 |
|
|
18
|
+
| `selectedWalletType` | `ACTIVITY` | 用戶選擇了活動錢包 → 經過 ModalSelectWallet |
|
|
19
|
+
| `mappingId` | `8` | 正常 |
|
|
20
|
+
| `isMobile` | `null` | 可能是桌面端 |
|
|
21
|
+
| `lang` | `ko_KR` | 韓語用戶 |
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 資料流追蹤
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
遊戲來源 (活動 API response, provider 欄位缺失)
|
|
29
|
+
→ 活動元件映射 game.providerId = game.provider → null
|
|
30
|
+
→ store.enterGame()
|
|
31
|
+
→ ModalSelectWallet (用戶選擇 ACTIVITY 錢包)
|
|
32
|
+
→ $gameService.send('ENTER_GAME', { game: { providerId: null, ... } })
|
|
33
|
+
→ XState setGameInfo → context.game.providerId = null
|
|
34
|
+
→ flow.idle → flow.connecting
|
|
35
|
+
├─ connectGame service: !null === true → 防呆攔截 → return undefined
|
|
36
|
+
│ └─ onDone → setGameURL 收到 undefined → 畫面無遊戲
|
|
37
|
+
└─ gameNavigationHandler: 讀取 context.game.providerId = null
|
|
38
|
+
└─ URL 序列化: ${null} → 字串 "null"
|
|
39
|
+
└─ router.push('/play?...&providerId=null&walletType=ACTIVITY&...')
|
|
40
|
+
|
|
41
|
+
用戶重新整理頁面 (或 beforeRouteUpdate 觸發)
|
|
42
|
+
→ play.vue 讀取 $route.query.providerId → 字串 "null"
|
|
43
|
+
→ URL 已帶 walletType=ACTIVITY → 不彈 ModalSelectWallet
|
|
44
|
+
→ $gameService.send('ENTER_GAME', { game: { providerId: "null", ... } })
|
|
45
|
+
→ connectGame: !"null" === false → 防呆失效!
|
|
46
|
+
→ API 請求送出: provider_id="null"
|
|
47
|
+
→ 後端記錄 Kibana 錯誤
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 根因分析
|
|
53
|
+
|
|
54
|
+
### 根因 #1:活動 API 遊戲資料缺少 `provider` 欄位
|
|
55
|
+
|
|
56
|
+
活動/任務 API 的遊戲資料結構使用 `provider` 欄位(非 `providerId`),前端元件手動映射。
|
|
57
|
+
如果後端回傳的遊戲資料中 `provider` 欄位缺失,`providerId` 就會是 `null`。
|
|
58
|
+
|
|
59
|
+
**涉及檔案:**
|
|
60
|
+
|
|
61
|
+
| 檔案 | 行號 | 程式碼 |
|
|
62
|
+
| ------------------------------------------------ | ---- | ------------------------------------------- |
|
|
63
|
+
| `components/modal/MiniGame.vue` | 118 | `game.providerId = game.provider \|\| null` |
|
|
64
|
+
| `components/mission/SpecifyBetsActivity.vue` | 74 | `game.providerId = game.provider` |
|
|
65
|
+
| `components/mission/SpecifyTurnoverActivity.vue` | 75 | `game.providerId = game.provider` |
|
|
66
|
+
| `components/mission/RankingActivity.vue` | 54 | `game.providerId = game.provider` |
|
|
67
|
+
| `pages/mission/allgames/_activityNo.vue` | 50 | `game.providerId = game.provider` |
|
|
68
|
+
|
|
69
|
+
**嚴重度:高** — 這是 `providerId=null` 的源頭。
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
### 根因 #2:URL 序列化將 `null` 轉為字串 `"null"`,繞過防呆
|
|
74
|
+
|
|
75
|
+
`utils/gameNavigationHandler.js:39-45`:
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
const { gameCode, providerId, gameId, gameTypeId, mappingId } = game
|
|
79
|
+
const params = { gameCode, providerId, gameId, gameTypeId, mappingId }
|
|
80
|
+
const qs = Object.keys(params)
|
|
81
|
+
.map((key) => `${key}=${params[key]}`) // ${null} → "null"
|
|
82
|
+
.join('&')
|
|
83
|
+
router.push(`/play?${qs}`)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`null` 被 template literal 轉為字串 `"null"`,URL 變成 `/play?...&providerId=null&...`。
|
|
87
|
+
後續從 `$route.query` 讀回時已經是字串 `"null"`,不再是 JavaScript `null`。
|
|
88
|
+
|
|
89
|
+
**嚴重度:高** — 這是防呆失效的關鍵轉換點。
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### 根因 #3:`connectGame` 防呆無法攔截字串 `"null"`
|
|
94
|
+
|
|
95
|
+
`node_modules/@jetthai/cuora/src/machine/game_v2_1.js:641-645`:
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
connectGame: async (context, event) => {
|
|
99
|
+
const { providerId, gameId } = context.game || {}
|
|
100
|
+
if (!providerId || !gameId) return // !"null" === false → 不攔截
|
|
101
|
+
// ...
|
|
102
|
+
const params = { provider_id: providerId, ... } // provider_id = "null"
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
| `providerId` 值 | `!providerId` | 防呆結果 |
|
|
107
|
+
| -------------------- | ------------- | ------------------ |
|
|
108
|
+
| `null` | `true` | 攔截(正確) |
|
|
109
|
+
| `undefined` | `true` | 攔截(正確) |
|
|
110
|
+
| `""` | `true` | 攔截(正確) |
|
|
111
|
+
| `"null"` (字串) | `false` | **不攔截(錯誤)** |
|
|
112
|
+
| `"undefined"` (字串) | `false` | **不攔截(錯誤)** |
|
|
113
|
+
|
|
114
|
+
**嚴重度:高** — 字串 `"null"` 被當作合法 providerId 送到後端。
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### 根因 #4:頁面重整時從 URL 直接使用未驗證的參數
|
|
119
|
+
|
|
120
|
+
`pages/play.vue:474-490`:
|
|
121
|
+
|
|
122
|
+
```javascript
|
|
123
|
+
if (shouldSendEnterGame && !this.getClickPlayGame) {
|
|
124
|
+
const selectWalletEnable = this.getSiteConfig?.selectWalletEnable
|
|
125
|
+
if (selectWalletEnable && !walletType) {
|
|
126
|
+
// 缺 walletType → 彈 ModalSelectWallet
|
|
127
|
+
this.enterGame({ game: { gameCode, providerId, gameId, gameTypeId, mappingId }, ... })
|
|
128
|
+
} else {
|
|
129
|
+
// URL 已帶 walletType → 直接進入遊戲,不驗證 providerId 是否有效
|
|
130
|
+
this.$gameService.send({
|
|
131
|
+
type: 'ENTER_GAME',
|
|
132
|
+
data: { game: { gameCode, providerId, gameId, gameTypeId, mappingId }, walletType },
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
頁面重整時 URL 已帶 `walletType=ACTIVITY` → 走 `else` 分支 → 直接發送 `ENTER_GAME`。
|
|
139
|
+
此時 `providerId` 為字串 `"null"`,不會經過任何驗證。
|
|
140
|
+
|
|
141
|
+
**嚴重度:中** — 頁面重整是觸發 API 帶 `"null"` 的直接路徑。
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
### 根因 #5(時序問題):`getSiteConfig` 未載入時跳過錢包選擇
|
|
146
|
+
|
|
147
|
+
`pages/play.vue:475`:
|
|
148
|
+
|
|
149
|
+
```javascript
|
|
150
|
+
const selectWalletEnable = this.getSiteConfig?.selectWalletEnable
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
`handlePlayRouteQuery` 在 `beforeMount` 就呼叫(`play.vue:257-258`)。
|
|
154
|
+
如果 `getSiteConfig` API 回應慢(裝置卡頓、網路延遲),`selectWalletEnable` 為 `undefined`:
|
|
155
|
+
|
|
156
|
+
- 即使站台 `selectWalletEnable=true`,也走 `else` 分支直接送 ENTER_GAME
|
|
157
|
+
- `walletType` 此時為 `undefined`,後端收到 `selectedWalletType=null`
|
|
158
|
+
|
|
159
|
+
> 本次 Kibana 日誌 `selectedWalletType=ACTIVITY`,所以此次事件不是這個原因,但仍為潛在風險。
|
|
160
|
+
|
|
161
|
+
**嚴重度:低** — 此次非主因,但為獨立的潛在問題。
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## 最可能的事件重建
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
1. 用戶從活動/任務頁面點擊遊戲 SMG_titaniumLiveGames_MP_Baccarat
|
|
169
|
+
2. 活動 API 回傳的遊戲資料中 provider 欄位缺失
|
|
170
|
+
3. 活動元件映射:game.providerId = game.provider → null
|
|
171
|
+
4. 觸發 enterGame(),因 selectWalletEnable=true 彈出 ModalSelectWallet
|
|
172
|
+
5. 用戶選擇 ACTIVITY 錢包並確認
|
|
173
|
+
6. $gameService 收到 ENTER_GAME,context.game.providerId = null
|
|
174
|
+
7. 進入 flow.connecting:
|
|
175
|
+
- connectGame 防呆攔截 (!null → true) → return undefined
|
|
176
|
+
- onDone 觸發,setGameURL 收到 undefined → 畫面無遊戲顯示
|
|
177
|
+
- gameNavigationHandler 將 null 序列化為字串寫入 URL
|
|
178
|
+
8. 用戶看到空白/錯誤,重新整理頁面
|
|
179
|
+
9. play.vue 讀取 URL → providerId="null"(字串)
|
|
180
|
+
10. URL 已帶 walletType=ACTIVITY → 直接發送 ENTER_GAME(不彈彈窗)
|
|
181
|
+
11. connectGame 防呆被字串 "null" 繞過
|
|
182
|
+
12. API 請求送出 → 後端記錄 Kibana 錯誤
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## 問題總結
|
|
188
|
+
|
|
189
|
+
| 層級 | 問題 | 嚴重度 |
|
|
190
|
+
| ---------- | -------------------------------------------------------------------- | ------ |
|
|
191
|
+
| 資料源 | 活動 API 遊戲的 `provider` 欄位可能缺失,映射後 `providerId=null` | 高 |
|
|
192
|
+
| URL 序列化 | `gameNavigationHandler` 將 `null` 轉為字串 `"null"` 寫入 URL,無過濾 | 高 |
|
|
193
|
+
| 防呆失效 | `connectGame` 的 `!providerId` 無法攔截字串 `"null"` | 高 |
|
|
194
|
+
| 頁面重整 | `play.vue` 重整時從 URL 讀回字串 `"null"` 直接使用,不驗證 | 中 |
|
|
195
|
+
| 時序競爭 | `getSiteConfig` 未載入時可能跳過錢包選擇流程 | 低 |
|
|
196
|
+
|
|
197
|
+
## 建議修復方向
|
|
198
|
+
|
|
199
|
+
1. **活動元件**:映射時驗證 `provider` 欄位有效性,缺失時 log 警告或不顯示該遊戲
|
|
200
|
+
2. **gameNavigationHandler**:序列化前過濾 null/undefined,或在 `providerId` 為空時阻止導航
|
|
201
|
+
3. **connectGame 防呆**:加入 `providerId === 'null'` / `providerId === 'undefined'` 字串檢查
|
|
202
|
+
4. **play.vue**:從 URL 讀取參數後驗證必要欄位(`providerId`、`gameId`),無效時導回首頁或顯示錯誤提示
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Request IP:【10.8.83.20】,Request URL:【http://gameprovider-connector-vd.default.svc.cluster.local/game-provider/forward-game】,Request Param:【[FrowardGameRequestBean(uuid=null, providerId=VD_BGL, gameTypeId=live, gameId=casino, uidSite=btkmn08d74kzqpwz2gq@BTK, mappingId=8, isDemo=false, returnUrl=https://www.be-ttk-222.com/play, lang=ko_KR, isMobile=null, ip=211.223.151.97, ipAddress=null, selectedWalletType=null, userTags={=[DEPOSIT_5_9, DEPOSITED_YESTERDAY, FIRST_WITHDRAW_IN_30_DAYS]})]】,Time:【2026-04-12 15:07:00.195】
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Request IP:【10.8.3.20】,Request URL:【http://gameprovider-connector-vd.default.svc.cluster.local/game-provider/forward-game】,Request Param:【[FrowardGameRequestBean(uuid=null, providerId=VD_EVO, gameTypeId=live, gameId=XXXtremeLB000001, uidSite=btkmn08d74kzqpwz2gq@BTK, mappingId=8, isDemo=false, returnUrl=https://www.be-ttk-222.com/play, lang=ko_KR, isMobile=null, ip=211.223.151.97, ipAddress=null, selectedWalletType=null, userTags={=[DEPOSIT_5_9]})]】,Time:【2026-04-12 10:07:49.179】
|
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
# selectedWalletType = null 問題分析
|
|
2
|
+
|
|
3
|
+
## Kibana 錯誤記錄
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
# 記錄 1 — 2026-04-12 10:07:49
|
|
7
|
+
FrowardGameRequestBean(
|
|
8
|
+
providerId=VD_EVO, gameId=XXXtremeLB000001,
|
|
9
|
+
uidSite=btkmn08d74kzqpwz2gq@BTK,
|
|
10
|
+
selectedWalletType=null, isMobile=null
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
# 記錄 2 — 2026-04-12 15:07:00
|
|
14
|
+
FrowardGameRequestBean(
|
|
15
|
+
providerId=VD_BGL, gameId=casino,
|
|
16
|
+
uidSite=btkmn08d74kzqpwz2gq@BTK,
|
|
17
|
+
selectedWalletType=null, isMobile=null
|
|
18
|
+
)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- 同一 BTK 用戶,5 小時內兩次都是 null → **系統性問題,非偶發**
|
|
22
|
+
- BTK 品牌 `selectWalletEnable = true`,正常流程應該透過 ModalSelectWallet 選擇錢包
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 資料流全貌
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
元件點擊 (PlayGame / GameButton / Sidebar / GridGame / FloatCategory ...)
|
|
30
|
+
│ enterGame({ game, locale }) ← 不帶 walletType
|
|
31
|
+
▼
|
|
32
|
+
store.enterGame() ← store/index.js:911
|
|
33
|
+
│ selectWalletEnable = true
|
|
34
|
+
▼
|
|
35
|
+
彈出 ModalSelectWallet ← store/index.js:917
|
|
36
|
+
│ 用戶選擇錢包 → confirm()
|
|
37
|
+
▼
|
|
38
|
+
eventData = { ...gameData, walletType: 'CASH' | 'ACTIVITY' }
|
|
39
|
+
$gameService.send({ type: 'ENTER_GAME', data: eventData })
|
|
40
|
+
│ ← SelectWallet.vue:173
|
|
41
|
+
▼
|
|
42
|
+
XState: setWalletType action ← game_v2_1.js:468
|
|
43
|
+
│ context.walletType = event.data.walletType
|
|
44
|
+
▼
|
|
45
|
+
XState: flow.idle → flow.connecting
|
|
46
|
+
│ invoke: connectGame service ← game_v2_1.js:167
|
|
47
|
+
▼
|
|
48
|
+
gameNavigationHandler (onTransition) ← gameNavigationHandler.js:16
|
|
49
|
+
│ state.matches('flow.connecting')
|
|
50
|
+
│ if (walletType) params.walletType = walletType ← :41
|
|
51
|
+
│ router.push(`/play?${qs}`) ← :57
|
|
52
|
+
▼
|
|
53
|
+
play.vue beforeMount ← play.vue:256
|
|
54
|
+
│ handlePlayRouteQuery(query, { shouldSendEnterGame: true })
|
|
55
|
+
│ getClickPlayGame = true → 不重送 ENTER_GAME ← play.vue:471
|
|
56
|
+
▼
|
|
57
|
+
connectGame service ← game_v2_1.js:640
|
|
58
|
+
│ const { walletType } = context ← :647
|
|
59
|
+
│ selected_wallet_type: walletType ← :657
|
|
60
|
+
▼
|
|
61
|
+
API: /game/play → 後端收到 selectedWalletType
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 相關程式碼位置
|
|
67
|
+
|
|
68
|
+
| 檔案 | 行號 | 作用 |
|
|
69
|
+
| ------------------------------------------------------ | --------------------- | ------------------------------------------------------------------------ |
|
|
70
|
+
| `store/index.js` | 911-940 | `enterGame` action,判斷是否彈 modal |
|
|
71
|
+
| `components/modal/SelectWallet.vue` | 141-183 | `confirm()` 方法,送出帶 walletType 的 event |
|
|
72
|
+
| `components/modal/SelectWallet.vue` | 121-139 | `waitForDispatchableState()` 等待可派送狀態,5 秒超時 |
|
|
73
|
+
| `components/modal/SelectWallet.vue` | 81-91 | `close()` 方法,設定 confirmCancelled |
|
|
74
|
+
| `components/modal/SelectWallet.vue` | 69-71 | `getWalletType` computed,依據 defaultChecked 回傳 CASH/ACTIVITY |
|
|
75
|
+
| `components/modal/SelectWallet.vue` | 92-96 | `setDefaultChecked()`,mounted 時根據 withdraw_rule 設定預設值 |
|
|
76
|
+
| `utils/gameNavigationHandler.js` | 37-41 | 從 context 取 walletType,truthy 才加入 URL params |
|
|
77
|
+
| `utils/gameNavigationHandler.js` | 57 | `router.push(/play?${qs})` 導航到 play 頁面 |
|
|
78
|
+
| `pages/play.vue` | 256-258 | `beforeMount` 呼叫 handlePlayRouteQuery |
|
|
79
|
+
| `pages/play.vue` | 373-375 | `getRouteGameQuery` 從 URL query 解構 walletType |
|
|
80
|
+
| `pages/play.vue` | 471-475 | **關鍵**:`shouldSendEnterGame && !getClickPlayGame` 時直接送 ENTER_GAME |
|
|
81
|
+
| `pages/play.vue` | 353-354 | `beforeDestroy` 清除 gameWalletType 和 clickPlayGame |
|
|
82
|
+
| `node_modules/@jetthai/cuora/src/machine/game_v2_1.js` | 46 | context 初始值 `walletType: null` |
|
|
83
|
+
| `node_modules/@jetthai/cuora/src/machine/game_v2_1.js` | 88, 96, 229, 236, 250 | ENTER_GAME / MENU_ENTER_GAME transition 都帶 setWalletType action |
|
|
84
|
+
| `node_modules/@jetthai/cuora/src/machine/game_v2_1.js` | 468-470 | `setWalletType: assign → walletType: event.data.walletType` |
|
|
85
|
+
| `node_modules/@jetthai/cuora/src/machine/game_v2_1.js` | 640-664 | `connectGame` service,組裝 API 參數 |
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 問題根因
|
|
90
|
+
|
|
91
|
+
### 根因 1(最高概率):play.vue 頁面刷新 / 深層連結,URL 不帶 walletType
|
|
92
|
+
|
|
93
|
+
**觸發方式:**
|
|
94
|
+
|
|
95
|
+
- 用戶在 play 頁面按 F5 / 瀏覽器重載
|
|
96
|
+
- 用戶從書籤、分享連結、瀏覽器歷史記錄直接進入 play 頁面
|
|
97
|
+
- 網路斷線後瀏覽器自動重載
|
|
98
|
+
|
|
99
|
+
**流程:**
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
① 頁面重載 → XState context 重置 → walletType 回到初始值 null
|
|
103
|
+
② play.vue beforeMount 執行
|
|
104
|
+
③ handlePlayRouteQuery(query, { shouldSendEnterGame: true })
|
|
105
|
+
④ getClickPlayGame = false(剛重載,store 也重置了)
|
|
106
|
+
⑤ 條件 shouldSendEnterGame && !getClickPlayGame → true
|
|
107
|
+
⑥ walletType = query.walletType → 取決於 URL 是否帶此參數
|
|
108
|
+
⑦ 送出 ENTER_GAME,data 中的 walletType 可能是 undefined
|
|
109
|
+
⑧ setWalletType action: context.walletType = undefined
|
|
110
|
+
⑨ connectGame: selected_wallet_type = undefined → 後端收到 null
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**關鍵點:** 這條路徑**完全繞過 ModalSelectWallet**,walletType 完全依賴 URL query。
|
|
114
|
+
|
|
115
|
+
**URL 是否帶 walletType 取決於 gameNavigationHandler.js:41:**
|
|
116
|
+
|
|
117
|
+
```javascript
|
|
118
|
+
if (walletType) params.walletType = walletType // falsy 就不帶
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
只要有任何一次 context.walletType 是 null/undefined,生成的 URL 就不帶 walletType,之後所有從該 URL 衍生的操作(刷新、書籤、分享)都會繼續是 null,形成**惡性循環**。
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
### 根因 2(高概率):waitForDispatchableState 超時
|
|
126
|
+
|
|
127
|
+
**觸發條件:** gameService 停留在非 dispatchable 狀態超過 5 秒。
|
|
128
|
+
|
|
129
|
+
**哪些狀態不是 dispatchable(SelectWallet.vue:97-113):**
|
|
130
|
+
|
|
131
|
+
```javascript
|
|
132
|
+
isDispatchableState(eventType) {
|
|
133
|
+
// 只允許 flow.idle、flow.playing、flow.playingDemo(僅 ENTER_GAME)
|
|
134
|
+
if (state.matches('flow.idle') || state.matches('flow.playing')) return true
|
|
135
|
+
if (eventType === 'ENTER_GAME' && state.matches('flow.playingDemo')) return true
|
|
136
|
+
return false
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
以下狀態都**不是** dispatchable:
|
|
141
|
+
|
|
142
|
+
- `flow.connecting` — 前一款遊戲的 connectGame API 回應慢
|
|
143
|
+
- `flow.connectSwitching` — 正在切換遊戲,disconnectGame API 慢
|
|
144
|
+
- `flow.refreshing` — 正在刷新遊戲
|
|
145
|
+
- `flow.disconnect` — 正在登出遊戲
|
|
146
|
+
|
|
147
|
+
**超時後果:**
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
① confirm() → setClickPlayGame(true) → waitForDispatchableState (polling...)
|
|
151
|
+
② 5 秒超時 → setClickPlayGame(false) → return(不送 event)
|
|
152
|
+
③ 但此時前一次的 connecting 可能最終成功
|
|
153
|
+
④ gameNavigationHandler 導航到 /play?...(不帶 walletType,因為那次的 context 可能沒有)
|
|
154
|
+
⑤ play.vue 載入 → shouldSendEnterGame: true, getClickPlayGame: false
|
|
155
|
+
⑥ 直接送 ENTER_GAME,walletType 從 URL 取 → null
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**什麼情況下 API 會慢超過 5 秒:**
|
|
159
|
+
|
|
160
|
+
- 後端 game-provider-connector 服務壓力大
|
|
161
|
+
- 用戶網路品質差(行動網路、跨國連線)
|
|
162
|
+
- 後端與遊戲供應商之間的通訊延遲
|
|
163
|
+
- 裝置效能差導致 JS 執行延遲(polling 間隔不準確)
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### 根因 3(中概率):confirmCancelled 競態
|
|
168
|
+
|
|
169
|
+
**觸發條件:** 用戶點了 confirm 按鈕後,在 waitForDispatchableState 返回前點了 X 關閉 modal。
|
|
170
|
+
|
|
171
|
+
**時序:**
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
T0: [confirm] → isConfirming=true, setClickPlayGame(true)
|
|
175
|
+
T1: → waitForDispatchableState 開始 polling
|
|
176
|
+
T2: [X 按鈕] → close() → isConfirming=true → confirmCancelled=true, setClickPlayGame(false)
|
|
177
|
+
T3: → waitForDispatchableState loop 檢測到 confirmCancelled → return { cancelled: true }
|
|
178
|
+
T4: [confirm] → if (cancelled) return ← gameService 沒收到 event
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
此時 clickPlayGame 被設回 false,walletType 未被設定。
|
|
182
|
+
|
|
183
|
+
**額外的微妙競態窗口:**
|
|
184
|
+
|
|
185
|
+
在 `waitForDispatchableState` 返回和 `confirm()` 中第二次 `this.confirmCancelled` 檢查之間:
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
T0: waitForDispatchableState 返回 { cancelled: false }(已通過 while 檢查)
|
|
189
|
+
T1: [X 按鈕] → close() → confirmCancelled = true, setClickPlayGame(false)
|
|
190
|
+
T2: confirm() 繼續 → if (this.confirmCancelled) → true → return(不送 event)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
雖然 JS 是單線程,但 `await` 讓出執行權後,Vue 的事件處理可能在微任務間隙執行 close()。
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
### 根因 4(低概率):gameNavigationHandler URL 建構缺陷
|
|
198
|
+
|
|
199
|
+
**問題:** gameNavigationHandler.js:41 使用條件判斷:
|
|
200
|
+
|
|
201
|
+
```javascript
|
|
202
|
+
if (walletType) params.walletType = walletType
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
這意味著只要 `walletType` 是以下任一值,URL 就不帶 walletType:
|
|
206
|
+
|
|
207
|
+
- `null`(初始值)
|
|
208
|
+
- `undefined`(setWalletType 設定 undefined)
|
|
209
|
+
- `''`(空字串)
|
|
210
|
+
- `0`(數字零,理論上不會出現)
|
|
211
|
+
|
|
212
|
+
**後果:** 一旦產生不帶 walletType 的 URL,該 URL 會存在於:
|
|
213
|
+
|
|
214
|
+
- 瀏覽器歷史記錄(history.pushState)
|
|
215
|
+
- 瀏覽器位址列(用戶可能書籤)
|
|
216
|
+
- 可能被分享給其他人
|
|
217
|
+
|
|
218
|
+
形成惡性循環,後續每次從此 URL 進入都是 null。
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## 各種特殊情況補充分析
|
|
223
|
+
|
|
224
|
+
### API 回應慢
|
|
225
|
+
|
|
226
|
+
| 情境 | 影響 | 說明 |
|
|
227
|
+
| --------------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
228
|
+
| getSiteConfig API 慢 | 不影響 | `selectWalletEnable` 是 config,載入時機早於用戶操作 |
|
|
229
|
+
| getUserInfo API 慢 | 間接影響 | SelectWallet.mounted 中 `setDefaultChecked()` 依賴 getUserInfo,若還沒載入完成,`withdraw_rule` 是 undefined,defaultChecked 設為 false → 預設選活動錢包(不是 null,但可能選錯) |
|
|
230
|
+
| connectGame API 慢 | **直接影響** | 見根因 2,導致 waitForDispatchableState 超時 |
|
|
231
|
+
| disconnectGame API 慢 | **直接影響** | 同上,connectSwitching 狀態卡住 |
|
|
232
|
+
|
|
233
|
+
### 裝置卡頓
|
|
234
|
+
|
|
235
|
+
| 情境 | 影響 | 說明 |
|
|
236
|
+
| ----------------------- | ------------ | ------------------------------------------------------------------------------------------------- |
|
|
237
|
+
| JS 主線程長時間阻塞 | **間接影響** | waitForDispatchableState 的 polling(每 100ms)可能被延遲,5 秒超時計算不準確,可能更早或更晚超時 |
|
|
238
|
+
| 記憶體不足導致頁面重載 | **直接影響** | 等同頁面刷新場景(根因 1) |
|
|
239
|
+
| Service Worker 快取問題 | 可能影響 | PWA 離線快取可能提供過期的頁面,URL query 可能不完整 |
|
|
240
|
+
|
|
241
|
+
### 網頁操作卡頓
|
|
242
|
+
|
|
243
|
+
| 情境 | 影響 | 說明 |
|
|
244
|
+
| ----------------------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
245
|
+
| 用戶快速連續點擊多款遊戲 | **可能影響** | 第一次 confirm 送出 ENTER_GAME,gameService 進入 connecting;用戶不等結果又點另一款,modal 再次彈出,但 waitForDispatchableState 可能超時(因為還在 connecting) |
|
|
246
|
+
| 用戶點 confirm 後立刻按返回鍵 | **直接影響** | 觸發 confirmCancelled 競態(根因 3) |
|
|
247
|
+
| Modal 動畫期間用戶操作 | 低影響 | Vue transition 不影響數據流 |
|
|
248
|
+
|
|
249
|
+
### 時序問題
|
|
250
|
+
|
|
251
|
+
| 情境 | 影響 | 說明 |
|
|
252
|
+
| -------------------------------------------------------- | ------------ | ------------------------------------------------------------------------------------- |
|
|
253
|
+
| gameNavigationHandler onTransition 早於 connectGame 完成 | 正常 | handler 在 connecting 狀態觸發導航,connectGame 是 invoke service,兩者是獨立流程 |
|
|
254
|
+
| play.vue beforeMount 早於 gameService ready | **可能影響** | 頁面刷新時,gameService 可能還在初始化,state 不是 flow.idle,但 beforeMount 已經執行 |
|
|
255
|
+
| beforeRouteUpdate 和 gameServiceHandler 競態 | 低影響 | beforeRouteUpdate 設定 shouldSendEnterGame: false,不會重送 event |
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## selectWalletEnable 兩種模式差異
|
|
260
|
+
|
|
261
|
+
修復必須同時考慮兩種品牌配置:
|
|
262
|
+
|
|
263
|
+
| | `selectWalletEnable = true`(如 BTK) | `selectWalletEnable = false` |
|
|
264
|
+
| -------------------------- | ----------------------------------------------- | ---------------------------------- |
|
|
265
|
+
| walletType | **必須** 有值(CASH / ACTIVITY) | **允許** 為 null |
|
|
266
|
+
| 進入遊戲流程 | 彈 ModalSelectWallet → 用戶選擇 | 直接送 ENTER_GAME,不帶 walletType |
|
|
267
|
+
| URL 預期 | 應帶 `walletType=CASH` 或 `walletType=ACTIVITY` | **不帶** `walletType`(正常行為) |
|
|
268
|
+
| API `selected_wallet_type` | 不該是 null | 可以是 null |
|
|
269
|
+
|
|
270
|
+
**關鍵原則:** 只有 `selectWalletEnable = true` 的品牌在 `walletType` 為空時才需要介入修復;`selectWalletEnable = false` 的品牌維持原行為不變。
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## 調整方式
|
|
275
|
+
|
|
276
|
+
### 調整 1:play.vue — 僅 selectWalletEnable=true 且缺少 walletType 時走 enterGame 流程(核心修復)
|
|
277
|
+
|
|
278
|
+
**檔案:** `pages/play.vue`
|
|
279
|
+
**位置:** `handlePlayRouteQuery` 方法,行 471-476
|
|
280
|
+
|
|
281
|
+
**現行邏輯:**
|
|
282
|
+
|
|
283
|
+
```javascript
|
|
284
|
+
// pages/play.vue:471-476
|
|
285
|
+
if (shouldSendEnterGame && !this.getClickPlayGame) {
|
|
286
|
+
this.$gameService.send({
|
|
287
|
+
type: 'ENTER_GAME',
|
|
288
|
+
data: { game: { gameCode, providerId, gameId, gameTypeId, mappingId }, locale: this.$i18n.locale, walletType },
|
|
289
|
+
})
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**問題:** 直接送 gameService event,繞過 store.enterGame 的 modal 判斷邏輯。當 `selectWalletEnable = true` 的品牌頁面刷新 / 深層連結時,URL 可能不帶 walletType,導致送出 `walletType: undefined`。
|
|
294
|
+
|
|
295
|
+
**調整為:**
|
|
296
|
+
|
|
297
|
+
```javascript
|
|
298
|
+
// pages/play.vue:471-476
|
|
299
|
+
if (shouldSendEnterGame && !this.getClickPlayGame) {
|
|
300
|
+
const selectWalletEnable = this.getSiteConfig?.selectWalletEnable
|
|
301
|
+
if (selectWalletEnable && !walletType) {
|
|
302
|
+
// selectWalletEnable=true 但 URL 缺少 walletType(刷新/深層連結/書籤)
|
|
303
|
+
// → 走 store.enterGame 流程,會彈出 ModalSelectWallet 讓用戶重新選擇
|
|
304
|
+
this.enterGame({
|
|
305
|
+
game: { gameCode, providerId, gameId, gameTypeId, mappingId },
|
|
306
|
+
locale: this.$i18n.locale,
|
|
307
|
+
})
|
|
308
|
+
} else {
|
|
309
|
+
// 1. selectWalletEnable=false → walletType 允許為 null,直接送 event(維持原行為)
|
|
310
|
+
// 2. URL 已帶 walletType → 正常刷新場景,直接送 event
|
|
311
|
+
this.$gameService.send({
|
|
312
|
+
type: 'ENTER_GAME',
|
|
313
|
+
data: { game: { gameCode, providerId, gameId, gameTypeId, mappingId }, locale: this.$i18n.locale, walletType },
|
|
314
|
+
})
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
**需要補上 mapActions:**
|
|
320
|
+
|
|
321
|
+
```javascript
|
|
322
|
+
// play.vue methods 區塊
|
|
323
|
+
...mapActions({
|
|
324
|
+
enterGame: 'enterGame'
|
|
325
|
+
}),
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
play.vue 的 computed 已有 `getSiteConfig: 'getSiteConfig'`(行 160),可直接使用。
|
|
329
|
+
|
|
330
|
+
**不會無限循環:** enterGame 走 modal 流程後,confirm 送 ENTER_GAME → gameNavigationHandler 導航到 `/play?...walletType=CASH`(帶 walletType)。beforeRouteUpdate 中 `shouldSendEnterGame: false`,不會重送 event。
|
|
331
|
+
|
|
332
|
+
**selectWalletEnable=false 不受影響:** 這類品牌的 URL 本來就不帶 walletType,走 else 分支直接送 ENTER_GAME,與修改前行為完全一致。
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
### 調整 2:gameNavigationHandler — 僅 selectWalletEnable=true 時防禦性補 walletType
|
|
337
|
+
|
|
338
|
+
**檔案:** `utils/gameNavigationHandler.js`
|
|
339
|
+
**位置:** 行 37-41
|
|
340
|
+
|
|
341
|
+
**現行邏輯:**
|
|
342
|
+
|
|
343
|
+
```javascript
|
|
344
|
+
// utils/gameNavigationHandler.js:37-41
|
|
345
|
+
const { walletType } = state.context
|
|
346
|
+
const { gameCode, providerId, gameId, gameTypeId, mappingId } = game
|
|
347
|
+
const params = { gameCode, providerId, gameId, gameTypeId, mappingId }
|
|
348
|
+
if (walletType) params.walletType = walletType
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**問題:** 當 `selectWalletEnable = true` 的品牌因為各種原因(根因 2、3)導致 walletType 為空時,生成的 URL 不帶 walletType,形成惡性循環。
|
|
352
|
+
|
|
353
|
+
**~~原方案~~(有誤):** 無條件加 `else params.walletType = 'CASH'`。這對 `selectWalletEnable = false` 的品牌是**錯誤的** — 會把本該為 null 的 walletType 強制設為 CASH 送給後端。
|
|
354
|
+
|
|
355
|
+
**調整為:**
|
|
356
|
+
|
|
357
|
+
```javascript
|
|
358
|
+
// utils/gameNavigationHandler.js:37-41
|
|
359
|
+
const { walletType } = state.context
|
|
360
|
+
const { gameCode, providerId, gameId, gameTypeId, mappingId } = game
|
|
361
|
+
const params = { gameCode, providerId, gameId, gameTypeId, mappingId }
|
|
362
|
+
if (walletType) {
|
|
363
|
+
params.walletType = walletType
|
|
364
|
+
} else if (store.getters.getSiteConfig?.selectWalletEnable) {
|
|
365
|
+
// selectWalletEnable=true 但 walletType 為空 → 不該發生的異常情況
|
|
366
|
+
// 補 CASH 作為防禦性預設值,防止生成有缺陷的 URL 引發惡性循環
|
|
367
|
+
params.walletType = 'CASH'
|
|
368
|
+
console.warn('[GameNavigationHandler] walletType missing for selectWalletEnable brand, defaulting to CASH')
|
|
369
|
+
}
|
|
370
|
+
// selectWalletEnable=false 時不加 walletType → 維持原行為
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
**此方案的優點:**
|
|
374
|
+
|
|
375
|
+
- handler 已有 `store` 引用(建構時傳入),可直接讀取 getSiteConfig
|
|
376
|
+
- `selectWalletEnable = false` 的品牌不會被影響,URL 維持不帶 walletType
|
|
377
|
+
- `selectWalletEnable = true` 的品牌即使出現異常,也不會產生有缺陷的 URL
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
### 調整 3:SelectWallet — waitForDispatchableState 超時後的處理
|
|
382
|
+
|
|
383
|
+
**檔案:** `components/modal/SelectWallet.vue`
|
|
384
|
+
**位置:** `confirm` 方法,行 158-166
|
|
385
|
+
|
|
386
|
+
> ModalSelectWallet 只在 `selectWalletEnable = true` 時才會彈出,不需要考慮 `selectWalletEnable = false` 的情況。
|
|
387
|
+
|
|
388
|
+
**現行邏輯:**
|
|
389
|
+
|
|
390
|
+
```javascript
|
|
391
|
+
// SelectWallet.vue:158-166
|
|
392
|
+
if (timedOut) {
|
|
393
|
+
console.warn('[SelectWallet] Timeout waiting for dispatchable state', {
|
|
394
|
+
waitedMs,
|
|
395
|
+
eventType,
|
|
396
|
+
state: this.getFlowStateLabel(),
|
|
397
|
+
})
|
|
398
|
+
this.setClickPlayGame(false)
|
|
399
|
+
return
|
|
400
|
+
}
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
**問題:** 超時後直接放棄,用戶沒有任何回饋,且 clickPlayGame 設為 false 可能導致 play.vue 的 beforeMount 重送無 walletType 的 event。
|
|
404
|
+
|
|
405
|
+
**調整方案 A(推薦)— 超時後仍然送出 event:**
|
|
406
|
+
|
|
407
|
+
```javascript
|
|
408
|
+
if (timedOut) {
|
|
409
|
+
console.warn('[SelectWallet] Timeout waiting for dispatchable state', {
|
|
410
|
+
waitedMs,
|
|
411
|
+
eventType,
|
|
412
|
+
state: this.getFlowStateLabel(),
|
|
413
|
+
})
|
|
414
|
+
// 超時但不放棄:仍然嘗試送出 event
|
|
415
|
+
// gameService 在非 dispatchable 狀態會忽略不認識的 event,不會出錯
|
|
416
|
+
// 如果剛好變成 dispatchable 狀態,event 就能被處理
|
|
417
|
+
}
|
|
418
|
+
// 移除 return,讓流程繼續往下走到 $gameService.send
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
**調整方案 B — 超時後顯示提示,讓用戶重試:**
|
|
422
|
+
|
|
423
|
+
```javascript
|
|
424
|
+
if (timedOut) {
|
|
425
|
+
console.warn('[SelectWallet] Timeout waiting for dispatchable state', ...)
|
|
426
|
+
this.isConfirming = false
|
|
427
|
+
// 不設 setClickPlayGame(false),不關 modal
|
|
428
|
+
// 讓用戶可以再次點 confirm
|
|
429
|
+
this.$toast.error({ message: this.$t('error.game_connecting_timeout') })
|
|
430
|
+
return
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
**選擇建議:** 方案 A 較簡單且安全,XState 對不認識的 event 會靜默忽略(不會報錯)。如果 gameService 剛好在超時瞬間變成 idle,event 就能正常處理。
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
### 調整 4:game_v2_1.js (cuora) — setWalletType 防禦
|
|
439
|
+
|
|
440
|
+
**檔案:** `node_modules/@jetthai/cuora/src/machine/game_v2_1.js`
|
|
441
|
+
**位置:** 行 468-470
|
|
442
|
+
|
|
443
|
+
**現行邏輯:**
|
|
444
|
+
|
|
445
|
+
```javascript
|
|
446
|
+
// game_v2_1.js:468-470
|
|
447
|
+
setWalletType: assign((context, event) => {
|
|
448
|
+
return { walletType: event.data.walletType }
|
|
449
|
+
})
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
**問題:** `event.data.walletType` 為 undefined 時,context.walletType 被設為 undefined(覆蓋掉之前的值)。
|
|
453
|
+
|
|
454
|
+
**~~原方案~~(可改進):** 使用 `||` 運算子。語意不夠精準,`''`(空字串)也會被忽略。
|
|
455
|
+
|
|
456
|
+
**調整為(使用 `??` nullish coalescing):**
|
|
457
|
+
|
|
458
|
+
```javascript
|
|
459
|
+
setWalletType: assign((context, event) => {
|
|
460
|
+
return { walletType: event.data.walletType ?? context.walletType }
|
|
461
|
+
})
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
**效果:**
|
|
465
|
+
|
|
466
|
+
- `event.data.walletType` 為 `'CASH'` 或 `'ACTIVITY'` → 正常設定(兩種模式皆適用)
|
|
467
|
+
- `event.data.walletType` 為 `undefined` → 保留 context 原值,不被覆蓋
|
|
468
|
+
- `event.data.walletType` 為 `null` → 保留 context 原值(`selectWalletEnable = false` 的 context.walletType 本身是 null,`null ?? null` = null,結果正確)
|
|
469
|
+
|
|
470
|
+
**`??` vs `||` 的差異:** `??` 只在 `null` / `undefined` 時回退,`||` 在所有 falsy 值(包括 `''`, `0`, `false`)時都回退。此處 walletType 的合法值是字串,使用 `??` 語意更精準。
|
|
471
|
+
|
|
472
|
+
**注意:** 此檔案在 `@jetthai/cuora` 套件中,需要修改套件並發版。
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
### 調整 5:connectGame — API 呼叫前統一 undefined → null
|
|
477
|
+
|
|
478
|
+
**檔案:** `node_modules/@jetthai/cuora/src/machine/game_v2_1.js`
|
|
479
|
+
**位置:** 行 640-661
|
|
480
|
+
|
|
481
|
+
**現行邏輯:**
|
|
482
|
+
|
|
483
|
+
```javascript
|
|
484
|
+
// game_v2_1.js:647, 657
|
|
485
|
+
const { lang, isMobile, walletType } = context
|
|
486
|
+
const params = {
|
|
487
|
+
...
|
|
488
|
+
selected_wallet_type: walletType,
|
|
489
|
+
...
|
|
490
|
+
}
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
**調整為:**
|
|
494
|
+
|
|
495
|
+
```javascript
|
|
496
|
+
const { lang, isMobile, walletType } = context
|
|
497
|
+
const params = {
|
|
498
|
+
...
|
|
499
|
+
selected_wallet_type: walletType || null,
|
|
500
|
+
...
|
|
501
|
+
}
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
**效果:** 統一把 undefined 轉為 null,讓後端收到一致的值(而非有時 undefined 有時 null)。
|
|
505
|
+
|
|
506
|
+
**不加 console.warn:** connectGame 在 cuora 層無法取得 `selectWalletEnable`(在 store 中),對 `selectWalletEnable = false` 的品牌而言 `walletType` 為 null 是正常行為,加 warn 會產生大量誤報。
|
|
507
|
+
|
|
508
|
+
**注意:** 此檔案在 `@jetthai/cuora` 套件中,需要修改套件並發版。
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
## 修復優先級
|
|
513
|
+
|
|
514
|
+
| 優先級 | 調整 | 影響範圍 | 修改位置 |
|
|
515
|
+
| :----: | ---------------------------------------------------------------------------- | --------------------------------------------------------------------- | --------------- |
|
|
516
|
+
| P0 | 調整 1:play.vue 僅 selectWalletEnable=true 且缺 walletType 時走 enterGame | 修復頁面刷新/深層連結的根本問題,不影響 selectWalletEnable=false 品牌 | client-pwa-cash |
|
|
517
|
+
| P0 | 調整 2:gameNavigationHandler 僅 selectWalletEnable=true 時防禦補 walletType | 切斷惡性循環,不影響 selectWalletEnable=false 品牌 | client-pwa-cash |
|
|
518
|
+
| P1 | 調整 4:cuora setWalletType 用 `??` 防禦 | 防止 walletType 被意外覆蓋為 undefined,兩種模式皆安全 | @jetthai/cuora |
|
|
519
|
+
| P2 | 調整 3:SelectWallet 超時處理改進 | 改善超時場景的用戶體驗和數據正確性(僅 selectWalletEnable=true) | client-pwa-cash |
|
|
520
|
+
| P2 | 調整 5:cuora connectGame 統一 undefined → null | 統一後端收到的值,兩種模式皆安全 | @jetthai/cuora |
|
|
521
|
+
|
|
522
|
+
---
|
|
523
|
+
|
|
524
|
+
## 驗證方式
|
|
525
|
+
|
|
526
|
+
### 場景 1:頁面刷新(selectWalletEnable=true 品牌,如 BTK)
|
|
527
|
+
|
|
528
|
+
1. 正常進入遊戲(通過 modal 選擇錢包)
|
|
529
|
+
2. 在 play 頁面按 F5 刷新
|
|
530
|
+
3. 確認彈出 ModalSelectWallet 讓用戶重新選擇
|
|
531
|
+
4. 確認 API 請求的 `selected_wallet_type` 不是 null
|
|
532
|
+
|
|
533
|
+
### 場景 2:頁面刷新(selectWalletEnable=false 品牌)
|
|
534
|
+
|
|
535
|
+
1. 正常進入遊戲(不彈 modal)
|
|
536
|
+
2. 在 play 頁面按 F5 刷新
|
|
537
|
+
3. 確認**不彈** ModalSelectWallet
|
|
538
|
+
4. 確認 API 請求的 `selected_wallet_type` 為 null(正常行為)
|
|
539
|
+
5. 確認遊戲正常載入
|
|
540
|
+
|
|
541
|
+
### 場景 3:深層連結(不帶 walletType,selectWalletEnable=true)
|
|
542
|
+
|
|
543
|
+
1. 直接在瀏覽器輸入 `/play?gameCode=X&providerId=Y&gameId=Z&gameTypeId=1&mappingId=2`
|
|
544
|
+
2. 確認彈出 ModalSelectWallet 讓用戶選擇
|
|
545
|
+
3. 確認 API 請求的 `selected_wallet_type` 正確
|
|
546
|
+
|
|
547
|
+
### 場景 4:深層連結(不帶 walletType,selectWalletEnable=false)
|
|
548
|
+
|
|
549
|
+
1. 直接在瀏覽器輸入 `/play?gameCode=X&providerId=Y&gameId=Z&gameTypeId=1&mappingId=2`
|
|
550
|
+
2. 確認**不彈** ModalSelectWallet
|
|
551
|
+
3. 確認 API 請求的 `selected_wallet_type` 為 null(正常行為)
|
|
552
|
+
4. 確認遊戲正常載入
|
|
553
|
+
|
|
554
|
+
### 場景 5:連續切換遊戲(selectWalletEnable=true)
|
|
555
|
+
|
|
556
|
+
1. 進入遊戲 A
|
|
557
|
+
2. 在遊戲 A 載入過程中(connecting 狀態),點擊進入遊戲 B
|
|
558
|
+
3. 確認 ModalSelectWallet 能正常彈出或正確處理超時
|
|
559
|
+
4. 確認 API 請求的 `selected_wallet_type` 不是 null
|
|
560
|
+
|
|
561
|
+
### 場景 6:confirm 後關閉 modal
|
|
562
|
+
|
|
563
|
+
1. 在 ModalSelectWallet 點擊確認
|
|
564
|
+
2. 在遊戲載入前快速點 X 關閉 modal
|
|
565
|
+
3. 確認不會產生不帶 walletType 的 URL
|
package/package.json
CHANGED
package/src/machine/game_v2_1.js
CHANGED
|
@@ -465,8 +465,10 @@ export default function (request) {
|
|
|
465
465
|
const { providerId, gameId, gameTypeId, mappingId, portrait, gameCode, name, gameName } = context.switchGame
|
|
466
466
|
return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0, gameCode, name, gameName } }
|
|
467
467
|
}),
|
|
468
|
+
// 頁面刷新或深層連結時,event.data.walletType 可能為 undefined/null
|
|
469
|
+
// 使用 ?? 確保不會覆蓋 context 中已有的 walletType,避免後端收到 selectedWalletType=null
|
|
468
470
|
setWalletType: assign((context, event) => {
|
|
469
|
-
return { walletType: event.data.walletType }
|
|
471
|
+
return { walletType: event.data.walletType ?? context.walletType }
|
|
470
472
|
}),
|
|
471
473
|
setLang: assign((context, event) => {
|
|
472
474
|
const lang = event.data.locale.replace('-', '_')
|
|
@@ -638,9 +640,9 @@ export default function (request) {
|
|
|
638
640
|
}
|
|
639
641
|
},
|
|
640
642
|
connectGame: async (context, event) => {
|
|
641
|
-
// [防呆] 確保有 providerId 和 gameId
|
|
643
|
+
// [防呆] 確保有 providerId 和 gameId(含字串 "null"/"undefined" 檢查)
|
|
642
644
|
const { providerId, gameId } = context.game || {}
|
|
643
|
-
if (!providerId || !gameId) {
|
|
645
|
+
if (!providerId || !gameId || providerId === 'null' || providerId === 'undefined' || gameId === 'null' || gameId === 'undefined') {
|
|
644
646
|
return
|
|
645
647
|
}
|
|
646
648
|
const returnProviders = ['RSG', 'KP', 'EPICWIN', 'AMBSLOT', 'SEXY_VENUS', 'SEXY_SEXYBCRT', 'PG', 'NPG']
|
|
@@ -654,7 +656,7 @@ export default function (request) {
|
|
|
654
656
|
is_demo: false,
|
|
655
657
|
is_mobile: isMobile === 'mobile' ? 'y' : null,
|
|
656
658
|
lang,
|
|
657
|
-
selected_wallet_type: walletType,
|
|
659
|
+
selected_wallet_type: walletType || null, // 統一 undefined → null,確保後端收到一致的值
|
|
658
660
|
return_url: returnProviders.includes(providerId)
|
|
659
661
|
? `${window.location.origin}${context.base}return`
|
|
660
662
|
: window.location.href?.split('?')?.[0], // For providers to return.
|
|
File without changes
|