@jetthai/cuora 1.0.24 → 1.0.26
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 +4 -0
- package/api/activity.js +46 -0
- package/api/auth.js +15 -0
- package/api/common.js +4 -0
- package/api/game.js +32 -0
- package/api/index.js +9 -0
- package/api/mailbox.js +20 -0
- package/api/payment.js +63 -0
- package/api/user.js +19 -0
- package/index.js +3 -58
- package/machine/activity/activity.js +73 -0
- package/machine/activity/continue_deposit_activity.js +132 -0
- package/machine/activity/deposit_activity.js +86 -0
- package/machine/activity/diamond_shop_activity.js +163 -0
- package/machine/activity/fafafa_activity.js +131 -0
- package/machine/activity/index.js +21 -0
- package/machine/activity/invite_friends_activity.js +121 -0
- package/machine/activity/ranking_activity.js +76 -0
- package/machine/activity/return_bonus_activity.js +150 -0
- package/machine/activity/specify_bets_activity.js +116 -0
- package/machine/auth.js +245 -0
- package/machine/auth_otp.js +191 -0
- package/machine/check.js +113 -0
- package/machine/common.js +163 -0
- package/machine/deposit.js +236 -0
- package/machine/error.js +72 -0
- package/machine/game.js +265 -0
- package/machine/game_favorite.js +123 -0
- package/machine/game_search.js +248 -0
- package/machine/inbox.js +246 -0
- package/machine/index.js +37 -0
- package/machine/merge.js +57 -0
- package/machine/payment_data.js +81 -0
- package/machine/reward.js +73 -0
- package/machine/setting.js +37 -0
- package/machine/side.js +147 -0
- package/machine/withdraw.js +367 -0
- package/package.json +3 -2
- package/request/config.js +18 -0
- package/request/cookie.js +52 -0
- package/request/request.js +97 -0
- package/plugin/activity.js +0 -289
- package/plugin/core.js +0 -518
- package/plugin/game.js +0 -474
- package/plugin/inbox.js +0 -216
- package/plugin/information.js +0 -57
- package/plugin/job/network.js +0 -61
- package/plugin/payment.js +0 -257
- package/plugin/request.js +0 -225
- package/plugin/search.js +0 -277
- package/plugin/user.js +0 -198
package/machine/game.js
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import api from '../api/game'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'game',
|
|
8
|
+
type: 'parallel',
|
|
9
|
+
context: {
|
|
10
|
+
roomId: null,
|
|
11
|
+
list: [],
|
|
12
|
+
game: {
|
|
13
|
+
provider: null,
|
|
14
|
+
game_id: null,
|
|
15
|
+
game_type: null,
|
|
16
|
+
mapping_id: null,
|
|
17
|
+
},
|
|
18
|
+
lang: 'en_US',
|
|
19
|
+
gameURL: null,
|
|
20
|
+
tick: 2000,
|
|
21
|
+
isMobile: false,
|
|
22
|
+
// game database
|
|
23
|
+
sha: {
|
|
24
|
+
category: null,
|
|
25
|
+
status: null,
|
|
26
|
+
},
|
|
27
|
+
isCategoryChanged: false,
|
|
28
|
+
isStatusChanged: false,
|
|
29
|
+
statusMap: {},
|
|
30
|
+
optionMap: {},
|
|
31
|
+
},
|
|
32
|
+
states: {
|
|
33
|
+
flow: {
|
|
34
|
+
initial: 'idle',
|
|
35
|
+
states: {
|
|
36
|
+
idle: {
|
|
37
|
+
enter: 'clearGameInfo',
|
|
38
|
+
on: {
|
|
39
|
+
ENTER_ROOM: {
|
|
40
|
+
target: 'loading',
|
|
41
|
+
actions: 'setRoomId',
|
|
42
|
+
cond: (context, event) => {
|
|
43
|
+
return context.roomId !== event.roomId
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
ENTER_GAME: {
|
|
47
|
+
target: 'connecting',
|
|
48
|
+
actions: ['setGameInfo', 'setLang'],
|
|
49
|
+
cond: (context, event) => {
|
|
50
|
+
return context.list.length > 0
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
loading: {
|
|
56
|
+
invoke: {
|
|
57
|
+
src: 'getRoomItems',
|
|
58
|
+
onDone: {
|
|
59
|
+
target: 'idle',
|
|
60
|
+
actions: 'setList',
|
|
61
|
+
},
|
|
62
|
+
onError: {
|
|
63
|
+
target: 'idle',
|
|
64
|
+
actions: assign({ list: [] }),
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
connecting: {
|
|
69
|
+
invoke: {
|
|
70
|
+
src: 'connectGame',
|
|
71
|
+
onDone: {
|
|
72
|
+
target: 'playing',
|
|
73
|
+
actions: 'setGameURL',
|
|
74
|
+
},
|
|
75
|
+
onError: {
|
|
76
|
+
target: 'idle',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
playing: {
|
|
81
|
+
on: {
|
|
82
|
+
EXIT_GAME: {
|
|
83
|
+
target: 'disconnect',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
disconnect: {
|
|
88
|
+
invoke: {
|
|
89
|
+
src: 'disconnectGame',
|
|
90
|
+
onDone: {
|
|
91
|
+
target: 'idle',
|
|
92
|
+
},
|
|
93
|
+
onError: {
|
|
94
|
+
target: 'idle',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
schedule: {
|
|
101
|
+
initial: 'fetchingGameSHA',
|
|
102
|
+
states: {
|
|
103
|
+
fetchingGameSHA: {
|
|
104
|
+
invoke: {
|
|
105
|
+
src: 'fetchGameSHA',
|
|
106
|
+
onDone: {
|
|
107
|
+
target: 'checking',
|
|
108
|
+
actions: 'setGameSHA',
|
|
109
|
+
},
|
|
110
|
+
onError: {},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
checking: {
|
|
114
|
+
always: [
|
|
115
|
+
{ target: 'updatingStatus', cond: 'isStatusChanged' },
|
|
116
|
+
{ target: 'updatingCategory', cond: 'isCategoryChanged' },
|
|
117
|
+
{ target: 'idle' },
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
updatingStatus: {
|
|
121
|
+
invoke: {
|
|
122
|
+
src: 'fetchStatus',
|
|
123
|
+
onDone: {
|
|
124
|
+
target: 'updatingOption',
|
|
125
|
+
actions: ['setStatus'],
|
|
126
|
+
},
|
|
127
|
+
onError: {},
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
updatingOption: {
|
|
131
|
+
invoke: {
|
|
132
|
+
src: 'fetchOption',
|
|
133
|
+
onDone: {
|
|
134
|
+
target: 'updatingCategory',
|
|
135
|
+
actions: 'mergeOption',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
updatingCategory: {
|
|
140
|
+
invoke: {
|
|
141
|
+
src: 'getRoomItems',
|
|
142
|
+
onDone: {
|
|
143
|
+
target: 'idle',
|
|
144
|
+
actions: 'setList',
|
|
145
|
+
},
|
|
146
|
+
onError: {
|
|
147
|
+
target: 'idle',
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
idle: {
|
|
152
|
+
after: {
|
|
153
|
+
TIMEOUT: {
|
|
154
|
+
target: 'fetchingGameSHA',
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
on: {
|
|
162
|
+
SET_MOBILE: {
|
|
163
|
+
actions: 'setMobile',
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
actions: {
|
|
169
|
+
setRoomId: assign((context, event) => {
|
|
170
|
+
return { roomId: event.roomId }
|
|
171
|
+
}),
|
|
172
|
+
setList: assign({
|
|
173
|
+
list: (context, event) => {
|
|
174
|
+
return event.data.list
|
|
175
|
+
},
|
|
176
|
+
}),
|
|
177
|
+
setGameURL: assign({
|
|
178
|
+
gameURL: (context, event) => {
|
|
179
|
+
return event.data.gameURL
|
|
180
|
+
},
|
|
181
|
+
}),
|
|
182
|
+
clearGameInfo: assign((context, event) => {
|
|
183
|
+
return { game: { provider: null, game_id: null, game_type: null, mapping_id: null } }
|
|
184
|
+
}),
|
|
185
|
+
setGameInfo: assign((context, event) => {
|
|
186
|
+
const { provider, game_id, game_type, mapping_id } = event.data.game
|
|
187
|
+
return { game: { provider, game_id, game_type, mapping_id } }
|
|
188
|
+
}),
|
|
189
|
+
setLang: assign((context, event) => {
|
|
190
|
+
const lang = event.data.locale.replace('-', '_')
|
|
191
|
+
return { lang }
|
|
192
|
+
}),
|
|
193
|
+
setMobile: assign((context, event) => {
|
|
194
|
+
return {
|
|
195
|
+
isMobile: event.data,
|
|
196
|
+
}
|
|
197
|
+
}),
|
|
198
|
+
setGameSHA: assign((context, event) => {
|
|
199
|
+
const { sha } = context
|
|
200
|
+
const newSha = event.data
|
|
201
|
+
return {
|
|
202
|
+
sha: newSha,
|
|
203
|
+
isCategoryChanged: newSha.category !== (sha.category || '0'),
|
|
204
|
+
isStatusChanged: newSha.status !== (sha.status || '0'),
|
|
205
|
+
}
|
|
206
|
+
}),
|
|
207
|
+
setStatus: assign((context, event) => {
|
|
208
|
+
return {
|
|
209
|
+
statusMap: event.data,
|
|
210
|
+
}
|
|
211
|
+
}),
|
|
212
|
+
mergeOption: assign((context, event) => {
|
|
213
|
+
const { optionMap } = context
|
|
214
|
+
return {
|
|
215
|
+
optionMap: { ...optionMap, ...event.data },
|
|
216
|
+
}
|
|
217
|
+
}),
|
|
218
|
+
},
|
|
219
|
+
guards: {
|
|
220
|
+
isCategoryChanged: (context, event) => context.isCategoryChanged,
|
|
221
|
+
isStatusChanged: (context, event) => context.isStatusChanged,
|
|
222
|
+
},
|
|
223
|
+
delays: {
|
|
224
|
+
TIMEOUT: (context, event) => {
|
|
225
|
+
return context.tick * 10
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
services: {
|
|
229
|
+
getRoomItems: async (context, event) => {
|
|
230
|
+
return await request.send(api.getGameCategory({ id: context.roomId }))
|
|
231
|
+
},
|
|
232
|
+
connectGame: async (context, event) => {
|
|
233
|
+
const { lang, isMobile } = context
|
|
234
|
+
const { provider, game_id, game_type, mapping_id } = context.game
|
|
235
|
+
const params = {
|
|
236
|
+
provider_id: provider,
|
|
237
|
+
game_id: game_id,
|
|
238
|
+
gametype_id: game_type,
|
|
239
|
+
mapping_id: mapping_id,
|
|
240
|
+
is_demo: false,
|
|
241
|
+
is_mobile: isMobile,
|
|
242
|
+
lang,
|
|
243
|
+
return_url: window.location.href,
|
|
244
|
+
}
|
|
245
|
+
const { redirect_url } = await request.send(api.playGame(params))
|
|
246
|
+
return { gameURL: redirect_url }
|
|
247
|
+
},
|
|
248
|
+
disconnectGame: async (context, event) => {
|
|
249
|
+
const uid_site = event.data
|
|
250
|
+
return await request.send(api.logoutGame({ uid_site, provider_id: context.game.provider }))
|
|
251
|
+
},
|
|
252
|
+
fetchOption: async (context, event) => {
|
|
253
|
+
const { optionIds } = context
|
|
254
|
+
return await request.send(api.getOptionMap())
|
|
255
|
+
},
|
|
256
|
+
fetchGameSHA: async (context, event) => {
|
|
257
|
+
return await request.send(api.getGameSHA())
|
|
258
|
+
},
|
|
259
|
+
fetchStatus: async (context, event) => {
|
|
260
|
+
return await request.send(api.getGameStatus())
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
}
|
|
264
|
+
)
|
|
265
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { createMachine, assign } from 'xstate'
|
|
2
|
+
import api from '../api/game'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'favorite',
|
|
8
|
+
type: 'parallel',
|
|
9
|
+
context: {
|
|
10
|
+
list: [],
|
|
11
|
+
},
|
|
12
|
+
states: {
|
|
13
|
+
fetching: {
|
|
14
|
+
initial: 'disable',
|
|
15
|
+
states: {
|
|
16
|
+
disable: {},
|
|
17
|
+
enable: {
|
|
18
|
+
invoke: {
|
|
19
|
+
src: 'fetchList',
|
|
20
|
+
onDone: {
|
|
21
|
+
actions: 'setList',
|
|
22
|
+
},
|
|
23
|
+
onError: {
|
|
24
|
+
actions: assign({ list: [] }),
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
adding: {
|
|
31
|
+
initial: 'disable',
|
|
32
|
+
states: {
|
|
33
|
+
disable: {},
|
|
34
|
+
enable: {
|
|
35
|
+
invoke: {
|
|
36
|
+
src: 'add',
|
|
37
|
+
onDone: {},
|
|
38
|
+
onError: {
|
|
39
|
+
actions: 'removeFromList',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
removing: {
|
|
46
|
+
initial: 'disable',
|
|
47
|
+
states: {
|
|
48
|
+
disable: {},
|
|
49
|
+
enable: {
|
|
50
|
+
invoke: {
|
|
51
|
+
src: 'remove',
|
|
52
|
+
onDone: {},
|
|
53
|
+
onError: {
|
|
54
|
+
actions: 'addToList',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
on: {
|
|
62
|
+
FETCH_LIST: {
|
|
63
|
+
target: 'fetching.enable',
|
|
64
|
+
},
|
|
65
|
+
ADD: {
|
|
66
|
+
target: 'adding.enable',
|
|
67
|
+
actions: 'addToList',
|
|
68
|
+
cond: 'isNotExist',
|
|
69
|
+
},
|
|
70
|
+
REMOVE: {
|
|
71
|
+
target: 'removing.enable',
|
|
72
|
+
actions: 'removeFromList',
|
|
73
|
+
cond: 'isExist',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
actions: {
|
|
79
|
+
setList: assign((context, event) => {
|
|
80
|
+
return {
|
|
81
|
+
list: event.data,
|
|
82
|
+
}
|
|
83
|
+
}),
|
|
84
|
+
addToList: assign((context, event) => {
|
|
85
|
+
return {
|
|
86
|
+
list: [...context.list, event.data],
|
|
87
|
+
}
|
|
88
|
+
}),
|
|
89
|
+
removeFromList: assign((context, event) => {
|
|
90
|
+
return {
|
|
91
|
+
list: context.list.filter((item) => item !== event.data),
|
|
92
|
+
}
|
|
93
|
+
}),
|
|
94
|
+
},
|
|
95
|
+
guards: {
|
|
96
|
+
isExist: (context, event) => context.list.includes(event.data),
|
|
97
|
+
isNotExist: (context, event) => !context.list.includes(event.data),
|
|
98
|
+
},
|
|
99
|
+
services: {
|
|
100
|
+
add: async (context, event) => {
|
|
101
|
+
try {
|
|
102
|
+
return await request.send(api.addFavoriteGame(event.data))
|
|
103
|
+
} catch (error) {
|
|
104
|
+
throw event.data
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
remove: async (context, event) => {
|
|
108
|
+
try {
|
|
109
|
+
return await request.send(api.removeFavoriteGame(event.data))
|
|
110
|
+
} catch (error) {
|
|
111
|
+
throw event.data
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
fetchList: async (context, event) => {
|
|
115
|
+
const main = await request.send(api.getGameCategory({}))
|
|
116
|
+
const room = main.list.find((item) => item.category === 'SYSTEM_MY_FAVORITE')
|
|
117
|
+
const favorite = await request.send(api.getGameCategory({ id: room.id }))
|
|
118
|
+
return favorite.list.map((item) => item.g)
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { createMachine, assign, send } from 'xstate'
|
|
2
|
+
import game from '../api/game'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'game_search',
|
|
8
|
+
initial: 'preset',
|
|
9
|
+
context: {
|
|
10
|
+
keyword: '',
|
|
11
|
+
tagId: null,
|
|
12
|
+
mainTagList: [],
|
|
13
|
+
tagList: [],
|
|
14
|
+
gameList: [],
|
|
15
|
+
// 以下變數為數據分析用
|
|
16
|
+
tagIndex: null,
|
|
17
|
+
click: null,
|
|
18
|
+
clickDefault: null,
|
|
19
|
+
traceId: null,
|
|
20
|
+
gameCode: null,
|
|
21
|
+
},
|
|
22
|
+
states: {
|
|
23
|
+
preset: {
|
|
24
|
+
invoke: {
|
|
25
|
+
src: 'fetchTags',
|
|
26
|
+
onDone: {
|
|
27
|
+
target: 'loading',
|
|
28
|
+
actions: ['setMainTagList', 'setInitialTagId'],
|
|
29
|
+
},
|
|
30
|
+
onError: {
|
|
31
|
+
target: 'fail',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
loading: {
|
|
36
|
+
invoke: {
|
|
37
|
+
src: 'fetchGames',
|
|
38
|
+
onDone: {
|
|
39
|
+
target: 'idle',
|
|
40
|
+
actions: 'setGames',
|
|
41
|
+
},
|
|
42
|
+
onError: {
|
|
43
|
+
target: '#game_search.fail',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
idle: {
|
|
48
|
+
on: {
|
|
49
|
+
SET_MAIN_TAG_ID: {
|
|
50
|
+
target: 'loading',
|
|
51
|
+
actions: 'setMainTagId',
|
|
52
|
+
},
|
|
53
|
+
PLAY_GAME: {
|
|
54
|
+
target: 'sendingTrace',
|
|
55
|
+
actions: 'setGameCode',
|
|
56
|
+
},
|
|
57
|
+
START_SEARCH: {
|
|
58
|
+
target: 'searching',
|
|
59
|
+
actions: 'clearKeyword',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
searching: {
|
|
64
|
+
initial: 'debouncing',
|
|
65
|
+
states: {
|
|
66
|
+
debouncing: {
|
|
67
|
+
after: {
|
|
68
|
+
500: {
|
|
69
|
+
target: 'fetchingTagsByKeyword',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
fetchingTagsByKeyword: {
|
|
74
|
+
invoke: {
|
|
75
|
+
src: 'fetchTags',
|
|
76
|
+
onDone: {
|
|
77
|
+
actions: 'setTagList',
|
|
78
|
+
},
|
|
79
|
+
onError: {
|
|
80
|
+
target: '#game_search.fail',
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
on: {
|
|
86
|
+
SET_TAG_ID: {
|
|
87
|
+
target: 'loading',
|
|
88
|
+
actions: 'setTagId',
|
|
89
|
+
},
|
|
90
|
+
PRESS_ENTER: [
|
|
91
|
+
{
|
|
92
|
+
actions: send((context, event) => ({ type: 'SET_TAG_ID', data: context.tagList[0].id })),
|
|
93
|
+
cond: 'hasTagList',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
target: 'sendingTrace',
|
|
97
|
+
actions: 'clearExceptKeyword',
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
SET_KEYWORD: {
|
|
101
|
+
target: 'searching.debouncing',
|
|
102
|
+
actions: 'setKeyword',
|
|
103
|
+
},
|
|
104
|
+
STOP_SEARCH: {
|
|
105
|
+
target: 'loading',
|
|
106
|
+
actions: 'setInitialTagId',
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
sendingTrace: {
|
|
111
|
+
invoke: {
|
|
112
|
+
src: 'sendTrace',
|
|
113
|
+
onDone: {
|
|
114
|
+
target: 'idle',
|
|
115
|
+
},
|
|
116
|
+
onError: {
|
|
117
|
+
target: 'fail',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
fail: {},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
actions: {
|
|
126
|
+
setMainTagList: assign((context, event) => {
|
|
127
|
+
return {
|
|
128
|
+
mainTagList: event.data,
|
|
129
|
+
}
|
|
130
|
+
}),
|
|
131
|
+
setInitialTagId: assign((context, event) => {
|
|
132
|
+
const { mainTagList } = context
|
|
133
|
+
return {
|
|
134
|
+
tagId: mainTagList[0].id,
|
|
135
|
+
tagIndex: 0,
|
|
136
|
+
keyword: '',
|
|
137
|
+
}
|
|
138
|
+
}),
|
|
139
|
+
setMainTagId: assign((context, event) => {
|
|
140
|
+
const tagId = event.data
|
|
141
|
+
const { mainTagList } = context
|
|
142
|
+
const tagIndex = mainTagList.findIndex((tag) => tag.id === tagId)
|
|
143
|
+
return {
|
|
144
|
+
keyword: '',
|
|
145
|
+
tagId,
|
|
146
|
+
tagIndex,
|
|
147
|
+
click: null,
|
|
148
|
+
clickDefault: null,
|
|
149
|
+
}
|
|
150
|
+
}),
|
|
151
|
+
setTagId: assign((context, event) => {
|
|
152
|
+
const tagId = event.data
|
|
153
|
+
const { mainTagList, tagList } = context
|
|
154
|
+
if (tagList.length === 0) {
|
|
155
|
+
const tagIndex = mainTagList.findIndex((tag) => tag.id === tagId)
|
|
156
|
+
return {
|
|
157
|
+
tagId,
|
|
158
|
+
tagIndex,
|
|
159
|
+
click: null,
|
|
160
|
+
clickDefault: 1,
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
const tagIndex = tagList.findIndex((tag) => tag.id === tagId)
|
|
164
|
+
return {
|
|
165
|
+
tagId,
|
|
166
|
+
tagIndex,
|
|
167
|
+
click: 1,
|
|
168
|
+
clickDefault: null,
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}),
|
|
172
|
+
setGames: assign((context, event) => {
|
|
173
|
+
const { traceId, result } = event.data
|
|
174
|
+
return {
|
|
175
|
+
traceId: traceId,
|
|
176
|
+
gameList: result,
|
|
177
|
+
}
|
|
178
|
+
}),
|
|
179
|
+
setKeyword: assign((context, event) => {
|
|
180
|
+
return {
|
|
181
|
+
keyword: event.data,
|
|
182
|
+
}
|
|
183
|
+
}),
|
|
184
|
+
clearKeyword: assign((context, event) => {
|
|
185
|
+
return {
|
|
186
|
+
keyword: '',
|
|
187
|
+
}
|
|
188
|
+
}),
|
|
189
|
+
setTagList: assign((context, event) => {
|
|
190
|
+
return {
|
|
191
|
+
tagList: event.data,
|
|
192
|
+
}
|
|
193
|
+
}),
|
|
194
|
+
setGameCode: assign((context, event) => {
|
|
195
|
+
const { gameList } = context
|
|
196
|
+
const gameCode = event.data
|
|
197
|
+
const gameCodeIndex = gameList.findIndex((game) => game === gameCode)
|
|
198
|
+
return {
|
|
199
|
+
gameCode,
|
|
200
|
+
gameCodeIndex,
|
|
201
|
+
}
|
|
202
|
+
}),
|
|
203
|
+
clearExceptKeyword: assign((context, event) => {
|
|
204
|
+
return {
|
|
205
|
+
gameList: [],
|
|
206
|
+
//
|
|
207
|
+
traceId: null,
|
|
208
|
+
tagId: null,
|
|
209
|
+
tagIndex: null,
|
|
210
|
+
gameCode: null,
|
|
211
|
+
gameCodeIndex: null,
|
|
212
|
+
query: context.keyword,
|
|
213
|
+
click: null,
|
|
214
|
+
clickDefault: null,
|
|
215
|
+
}
|
|
216
|
+
}),
|
|
217
|
+
},
|
|
218
|
+
guards: {
|
|
219
|
+
hasMainTags: (context, event) => {
|
|
220
|
+
return context.mainTagList.length > 0
|
|
221
|
+
},
|
|
222
|
+
hasTagList: (context, event) => {
|
|
223
|
+
return context.tagList.length > 0
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
services: {
|
|
227
|
+
fetchTags: async (context, event) => {
|
|
228
|
+
const { keyword } = context
|
|
229
|
+
const { result } = await request.send(game.getGameTags({ q: keyword }))
|
|
230
|
+
return result
|
|
231
|
+
},
|
|
232
|
+
fetchGames: async (context, event) => {
|
|
233
|
+
const { tagId, tagIndex, keyword, click, clickDefault } = context
|
|
234
|
+
const { traceId, result } = await request.send(
|
|
235
|
+
game.getGameSearchList({ id: tagId, index: tagIndex, q: keyword, click, clickDefault })
|
|
236
|
+
)
|
|
237
|
+
return { traceId, result }
|
|
238
|
+
},
|
|
239
|
+
sendTrace: async (context, event) => {
|
|
240
|
+
const { traceId, tagId, tagIndex, gameCode, gameCodeIndex, keyword: query, click, clickDefault } = context
|
|
241
|
+
return await request.send(
|
|
242
|
+
game.setGameSearchTrace({ traceId, tagId, tagIndex, gameCode, gameCodeIndex, query, click, clickDefault })
|
|
243
|
+
)
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
}
|
|
247
|
+
)
|
|
248
|
+
}
|