@jetthai/cuora 1.0.193-1 → 1.0.193
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 +0 -2
- package/package.json +1 -1
- package/src/api/game.js +1 -5
- package/src/machine/index.js +0 -2
- package/src/machine/game_search_v2.js +0 -354
package/CHANGELOG.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
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.0.193-1](https://github.com/jetthai/cuora-module/compare/v1.0.193...v1.0.193-1) (2022-11-01)
|
|
6
|
-
|
|
7
5
|
### [1.0.193](https://github.com/jetthai/cuora-module/compare/v1.0.192...v1.0.193) (2022-10-26)
|
|
8
6
|
|
|
9
7
|
### [1.0.192](https://github.com/jetthai/cuora-module/compare/v1.0.191...v1.0.192) (2022-10-26)
|
package/package.json
CHANGED
package/src/api/game.js
CHANGED
|
@@ -10,13 +10,12 @@ export default {
|
|
|
10
10
|
logoutGame: ({ uid_site, provider_id }) => ({ url: 'game/logout', method: 'get', params: { uid_site, provider_id } }),
|
|
11
11
|
|
|
12
12
|
getGameTags: ({ q }) => ({ url: 'game/search', method: 'get', params: { q } }),
|
|
13
|
-
getGameSearchHome: () => ({ url: 'game/search/home', method: 'get' }),
|
|
14
13
|
getGameSearchList: ({ id, index, q, click, clickDefault }) => ({
|
|
15
14
|
url: 'game/search/list',
|
|
16
15
|
method: 'get',
|
|
17
16
|
params: { id, index, q, click, clickDefault },
|
|
18
17
|
}),
|
|
19
|
-
setGameSearchTrace: ({ traceId, tagId, tagIndex, gameCode, gameCodeIndex, query, click, clickDefault
|
|
18
|
+
setGameSearchTrace: ({ traceId, tagId, tagIndex, gameCode, gameCodeIndex, query, click, clickDefault }) => ({
|
|
20
19
|
url: 'game/search/trace',
|
|
21
20
|
method: 'post',
|
|
22
21
|
params: {
|
|
@@ -28,9 +27,6 @@ export default {
|
|
|
28
27
|
query,
|
|
29
28
|
click,
|
|
30
29
|
clickDefault,
|
|
31
|
-
isYouMayLike,
|
|
32
|
-
isRecentlyGame,
|
|
33
|
-
isRecentlySearch
|
|
34
30
|
},
|
|
35
31
|
}),
|
|
36
32
|
gameHistory: ({ requestTimestamp, lang, provider, type }) => ({
|
package/src/machine/index.js
CHANGED
|
@@ -9,7 +9,6 @@ import game_v2 from './game_v2.js'
|
|
|
9
9
|
import game_favorite from './game_favorite.js'
|
|
10
10
|
import game_favorite_v2 from './game_favorite_v2.js'
|
|
11
11
|
import game_search from './game_search.js'
|
|
12
|
-
import game_search_v2 from './game_search_v2.js'
|
|
13
12
|
import game_hot_new from './game_hot_new.js'
|
|
14
13
|
import inbox from './inbox.js'
|
|
15
14
|
import merge from './merge.js'
|
|
@@ -46,7 +45,6 @@ export default {
|
|
|
46
45
|
game_favorite,
|
|
47
46
|
game_favorite_v2,
|
|
48
47
|
game_search,
|
|
49
|
-
game_search_v2,
|
|
50
48
|
game_hot_new,
|
|
51
49
|
inbox,
|
|
52
50
|
merge,
|
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
import { createMachine, assign, send } from 'xstate'
|
|
2
|
-
import game from '../api/game.js'
|
|
3
|
-
|
|
4
|
-
export default function (request) {
|
|
5
|
-
return createMachine(
|
|
6
|
-
{
|
|
7
|
-
id: 'game_search_v2',
|
|
8
|
-
initial: 'preset',
|
|
9
|
-
context: {
|
|
10
|
-
keyword: '',
|
|
11
|
-
tagId: null,
|
|
12
|
-
mainTagList: [],
|
|
13
|
-
tagList: [],
|
|
14
|
-
gameList: [],
|
|
15
|
-
recentlySearch: [],
|
|
16
|
-
recentlyGame: [],
|
|
17
|
-
youMayLike: [],
|
|
18
|
-
// 以下變數為數據分析用
|
|
19
|
-
selectedType: null,
|
|
20
|
-
tagIndex: null,
|
|
21
|
-
click: null,
|
|
22
|
-
clickDefault: null,
|
|
23
|
-
traceId: null,
|
|
24
|
-
isYouMayLike: null,
|
|
25
|
-
isRecentlyGame: null,
|
|
26
|
-
isRecentlySearch: null,
|
|
27
|
-
gameCode: null,
|
|
28
|
-
},
|
|
29
|
-
states: {
|
|
30
|
-
preset: {
|
|
31
|
-
invoke: {
|
|
32
|
-
src: 'fetchTags',
|
|
33
|
-
onDone: {
|
|
34
|
-
target: 'loading',
|
|
35
|
-
actions: 'setMainTagList',
|
|
36
|
-
},
|
|
37
|
-
onError: {
|
|
38
|
-
target: 'fail',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
loading: {
|
|
43
|
-
invoke: {
|
|
44
|
-
src: 'fetchInitialData',
|
|
45
|
-
onDone: {
|
|
46
|
-
target: 'idle',
|
|
47
|
-
actions: 'setInitialData',
|
|
48
|
-
},
|
|
49
|
-
onError: {
|
|
50
|
-
target: '#game_search_v2.fail',
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
idle: {
|
|
55
|
-
on: {
|
|
56
|
-
SET_MAIN_TAG_ID: {
|
|
57
|
-
target: 'setGameList',
|
|
58
|
-
actions: ['setMainTagId', 'setTraceData']
|
|
59
|
-
},
|
|
60
|
-
PLAY_GAME: {
|
|
61
|
-
target: 'sendingTrace',
|
|
62
|
-
actions: 'setGameCode',
|
|
63
|
-
},
|
|
64
|
-
START_SEARCH: {
|
|
65
|
-
target: 'searching',
|
|
66
|
-
actions: 'clearKeyword',
|
|
67
|
-
},
|
|
68
|
-
CLEAR_MAIN_TAG: {
|
|
69
|
-
actions: 'clearMainTag',
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
setGameList: {
|
|
74
|
-
always: [
|
|
75
|
-
{
|
|
76
|
-
target: 'idle',
|
|
77
|
-
actions: 'setGames',
|
|
78
|
-
cond: 'isRecentlyYouMayLike'
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
target: 'fetchGameList',
|
|
82
|
-
}
|
|
83
|
-
]
|
|
84
|
-
},
|
|
85
|
-
fetchGameList: {
|
|
86
|
-
invoke: {
|
|
87
|
-
src: 'fetchGames',
|
|
88
|
-
onDone: {
|
|
89
|
-
target: 'idle',
|
|
90
|
-
actions: 'setGames',
|
|
91
|
-
},
|
|
92
|
-
onError: {
|
|
93
|
-
target: '#game_search_v2.fail',
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
searching: {
|
|
98
|
-
initial: 'searchIdle',
|
|
99
|
-
states: {
|
|
100
|
-
searchIdle: {
|
|
101
|
-
on: {
|
|
102
|
-
SET_TAG_ID: {
|
|
103
|
-
target: '#game_search_v2.fetchGameList',
|
|
104
|
-
actions: ['setTagId', 'setTraceData']
|
|
105
|
-
},
|
|
106
|
-
PRESS_ENTER: [
|
|
107
|
-
{
|
|
108
|
-
actions: send((context, event) => ({
|
|
109
|
-
type: 'SET_TAG_ID',
|
|
110
|
-
data: {
|
|
111
|
-
tagId: context.tagList[0]?.id,
|
|
112
|
-
traceData: {
|
|
113
|
-
isYouMayLike: null,
|
|
114
|
-
isRecentlyGame: null,
|
|
115
|
-
isRecentlySearch: null
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
})),
|
|
119
|
-
cond: 'hasTagList',
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
target: '#game_search_v2.sendingTrace',
|
|
123
|
-
actions: 'clearExceptKeyword',
|
|
124
|
-
},
|
|
125
|
-
],
|
|
126
|
-
SET_KEYWORD: {
|
|
127
|
-
target: 'debouncing',
|
|
128
|
-
actions: 'setKeyword',
|
|
129
|
-
},
|
|
130
|
-
STOP_SEARCH: {
|
|
131
|
-
target: '#game_search_v2.idle',
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
debouncing: {
|
|
136
|
-
on: {
|
|
137
|
-
SET_KEYWORD: {
|
|
138
|
-
target: 'debouncing',
|
|
139
|
-
actions: 'setKeyword',
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
after: {
|
|
143
|
-
500: {
|
|
144
|
-
target: 'fetching',
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
fetching: {
|
|
149
|
-
invoke: {
|
|
150
|
-
src: 'fetchTags',
|
|
151
|
-
onDone: {
|
|
152
|
-
target: 'searchIdle',
|
|
153
|
-
actions: 'setTagList',
|
|
154
|
-
},
|
|
155
|
-
onError: {
|
|
156
|
-
target: '#game_search_v2.fail',
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
sendingTrace: {
|
|
163
|
-
invoke: {
|
|
164
|
-
src: 'sendTrace',
|
|
165
|
-
onDone: {
|
|
166
|
-
target: 'idle',
|
|
167
|
-
},
|
|
168
|
-
onError: {
|
|
169
|
-
target: 'fail',
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
fail: {},
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
actions: {
|
|
178
|
-
setMainTagList: assign((context, event) => {
|
|
179
|
-
return {
|
|
180
|
-
mainTagList: event.data,
|
|
181
|
-
}
|
|
182
|
-
}),
|
|
183
|
-
setInitialData: assign((context, event) => {
|
|
184
|
-
const { recentlySearch = [], recentlyGame = [], youMayLike = [] } = event.data
|
|
185
|
-
let tagId = null
|
|
186
|
-
let gameList = []
|
|
187
|
-
if (recentlyGame?.length > 0) {
|
|
188
|
-
// tagId = 'RECENTLY'
|
|
189
|
-
gameList = recentlyGame
|
|
190
|
-
} else if (youMayLike?.length > 0) {
|
|
191
|
-
// tagId = 'YOU MAY LIKE'
|
|
192
|
-
gameList = youMayLike
|
|
193
|
-
}
|
|
194
|
-
return {
|
|
195
|
-
recentlySearch: recentlySearch.filter(item => item.id && item.i18n),
|
|
196
|
-
recentlyGame,
|
|
197
|
-
youMayLike,
|
|
198
|
-
gameList,
|
|
199
|
-
tagId
|
|
200
|
-
}
|
|
201
|
-
}),
|
|
202
|
-
setMainTagId: assign((context, event) => {
|
|
203
|
-
const { tagId } = event.data
|
|
204
|
-
const { mainTagList } = context
|
|
205
|
-
const tagIndex = mainTagList.findIndex((tag) => tag.id === tagId)
|
|
206
|
-
return {
|
|
207
|
-
keyword: '',
|
|
208
|
-
tagId,
|
|
209
|
-
tagIndex,
|
|
210
|
-
click: 1,
|
|
211
|
-
clickDefault: null,
|
|
212
|
-
}
|
|
213
|
-
}),
|
|
214
|
-
clearMainTag: assign((context, event) => {
|
|
215
|
-
return {
|
|
216
|
-
tagId: null,
|
|
217
|
-
}
|
|
218
|
-
}),
|
|
219
|
-
setTagId: assign((context, event) => {
|
|
220
|
-
const { tagId, clickTagType, traceData } = event.data
|
|
221
|
-
const { mainTagList, tagList, recentlySearch } = context
|
|
222
|
-
if (clickTagType === 'RECENTLY SEARCH') {
|
|
223
|
-
const tagIndex = recentlySearch.findIndex((tag) => tag.id === tagId)
|
|
224
|
-
return {
|
|
225
|
-
tagId,
|
|
226
|
-
tagIndex,
|
|
227
|
-
click: 1,
|
|
228
|
-
clickDefault: null,
|
|
229
|
-
}
|
|
230
|
-
} else if (clickTagType === 'POPULAR KEYWORDS' || tagList.length <= 0) {
|
|
231
|
-
const tagIndex = mainTagList.findIndex((tag) => tag.id === tagId)
|
|
232
|
-
return {
|
|
233
|
-
tagId,
|
|
234
|
-
tagIndex,
|
|
235
|
-
click: null,
|
|
236
|
-
clickDefault: 1,
|
|
237
|
-
}
|
|
238
|
-
} else {
|
|
239
|
-
const tagIndex = tagList.findIndex((tag) => tag.id === tagId)
|
|
240
|
-
return {
|
|
241
|
-
tagId,
|
|
242
|
-
tagIndex,
|
|
243
|
-
click: 1,
|
|
244
|
-
clickDefault: null,
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}),
|
|
248
|
-
setGames: assign((context, event) => {
|
|
249
|
-
if (event?.data) {
|
|
250
|
-
const { traceId, result } = event.data
|
|
251
|
-
return {
|
|
252
|
-
traceId,
|
|
253
|
-
gameList: result,
|
|
254
|
-
}
|
|
255
|
-
} else {
|
|
256
|
-
const { tagId, recentlyGame, youMayLike } = context
|
|
257
|
-
let gameList = []
|
|
258
|
-
if (tagId === 'RECENTLY') {
|
|
259
|
-
gameList = recentlyGame
|
|
260
|
-
} else if (tagId === 'YOU MAY LIKE') {
|
|
261
|
-
gameList = youMayLike
|
|
262
|
-
}
|
|
263
|
-
return {
|
|
264
|
-
traceId: null,
|
|
265
|
-
gameList,
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}),
|
|
269
|
-
setTraceData: assign((context, event) => {
|
|
270
|
-
const { isYouMayLike, isRecentlyGame, isRecentlySearch } = event.data?.traceData
|
|
271
|
-
return {
|
|
272
|
-
isYouMayLike,
|
|
273
|
-
isRecentlyGame,
|
|
274
|
-
isRecentlySearch,
|
|
275
|
-
}
|
|
276
|
-
}),
|
|
277
|
-
setKeyword: assign((context, event) => {
|
|
278
|
-
return {
|
|
279
|
-
keyword: event.data,
|
|
280
|
-
}
|
|
281
|
-
}),
|
|
282
|
-
clearKeyword: assign((context, event) => {
|
|
283
|
-
return {
|
|
284
|
-
keyword: '',
|
|
285
|
-
}
|
|
286
|
-
}),
|
|
287
|
-
setTagList: assign((context, event) => {
|
|
288
|
-
return {
|
|
289
|
-
tagList: event.data,
|
|
290
|
-
}
|
|
291
|
-
}),
|
|
292
|
-
setGameCode: assign((context, event) => {
|
|
293
|
-
const { gameList } = context
|
|
294
|
-
const gameCode = event.data
|
|
295
|
-
const gameCodeIndex = gameList.findIndex((game) => game === gameCode)
|
|
296
|
-
return {
|
|
297
|
-
gameCode,
|
|
298
|
-
gameCodeIndex,
|
|
299
|
-
}
|
|
300
|
-
}),
|
|
301
|
-
clearExceptKeyword: assign((context, event) => {
|
|
302
|
-
return {
|
|
303
|
-
gameList: [],
|
|
304
|
-
traceId: null,
|
|
305
|
-
tagId: null,
|
|
306
|
-
tagIndex: null,
|
|
307
|
-
gameCode: null,
|
|
308
|
-
gameCodeIndex: null,
|
|
309
|
-
isYouMayLike: null,
|
|
310
|
-
isRecentlyGame: null,
|
|
311
|
-
isRecentlySearch: null,
|
|
312
|
-
query: context.keyword,
|
|
313
|
-
click: null,
|
|
314
|
-
clickDefault: null,
|
|
315
|
-
}
|
|
316
|
-
}),
|
|
317
|
-
},
|
|
318
|
-
guards: {
|
|
319
|
-
isRecentlyYouMayLike: (context, event) => {
|
|
320
|
-
const { tagId } = context
|
|
321
|
-
return tagId === 'RECENTLY' || tagId === 'YOU MAY LIKE'
|
|
322
|
-
},
|
|
323
|
-
hasTagList: (context, event) => {
|
|
324
|
-
const { tagList } = context
|
|
325
|
-
return tagList?.length > 0
|
|
326
|
-
},
|
|
327
|
-
},
|
|
328
|
-
services: {
|
|
329
|
-
fetchTags: async (context, event) => {
|
|
330
|
-
const { keyword } = context
|
|
331
|
-
const { result } = await request.send(game.getGameTags({ q: keyword }))
|
|
332
|
-
return result
|
|
333
|
-
},
|
|
334
|
-
fetchInitialData: async (context, event) => {
|
|
335
|
-
const data = await request.send(game.getGameSearchHome())
|
|
336
|
-
return data
|
|
337
|
-
},
|
|
338
|
-
fetchGames: async (context, event) => {
|
|
339
|
-
const { tagId, tagIndex, keyword, click, clickDefault } = context
|
|
340
|
-
const { traceId, result } = await request.send(game.getGameSearchList({ id: tagId, index: tagIndex, q: keyword, click, clickDefault }))
|
|
341
|
-
return { traceId, result }
|
|
342
|
-
},
|
|
343
|
-
sendTrace: async (context, event) => {
|
|
344
|
-
const { traceId, tagId, tagIndex, gameCode, gameCodeIndex, keyword: query, click, clickDefault, isYouMayLike, isRecentlyGame, isRecentlySearch } = context
|
|
345
|
-
let id = tagId
|
|
346
|
-
if (tagId === 'RECENTLY' || tagId === 'YOU MAY LIKE') {
|
|
347
|
-
id = null
|
|
348
|
-
}
|
|
349
|
-
return await request.send(game.setGameSearchTrace({ traceId, tagId: id, tagIndex, gameCode, gameCodeIndex, query, click, clickDefault, isYouMayLike, isRecentlyGame, isRecentlySearch }))
|
|
350
|
-
},
|
|
351
|
-
},
|
|
352
|
-
}
|
|
353
|
-
)
|
|
354
|
-
}
|