@jetthai/cuora 1.1.469 → 1.1.470-dev.0
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/.claude/commands/sync-ai-prompts.md +88 -1
- package/.claude/settings.local.json +3 -1
- package/.github/copilot-instructions.md +64 -57
- package/.husky/post-checkout +3 -3
- package/.husky/pre-push +1 -1
- package/.prettierignore +2 -1
- package/AGENTS.md +64 -57
- package/AI_PROMPT_SOURCE.md +64 -57
- package/CHANGELOG.md +182 -4
- package/CLAUDE.md +64 -57
- package/GEMINI.md +64 -57
- package/README.md +11 -12
- package/package.json +1 -1
- package/scripts/auto-version.js +1 -0
- package/scripts/branch-auto-npm-publish.js +9 -2
- package/src/api/account.js +0 -1
- package/src/api/activity.js +0 -37
- package/src/api/auth.js +0 -31
- package/src/api/game.js +0 -10
- package/src/api/payment.js +0 -52
- package/src/api/user.js +4 -22
- package/src/index.js +2 -2
- package/src/machine/activity/activity_cash.js +23 -15
- package/src/machine/activity/diamond_shop_activity_cash.js +0 -1
- package/src/machine/activity/fafafa_activity.js +0 -10
- package/src/machine/activity/index.js +0 -12
- package/src/machine/auth.js +16 -68
- package/src/machine/auth_otp_v3.js +0 -3
- package/src/machine/common.js +0 -55
- package/src/machine/deposit/index.js +0 -28
- package/src/machine/deposit/manual_cash.js +0 -8
- package/src/machine/game_info.js +1 -12
- package/src/machine/game_v2_1.js +1 -89
- package/src/machine/inbox.js +0 -12
- package/src/machine/index.js +0 -32
- package/src/machine/reward_cash.js +0 -39
- package/src/machine/user_reset_password.js +0 -13
- package/src/machine/user_sign_up.js +6 -1
- package/src/machine/websocket.js +0 -4
- package/src/machine/withdraw/index.js +0 -6
- package/src/request/request.js +0 -28
- package/src/util/constant.js +0 -1
- package/src/util/index.js +1 -4
- package/src/machine/activity/activity.js +0 -209
- package/src/machine/activity/diamond_shop_activity_fc.js +0 -196
- package/src/machine/activity/diamond_shop_activity_vn.js +0 -178
- package/src/machine/activity/invite_friends_activity.js +0 -114
- package/src/machine/activity/mini_game_activity.js +0 -68
- package/src/machine/activity/return_bonus_activity.js +0 -153
- package/src/machine/auth_otp_v2.js +0 -177
- package/src/machine/bank_binding_amb.js +0 -146
- package/src/machine/bonus.js +0 -76
- package/src/machine/deposit/amb.js +0 -93
- package/src/machine/deposit/crypto_bank.js +0 -330
- package/src/machine/deposit/crypto_qrcode.js +0 -148
- package/src/machine/deposit/crypto_way.js +0 -252
- package/src/machine/deposit/deposit_fc.js +0 -272
- package/src/machine/deposit/direct.js +0 -310
- package/src/machine/deposit/float.js +0 -375
- package/src/machine/deposit/krway.js +0 -151
- package/src/machine/deposit/loadcard_vn.js +0 -351
- package/src/machine/deposit/manual_vn.js +0 -458
- package/src/machine/deposit/qrcode_v2.js +0 -338
- package/src/machine/deposit/usdt.js +0 -144
- package/src/machine/deposit/virtual_bank_vn.js +0 -269
- package/src/machine/deposit/vpay.js +0 -368
- package/src/machine/game_hot_new.js +0 -79
- package/src/machine/game_replay.js +0 -46
- package/src/machine/game_search_v2.js +0 -401
- package/src/machine/honor_board.js +0 -132
- package/src/machine/merge.js +0 -57
- package/src/machine/payment_data.js +0 -86
- package/src/machine/promotions.js +0 -170
- package/src/machine/reward.js +0 -255
- package/src/machine/reward_fc.js +0 -98
- package/src/machine/side.js +0 -154
- package/src/machine/side_v2.js +0 -211
- package/src/machine/vip_table.js +0 -57
- package/src/machine/welcome.js +0 -110
- package/src/machine/withdraw/withdraw_crypto_cash.js +0 -327
- package/src/machine/withdraw/withdraw_krway.js +0 -223
- package/src/machine/withdraw/withdraw_manual.js +0 -536
- package/src/util/math.js +0 -4
package/src/machine/index.js
CHANGED
|
@@ -1,42 +1,26 @@
|
|
|
1
1
|
import activity from './activity/index.js'
|
|
2
2
|
import auth from './auth.js'
|
|
3
|
-
import welcome from './welcome.js'
|
|
4
3
|
import common from './common.js'
|
|
5
4
|
import error from './error.js'
|
|
6
5
|
import game_v2_1 from './game_v2_1.js'
|
|
7
6
|
import game_favorite_v2 from './game_favorite_v2.js'
|
|
8
7
|
import game_search_cash from './game_search_cash.js'
|
|
9
|
-
import game_search_v2 from './game_search_v2.js'
|
|
10
|
-
import game_hot_new from './game_hot_new.js'
|
|
11
8
|
import game_info from './game_info.js'
|
|
12
|
-
import game_replay from './game_replay.js'
|
|
13
9
|
import game_betslip from './game_betslip.js'
|
|
14
10
|
import inbox from './inbox.js'
|
|
15
|
-
import merge from './merge.js'
|
|
16
|
-
import payment_data from './payment_data.js'
|
|
17
|
-
import reward_fc from './reward_fc.js'
|
|
18
|
-
import reward from './reward.js'
|
|
19
11
|
import reward_cash from './reward_cash.js'
|
|
20
12
|
import setting from './setting.js'
|
|
21
|
-
import side from './side.js'
|
|
22
|
-
import side_v2 from './side_v2.js'
|
|
23
13
|
import side_cash from './side_cash.js'
|
|
24
14
|
import user_info from './user_info.js'
|
|
25
15
|
import user_sign_up from './user_sign_up.js'
|
|
26
16
|
import user_reset_password from './user_reset_password.js'
|
|
27
17
|
import bank_binding from './bank_binding.js'
|
|
28
|
-
import bank_binding_amb from './bank_binding_amb.js'
|
|
29
18
|
import withdraw from './withdraw/index.js'
|
|
30
19
|
import deposit from './deposit/index.js'
|
|
31
|
-
import bonus from './bonus.js'
|
|
32
20
|
import leaderboard from './leaderboard.js'
|
|
33
|
-
import auth_otp_v2 from './auth_otp_v2.js'
|
|
34
21
|
import auth_otp_v3 from './auth_otp_v3.js'
|
|
35
|
-
import vip_table from './vip_table.js'
|
|
36
|
-
import promotions from './promotions.js'
|
|
37
22
|
import roulette_v2 from './roulette_v2.js'
|
|
38
23
|
import honor_board_cash from './honor_board_cash.js'
|
|
39
|
-
import honor_board from './honor_board.js'
|
|
40
24
|
import user_photo from './user_photo.js'
|
|
41
25
|
import navbar from './navbar.js'
|
|
42
26
|
import websocket from './websocket.js'
|
|
@@ -45,42 +29,26 @@ import ranking from './ranking.js'
|
|
|
45
29
|
export default {
|
|
46
30
|
...activity,
|
|
47
31
|
auth,
|
|
48
|
-
welcome,
|
|
49
32
|
common,
|
|
50
33
|
error,
|
|
51
34
|
game_favorite_v2,
|
|
52
35
|
game_search_cash,
|
|
53
|
-
game_search_v2,
|
|
54
|
-
game_hot_new,
|
|
55
36
|
game_info,
|
|
56
|
-
game_replay,
|
|
57
37
|
game_betslip,
|
|
58
38
|
inbox,
|
|
59
|
-
merge,
|
|
60
|
-
payment_data,
|
|
61
|
-
reward,
|
|
62
39
|
reward_cash,
|
|
63
|
-
reward_fc,
|
|
64
40
|
setting,
|
|
65
|
-
side,
|
|
66
|
-
side_v2,
|
|
67
41
|
side_cash,
|
|
68
42
|
game_v2_1,
|
|
69
43
|
user_info,
|
|
70
44
|
user_sign_up,
|
|
71
45
|
user_reset_password,
|
|
72
46
|
bank_binding,
|
|
73
|
-
bank_binding_amb,
|
|
74
47
|
...deposit,
|
|
75
|
-
bonus,
|
|
76
48
|
leaderboard,
|
|
77
|
-
auth_otp_v2,
|
|
78
49
|
auth_otp_v3,
|
|
79
|
-
vip_table,
|
|
80
|
-
promotions,
|
|
81
50
|
roulette_v2,
|
|
82
51
|
honor_board_cash,
|
|
83
|
-
honor_board,
|
|
84
52
|
user_photo,
|
|
85
53
|
navbar,
|
|
86
54
|
...withdraw,
|
|
@@ -63,10 +63,6 @@ export default function (request, context) {
|
|
|
63
63
|
states: {
|
|
64
64
|
idle: {
|
|
65
65
|
on: {
|
|
66
|
-
FETCH_WITHDRAW_RULE: {
|
|
67
|
-
target: 'fetching',
|
|
68
|
-
actions: 'setRewardData',
|
|
69
|
-
},
|
|
70
66
|
FETCH_OTHER_REWARD: {
|
|
71
67
|
target: 'fetchingOtherReward',
|
|
72
68
|
actions: 'setOrderColumn',
|
|
@@ -84,18 +80,6 @@ export default function (request, context) {
|
|
|
84
80
|
},
|
|
85
81
|
},
|
|
86
82
|
},
|
|
87
|
-
fetching: {
|
|
88
|
-
invoke: {
|
|
89
|
-
src: 'fetchWithdrawRulePreview',
|
|
90
|
-
onDone: {
|
|
91
|
-
target: 'pending',
|
|
92
|
-
actions: 'setWithdrawRulePreview',
|
|
93
|
-
},
|
|
94
|
-
onError: {
|
|
95
|
-
target: 'idle',
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
83
|
fetchingOtherReward: {
|
|
100
84
|
invoke: {
|
|
101
85
|
src: 'fetchOtherRewardList',
|
|
@@ -180,13 +164,6 @@ export default function (request, context) {
|
|
|
180
164
|
otherRewardList: event.data[0]?.data,
|
|
181
165
|
}
|
|
182
166
|
}),
|
|
183
|
-
setRewardData: assign((context, event) => {
|
|
184
|
-
const { activityNo, receiveNo } = event.data
|
|
185
|
-
return {
|
|
186
|
-
activityNo,
|
|
187
|
-
receiveNo,
|
|
188
|
-
}
|
|
189
|
-
}),
|
|
190
167
|
setCallback: assign((context, event) => {
|
|
191
168
|
return {
|
|
192
169
|
callback: event.data?.callback || (() => {}),
|
|
@@ -200,11 +177,6 @@ export default function (request, context) {
|
|
|
200
177
|
doCallback: (context, event) => {
|
|
201
178
|
context.callback()
|
|
202
179
|
},
|
|
203
|
-
setWithdrawRulePreview: assign((context, event) => {
|
|
204
|
-
return {
|
|
205
|
-
withdrawRule: event.data,
|
|
206
|
-
}
|
|
207
|
-
}),
|
|
208
180
|
setLang: assign((context, event) => {
|
|
209
181
|
const lang = event.data.locale || context.lang || 'en-US'
|
|
210
182
|
return { lang }
|
|
@@ -250,17 +222,6 @@ export default function (request, context) {
|
|
|
250
222
|
const [otherRewardList] = await Promise.all([getOtherRewardAPI])
|
|
251
223
|
return [otherRewardList]
|
|
252
224
|
},
|
|
253
|
-
fetchWithdrawRulePreview: async (context, event) => {
|
|
254
|
-
const { receiveNo } = context
|
|
255
|
-
const data = await request.send(
|
|
256
|
-
payment.getWithdrawRulePreview({
|
|
257
|
-
applyType: 'activity',
|
|
258
|
-
applyNo: receiveNo,
|
|
259
|
-
amount: null,
|
|
260
|
-
})
|
|
261
|
-
)
|
|
262
|
-
return data
|
|
263
|
-
},
|
|
264
225
|
receiveReward: async (context, event) => {
|
|
265
226
|
const { activityNo, receiveNo, attended } = event.data
|
|
266
227
|
// Number("")-> 0 / Number(" ") -> 0 需要收到實際的數字才傳給後端
|
|
@@ -28,10 +28,6 @@ export default function (request) {
|
|
|
28
28
|
target: 'otpFetching',
|
|
29
29
|
actions: 'setOtpParamsEmail',
|
|
30
30
|
},
|
|
31
|
-
SEND_OTP_LOCAL: {
|
|
32
|
-
target: 'otpFetching',
|
|
33
|
-
actions: 'setOtpParamsLocal',
|
|
34
|
-
},
|
|
35
31
|
SEND_OTP_PHONE: {
|
|
36
32
|
target: 'otpFetching',
|
|
37
33
|
actions: 'setOtpParamsPhone',
|
|
@@ -157,15 +153,6 @@ export default function (request) {
|
|
|
157
153
|
},
|
|
158
154
|
}
|
|
159
155
|
}),
|
|
160
|
-
setOtpParamsLocal: assign((context, event) => {
|
|
161
|
-
const { username } = event.data
|
|
162
|
-
return {
|
|
163
|
-
otpParams: {
|
|
164
|
-
provider: 'local',
|
|
165
|
-
username,
|
|
166
|
-
},
|
|
167
|
-
}
|
|
168
|
-
}),
|
|
169
156
|
setOtpParamsEmail: assign((context, event) => {
|
|
170
157
|
const { email } = event.data
|
|
171
158
|
return {
|
|
@@ -34,6 +34,7 @@ export default function (request) {
|
|
|
34
34
|
site: null,
|
|
35
35
|
strategy: null,
|
|
36
36
|
uid: null,
|
|
37
|
+
agentId: null,
|
|
37
38
|
},
|
|
38
39
|
deviceTokenEnable: true,
|
|
39
40
|
},
|
|
@@ -106,6 +107,7 @@ export default function (request) {
|
|
|
106
107
|
return {
|
|
107
108
|
signUpData: {
|
|
108
109
|
provider: 'local',
|
|
110
|
+
birthday,
|
|
109
111
|
...pickBindData(event.data),
|
|
110
112
|
birthday,
|
|
111
113
|
email,
|
|
@@ -129,6 +131,7 @@ export default function (request) {
|
|
|
129
131
|
return {
|
|
130
132
|
signUpData: {
|
|
131
133
|
provider: 'phone',
|
|
134
|
+
birthday,
|
|
132
135
|
...pickBindData(event.data),
|
|
133
136
|
birthday,
|
|
134
137
|
email,
|
|
@@ -151,6 +154,7 @@ export default function (request) {
|
|
|
151
154
|
return {
|
|
152
155
|
signUpData: {
|
|
153
156
|
provider: 'email',
|
|
157
|
+
birthday,
|
|
154
158
|
...pickBindData(event.data),
|
|
155
159
|
birthday,
|
|
156
160
|
email,
|
|
@@ -168,7 +172,7 @@ export default function (request) {
|
|
|
168
172
|
}
|
|
169
173
|
}),
|
|
170
174
|
setRegistrationData: assign((context, event) => {
|
|
171
|
-
const { account, currency, site, strategy, uid } = event.data
|
|
175
|
+
const { account, currency, site, strategy, uid, agentId } = event.data
|
|
172
176
|
return {
|
|
173
177
|
registrationData: {
|
|
174
178
|
account,
|
|
@@ -176,6 +180,7 @@ export default function (request) {
|
|
|
176
180
|
site,
|
|
177
181
|
strategy,
|
|
178
182
|
uid,
|
|
183
|
+
agentId,
|
|
179
184
|
},
|
|
180
185
|
}
|
|
181
186
|
}),
|
package/src/machine/websocket.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import withdraw_manual from './withdraw_manual.js'
|
|
2
|
-
import withdraw_krway from './withdraw_krway.js'
|
|
3
|
-
import withdraw_crypto_cash from './withdraw_crypto_cash.js'
|
|
4
1
|
import withdraw_manual_cash from './withdraw_manual_cash.js'
|
|
5
2
|
|
|
6
3
|
export default {
|
|
7
|
-
withdraw_manual,
|
|
8
|
-
withdraw_krway,
|
|
9
|
-
withdraw_crypto_cash,
|
|
10
4
|
withdraw_manual_cash,
|
|
11
5
|
}
|
package/src/request/request.js
CHANGED
|
@@ -6,7 +6,6 @@ import { getErr998SentryExtra } from '../util/err998SentryExtra.js'
|
|
|
6
6
|
const supportVersion2List = [
|
|
7
7
|
// 04-09 Update
|
|
8
8
|
'game/play',
|
|
9
|
-
'game/gameReplay',
|
|
10
9
|
'game/logout',
|
|
11
10
|
'game/list/v3/root',
|
|
12
11
|
'game/list/v3/category',
|
|
@@ -18,8 +17,6 @@ const supportVersion2List = [
|
|
|
18
17
|
'game/list/v3/removeMyFavorite',
|
|
19
18
|
'login',
|
|
20
19
|
'callback/:strategy',
|
|
21
|
-
'guestLogin',
|
|
22
|
-
'appLogin',
|
|
23
20
|
'logout',
|
|
24
21
|
'self',
|
|
25
22
|
'register',
|
|
@@ -27,7 +24,6 @@ const supportVersion2List = [
|
|
|
27
24
|
'verify',
|
|
28
25
|
'reset',
|
|
29
26
|
'acknowledge',
|
|
30
|
-
'recovery',
|
|
31
27
|
'recovery/abandon',
|
|
32
28
|
'recovery/acknowledge',
|
|
33
29
|
'checkDt',
|
|
@@ -56,7 +52,6 @@ const supportVersion2List = [
|
|
|
56
52
|
'account-binding/status',
|
|
57
53
|
'account-binding/bind',
|
|
58
54
|
'account-binding/acknowledge',
|
|
59
|
-
'account-binding/bind-third-party',
|
|
60
55
|
'feeds',
|
|
61
56
|
'broadcast',
|
|
62
57
|
'upload',
|
|
@@ -75,28 +70,21 @@ const supportVersion2List = [
|
|
|
75
70
|
'payment/v2/convertFreeCredit',
|
|
76
71
|
'payment/v2/getBindingBankList',
|
|
77
72
|
'payment/v2/getBindingPaymentList',
|
|
78
|
-
'payment/v2/getWithdrawBankList',
|
|
79
|
-
'payment/v2/getCurrentWithdrawRule',
|
|
80
73
|
'payment/v2/withdrawCheck',
|
|
81
|
-
'payment/v2/history',
|
|
82
|
-
'payment/v2/mergeWallet',
|
|
83
74
|
'payment/v2/paymentDetail',
|
|
84
75
|
'payment/v2/category/options',
|
|
85
76
|
'payment/v2/paymentInfo',
|
|
86
77
|
'payment/v2/getBindingPaymentInfo',
|
|
87
78
|
'payment/v2/pendingOrder',
|
|
88
79
|
'payment/v2/promotions',
|
|
89
|
-
'payment/v2/spotmarket',
|
|
90
80
|
'payment/v2/transactionHistory',
|
|
91
81
|
'payment/v2/updateUtr',
|
|
92
|
-
'payment/v2/setting',
|
|
93
82
|
'payment/v2/amb/setting',
|
|
94
83
|
'payment/v2/updatePaymentInfo',
|
|
95
84
|
'payment/v2/uploadSlip',
|
|
96
85
|
'payment/v2/withdrawRule',
|
|
97
86
|
'payment/v2/:paymentType/getBankList',
|
|
98
87
|
'payment/v2/:paymentType/transaction',
|
|
99
|
-
'payment/v2/:paymentType/checkTransaction',
|
|
100
88
|
'payment/v2/:paymentType/bonus/preview',
|
|
101
89
|
'payment/v2/:paymentType/expected/result',
|
|
102
90
|
'payment/v2/:paymentType/crypto/expected/result',
|
|
@@ -111,7 +99,6 @@ const supportVersion2List = [
|
|
|
111
99
|
'activities',
|
|
112
100
|
'activities/types',
|
|
113
101
|
'activities/promo',
|
|
114
|
-
'activities/viptable',
|
|
115
102
|
'activities/level-bonus/info',
|
|
116
103
|
'activities/numbers',
|
|
117
104
|
'activities/honorBroadcast',
|
|
@@ -133,7 +120,6 @@ const supportVersion2List = [
|
|
|
133
120
|
'friends/dashboard',
|
|
134
121
|
'friends/dashboard/list',
|
|
135
122
|
'activities/ranking',
|
|
136
|
-
'activities/activity/ranking',
|
|
137
123
|
'activities/cashRain',
|
|
138
124
|
'activities/jackpot/list',
|
|
139
125
|
// 09/09
|
|
@@ -147,7 +133,6 @@ const supportVersion2List = [
|
|
|
147
133
|
'account-binding/status',
|
|
148
134
|
'account-binding/bind',
|
|
149
135
|
'account-binding/acknowledge',
|
|
150
|
-
'account-binding/bind-third-party',
|
|
151
136
|
'account-binding/bind-password',
|
|
152
137
|
'account-binding/reset-otp',
|
|
153
138
|
// 11/10
|
|
@@ -165,7 +150,6 @@ function isValid(value) {
|
|
|
165
150
|
export default class Request {
|
|
166
151
|
constructor(axios, config) {
|
|
167
152
|
this.axios = axios
|
|
168
|
-
this.source = axios.CancelToken.source()
|
|
169
153
|
this.config = config
|
|
170
154
|
this.sentry = config.sentry
|
|
171
155
|
this.key = `cuora_${config.clientId}`
|
|
@@ -285,17 +269,6 @@ export default class Request {
|
|
|
285
269
|
}
|
|
286
270
|
}
|
|
287
271
|
|
|
288
|
-
// 注意:send() 已不再預設附加 this.source.token(見 send 內註解),
|
|
289
|
-
// sourceUpdate 僅對「呼叫端明確以 this.source.token 為 customToken」的請求有效;保留以維持 API 相容。
|
|
290
|
-
sourceUpdate() {
|
|
291
|
-
this.source.cancel('Requests Cancelled')
|
|
292
|
-
this.source = this.axios.CancelToken.source()
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
sourceGenerate() {
|
|
296
|
-
return this.axios.CancelToken.source()
|
|
297
|
-
}
|
|
298
|
-
|
|
299
272
|
_createConfig(req, cancelToken) {
|
|
300
273
|
const { method, url, params, isPublic, isFormData, headers } = req
|
|
301
274
|
let fullURL = this.config.fullURL
|
|
@@ -354,7 +327,6 @@ export default class Request {
|
|
|
354
327
|
'activities/getFreeGameRewardList': 'activities/free-game/get-free-game-reward-list',
|
|
355
328
|
'activities/lose-rebate/history': 'activities/rebate/lose-rebate/history',
|
|
356
329
|
'activities/ranking': 'activities/ranking/promotion-ranking',
|
|
357
|
-
'activities/activity/ranking': 'activities/ranking/basic-ranking',
|
|
358
330
|
'activities/cashRain': 'activities/cash-rain/exchange',
|
|
359
331
|
'tournament/detail': 'activities/tournament/detail',
|
|
360
332
|
'ranking/detail': 'activities/tournament/ranking/detail',
|
package/src/util/constant.js
CHANGED
package/src/util/index.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import storage from './storage.js'
|
|
2
2
|
import paramStore from './paramStore.js'
|
|
3
3
|
import * as constant from './constant.js'
|
|
4
|
-
import { max } from './math.js'
|
|
5
|
-
import { isAmountInRange } from './amount.js'
|
|
6
4
|
|
|
7
|
-
export
|
|
8
|
-
export { constant, storage, paramStore, max, isAmountInRange }
|
|
5
|
+
export { constant, storage, paramStore }
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { createMachine, assign } from 'xstate'
|
|
2
|
-
import activity from '../../api/activity.js'
|
|
3
|
-
import payment from '../../api/payment.js'
|
|
4
|
-
|
|
5
|
-
export default function (request) {
|
|
6
|
-
const { appSecret } = request.config
|
|
7
|
-
return createMachine(
|
|
8
|
-
{
|
|
9
|
-
id: 'activity',
|
|
10
|
-
initial: 'init',
|
|
11
|
-
context: {
|
|
12
|
-
tick: 2000,
|
|
13
|
-
specifyActivities: [4, 29, 34],
|
|
14
|
-
activitiesDetailList: [],
|
|
15
|
-
activityList: [],
|
|
16
|
-
promotionList: [],
|
|
17
|
-
activityMap: {},
|
|
18
|
-
tournamentList: [],
|
|
19
|
-
refs: {},
|
|
20
|
-
uidSite: '',
|
|
21
|
-
siteConfig: {},
|
|
22
|
-
isPlaying: false,
|
|
23
|
-
},
|
|
24
|
-
states: {
|
|
25
|
-
init: {
|
|
26
|
-
on: {
|
|
27
|
-
SET_CONFIG: {
|
|
28
|
-
target: 'fetchingList',
|
|
29
|
-
actions: 'setSiteConifg',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
fetchingList: {
|
|
34
|
-
invoke: {
|
|
35
|
-
src: 'fetchList',
|
|
36
|
-
onDone: {
|
|
37
|
-
target: 'idle',
|
|
38
|
-
actions: ['setActivityList', 'setTournamentList', 'setPromotionList'],
|
|
39
|
-
},
|
|
40
|
-
onError: {
|
|
41
|
-
target: 'idle',
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
idle: {
|
|
46
|
-
type: 'parallel',
|
|
47
|
-
states: {
|
|
48
|
-
activitiesDetail: {
|
|
49
|
-
initial: 'checking',
|
|
50
|
-
states: {
|
|
51
|
-
checking: {
|
|
52
|
-
always: [{ target: 'fetchActivityDetail', cond: 'hasSpecifyActivities' }, { target: 'end' }],
|
|
53
|
-
},
|
|
54
|
-
fetchActivityDetail: {
|
|
55
|
-
invoke: {
|
|
56
|
-
src: 'fetchActivitiesDetail',
|
|
57
|
-
onDone: {
|
|
58
|
-
target: 'end',
|
|
59
|
-
actions: 'setActivitiesDetailList',
|
|
60
|
-
},
|
|
61
|
-
onError: {
|
|
62
|
-
target: 'end',
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
end: {},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
pending: {
|
|
70
|
-
after: {
|
|
71
|
-
TIMEOUT: [
|
|
72
|
-
{ target: '#activity.fetchingList', cond: 'isNotInGame' },
|
|
73
|
-
{ target: '#activity.idle', cond: 'isInGame' },
|
|
74
|
-
],
|
|
75
|
-
},
|
|
76
|
-
on: {
|
|
77
|
-
SET_UNREAD: {
|
|
78
|
-
actions: 'setUnread',
|
|
79
|
-
},
|
|
80
|
-
RESET_ACTIVITIES: {
|
|
81
|
-
actions: 'resetActivities',
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
on: {
|
|
89
|
-
REFRESH: {
|
|
90
|
-
target: '#activity.fetchingList',
|
|
91
|
-
actions: 'leaveGame',
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
actions: {
|
|
97
|
-
setSiteConifg: assign((context, event) => {
|
|
98
|
-
return {
|
|
99
|
-
siteConfig: event.data,
|
|
100
|
-
}
|
|
101
|
-
}),
|
|
102
|
-
setTournamentList: assign((context, event) => {
|
|
103
|
-
const { activityList } = event.data
|
|
104
|
-
const tournamentList = activityList.filter((item) => item.tournament === 1)
|
|
105
|
-
return {
|
|
106
|
-
tournamentList,
|
|
107
|
-
}
|
|
108
|
-
}),
|
|
109
|
-
setActivityList: assign((context, event) => {
|
|
110
|
-
const noRedActivity = [2, 4, 13, 20, 90, 91, 92]
|
|
111
|
-
const { uidSite } = context
|
|
112
|
-
const { activityList } = event.data
|
|
113
|
-
let list = JSON.parse(JSON.stringify(activityList))
|
|
114
|
-
list.forEach((activity) => {
|
|
115
|
-
const storageUnread = localStorage.getItem(`unread_${activity.activityNo}_${uidSite}`)
|
|
116
|
-
if (noRedActivity.includes(activity.activityType)) {
|
|
117
|
-
activity.unread = false
|
|
118
|
-
} else if (storageUnread) {
|
|
119
|
-
activity.unread = JSON.parse(storageUnread)
|
|
120
|
-
} else {
|
|
121
|
-
activity.unread = true
|
|
122
|
-
}
|
|
123
|
-
})
|
|
124
|
-
return {
|
|
125
|
-
activityList: list,
|
|
126
|
-
}
|
|
127
|
-
}),
|
|
128
|
-
setPromotionList: assign((context, event) => {
|
|
129
|
-
const { promotionList } = event.data
|
|
130
|
-
return {
|
|
131
|
-
promotionList,
|
|
132
|
-
}
|
|
133
|
-
}),
|
|
134
|
-
setActivitiesDetailList: assign((context, event) => {
|
|
135
|
-
return {
|
|
136
|
-
activitiesDetailList: event.data.map((item) => item.data),
|
|
137
|
-
}
|
|
138
|
-
}),
|
|
139
|
-
setUnread: assign((context, event) => {
|
|
140
|
-
const { uidSite, activityNo, unread } = event.data
|
|
141
|
-
const list = JSON.parse(JSON.stringify(context.activityList))
|
|
142
|
-
localStorage.setItem(`unread_${activityNo}_${uidSite}`, `${unread}`)
|
|
143
|
-
list.map((item) => {
|
|
144
|
-
if (item.activityNo === activityNo) {
|
|
145
|
-
item.unread = JSON.parse(`${unread}`)
|
|
146
|
-
}
|
|
147
|
-
return item
|
|
148
|
-
})
|
|
149
|
-
return {
|
|
150
|
-
activityList: list,
|
|
151
|
-
uidSite,
|
|
152
|
-
}
|
|
153
|
-
}),
|
|
154
|
-
resetActivities: assign((context, event) => {
|
|
155
|
-
return {
|
|
156
|
-
isPlaying: true,
|
|
157
|
-
}
|
|
158
|
-
}),
|
|
159
|
-
leaveGame: assign((context, event) => {
|
|
160
|
-
return {
|
|
161
|
-
isPlaying: false,
|
|
162
|
-
}
|
|
163
|
-
}),
|
|
164
|
-
},
|
|
165
|
-
guards: {
|
|
166
|
-
hasSpecifyActivities: (context, event) => {
|
|
167
|
-
const { activityList = [], specifyActivities = [] } = context
|
|
168
|
-
const filterActivityList = activityList.filter((activity) => specifyActivities.includes(activity.activityType))
|
|
169
|
-
return filterActivityList.length > 0
|
|
170
|
-
},
|
|
171
|
-
isInGame: (context, event) => {
|
|
172
|
-
return context.isPlaying
|
|
173
|
-
},
|
|
174
|
-
isNotInGame: (context, event) => {
|
|
175
|
-
return !context.isPlaying
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
delays: {
|
|
179
|
-
TIMEOUT: (context, event) => {
|
|
180
|
-
const { tick } = context
|
|
181
|
-
return tick * 10
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
services: {
|
|
185
|
-
fetchList: async (context, event) => {
|
|
186
|
-
const hasToken = request.getToken()
|
|
187
|
-
const apiCallable = hasToken
|
|
188
|
-
const [{ data }, promotionList] = await Promise.all([
|
|
189
|
-
hasToken ? request.send(activity.getActivityList({ appSecret })) : request.send(activity.getAllActivityList({ appSecret })),
|
|
190
|
-
apiCallable && !context.isPlaying ? request.send(payment.getPromotionsList()) : [],
|
|
191
|
-
])
|
|
192
|
-
|
|
193
|
-
return { activityList: data, promotionList }
|
|
194
|
-
},
|
|
195
|
-
fetchActivitiesDetail: async (context, event) => {
|
|
196
|
-
await new Promise((resolve) => setTimeout(resolve, 1000)) // delay 1 second
|
|
197
|
-
|
|
198
|
-
const { activityList = [], specifyActivities = [] } = context
|
|
199
|
-
const filterActivityList = activityList.filter((activity) => specifyActivities.includes(activity.activityType))
|
|
200
|
-
const promiseArray = filterActivityList.map((item) => {
|
|
201
|
-
return request.send(activity.getActivityDetail({ activityNo: item.activityNo, appSecret }))
|
|
202
|
-
})
|
|
203
|
-
const activitiesDetail = await Promise.all(promiseArray)
|
|
204
|
-
return activitiesDetail
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
}
|
|
208
|
-
)
|
|
209
|
-
}
|