@jetthai/cuora 1.1.354 → 1.1.355-apiv2-1

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 CHANGED
@@ -2,6 +2,12 @@
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.355-apiv2-1](https://github.com/jetthai/cuora-module/compare/v1.1.355...v1.1.355-apiv2-1) (2025-05-05)
6
+
7
+ ### [1.1.355](https://github.com/jetthai/cuora-module/compare/v1.1.353-data-1...v1.1.355) (2025-04-22)
8
+
9
+ ### [1.1.354](https://github.com/jetthai/cuora-module/compare/v1.1.353...v1.1.354) (2025-04-14)
10
+
5
11
  ### [1.1.354](https://github.com/jetthai/cuora-module/compare/v1.1.353...v1.1.354) (2025-04-14)
6
12
 
7
13
  ### [1.1.353](https://github.com/jetthai/cuora-module/compare/v1.1.352...v1.1.353) (2025-04-02)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.354",
3
+ "version": "1.1.355-apiv2-1",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
package/src/api/index.js CHANGED
@@ -6,5 +6,6 @@ import mailbox from './mailbox.js'
6
6
  import payment from './payment.js'
7
7
  import user from './user.js'
8
8
  import form from './form.js'
9
+ import ranking from './ranking.js'
9
10
 
10
- export default { activity, auth, common, game, mailbox, payment, user, form }
11
+ export default { activity, auth, common, game, mailbox, payment, user, form, ranking }
@@ -0,0 +1,27 @@
1
+ export default {
2
+ // 未登入排名資料
3
+ getTournament: ({ activityNo, cycle, round, site }) => ({
4
+ url: 'tournament/detail',
5
+ method: 'post',
6
+ params: { activityNo, cycle, round, site },
7
+ isPublic: true,
8
+ }),
9
+ // 登入後排名預設期數資料
10
+ getRankingOptions: ({ activityNo }) => ({
11
+ url: 'ranking/detail/option',
12
+ method: 'get',
13
+ params: { activityNo },
14
+ isPublic: true,
15
+ }),
16
+ // 登入後排名資料
17
+ getRankingDetail: ({ activityNo, cycle, round }) => ({
18
+ url: 'ranking/detail',
19
+ method: 'post',
20
+ params: { activityNo, cycle, round },
21
+ }),
22
+ getRankingGames: ({ activityNo }) => ({
23
+ url: 'hot-game/ranking',
24
+ method: 'get',
25
+ params: { activityNo },
26
+ }),
27
+ }
@@ -77,10 +77,6 @@ export default function (request) {
77
77
  SET_UNREAD: {
78
78
  actions: 'setUnread',
79
79
  },
80
- REFRESH: {
81
- target: '#activity.fetchingList',
82
- actions: 'leaveGame',
83
- },
84
80
  RESET_ACTIVITIES: {
85
81
  actions: 'resetActivities',
86
82
  },
@@ -89,6 +85,12 @@ export default function (request) {
89
85
  },
90
86
  },
91
87
  },
88
+ on: {
89
+ REFRESH: {
90
+ target: '#activity.fetchingList',
91
+ actions: 'leaveGame',
92
+ },
93
+ },
92
94
  },
93
95
  {
94
96
  actions: {
@@ -11,17 +11,19 @@ export default function (request) {
11
11
  activityDetail: null,
12
12
  conditions: null,
13
13
  rebateType: null,
14
- currentReachLevel: null,
15
- nextReachLevel: null,
16
- lastPeriod: null,
14
+ nextCycleCardCurrentReachLevel: null,
15
+ nextCycleCardNextReachLevel: null,
16
+ lastCycleCard: null,
17
17
  nextDepositLimit: null,
18
18
  nextTurnoverLimit: null,
19
- currentTotalDeposit: null,
20
- currentTotalTurnover: null,
19
+ accumulateTotalDeposit: null,
20
+ accumulateTotalValidTurnover: null,
21
21
  retainAmount: '0',
22
- yesterdayReward: '0',
22
+ yesterdayRewardsAmount: '0',
23
23
  calculateWalletMode: '1',
24
24
  duration: 0,
25
+ isAccumulationPeriod: false, // 當前是否為累積期
26
+ isAwardPeriod: false, // 當前是否為領獎期
25
27
  },
26
28
  initial: 'idle',
27
29
  states: {
@@ -31,6 +33,10 @@ export default function (request) {
31
33
  target: 'loading',
32
34
  actions: 'setActivityNo',
33
35
  },
36
+ SET_ACTIVITY: {
37
+ target: 'loading',
38
+ actions: 'setActivity',
39
+ },
34
40
  },
35
41
  },
36
42
  loading: {
@@ -45,6 +51,17 @@ export default function (request) {
45
51
  },
46
52
  },
47
53
  },
54
+ sentAward: {
55
+ invoke: {
56
+ src: 'sentAward',
57
+ onDone: {
58
+ target: 'loading',
59
+ },
60
+ onError: {
61
+ target: 'loaded',
62
+ },
63
+ },
64
+ },
48
65
  loaded: {
49
66
  entry: 'setDuration',
50
67
  after: {
@@ -61,6 +78,9 @@ export default function (request) {
61
78
  STOP: {
62
79
  target: '.idle',
63
80
  },
81
+ SENT_AWARD: {
82
+ target: '.sentAward',
83
+ },
64
84
  },
65
85
  },
66
86
  {
@@ -71,58 +91,80 @@ export default function (request) {
71
91
  }
72
92
  }),
73
93
  setActivityDetail: assign((context, event) => {
94
+ let activityDetail = event.data
95
+ if (context.activityDetail && (!event.data || Object.keys(event.data).length === 0)) {
96
+ activityDetail = context.activityDetail
97
+ }
98
+ return {
99
+ activityDetail,
100
+ }
101
+ }),
102
+ setActivity: assign((context, event) => {
74
103
  return {
75
- activityDetail: event.data,
104
+ activityDetail: event.data.activityDetail,
105
+ activityNo: event.data.activityNo,
76
106
  }
77
107
  }),
78
108
  setInitData: assign((context, event) => {
79
109
  const {
80
110
  rebateType,
81
111
  conditions = [],
82
- currentReachLevel = {},
83
- nextReachLevel = {},
84
- lastPeriod = {},
85
- currentTotalDeposit = '0',
86
- currentTotalTurnover = '0',
112
+ nextCycleCardCurrentReachLevel = {},
113
+ nextCycleCardNextReachLevel = {},
114
+ lastCycleCard = {},
115
+ accumulateTotalDeposit = '0',
116
+ accumulateTotalValidTurnover = '0',
87
117
  retainAmount = '0',
88
- yesterdayReward = '0',
118
+ yesterdayRewardsAmount = '0',
89
119
  calculateWalletMode = '0',
120
+ accumulateStartTime,
121
+ accumulateEndTime,
122
+ lastCycleCardStartTime,
123
+ lastCycleCardEndTime,
90
124
  } = context.activityDetail || {}
91
125
 
92
126
  let nextDepositLimit = '0'
93
127
  let nextTurnoverLimit = '0'
94
- let currentTurnover = '0'
95
- let currentDeposit = '0'
128
+ const maxReachLevel = conditions?.[conditions?.length - 1]
96
129
  // 若已達到最高等級,所有數值皆以最高等級顯示
97
- if (currentReachLevel?.title === conditions?.[conditions?.length - 1]?.title) {
98
- currentDeposit = conditions[conditions.length - 1].depositLimit
99
- currentTurnover = conditions[conditions.length - 1].turnoverLimit
100
- nextDepositLimit = conditions[conditions.length - 1].depositLimit
101
- nextTurnoverLimit = conditions[conditions.length - 1].turnoverLimit
130
+ if (maxReachLevel && nextCycleCardCurrentReachLevel?.title === maxReachLevel.title) {
131
+ nextDepositLimit = maxReachLevel.depositLimit
132
+ nextTurnoverLimit = maxReachLevel.turnoverLimit
102
133
  } else {
103
- currentDeposit = currentTotalDeposit
104
- currentTurnover = currentTotalTurnover
105
- nextDepositLimit = nextReachLevel?.depositLimit
106
- nextTurnoverLimit = nextReachLevel?.turnoverLimit
134
+ nextDepositLimit = nextCycleCardNextReachLevel?.depositLimit
135
+ nextTurnoverLimit = nextCycleCardNextReachLevel?.turnoverLimit
107
136
  }
137
+ // 計算當前是否為累積期及領獎期
138
+ const currentTime = new Date().getTime() / 1000
139
+ const isAccumulationPeriod = currentTime >= accumulateStartTime && currentTime <= accumulateEndTime
140
+ const isAwardPeriod = currentTime >= lastCycleCardStartTime && currentTime <= lastCycleCardEndTime
108
141
 
109
142
  return {
110
143
  rebateType,
111
144
  conditions,
112
- currentReachLevel,
113
- nextReachLevel,
114
- lastPeriod,
145
+ nextCycleCardCurrentReachLevel,
146
+ nextCycleCardNextReachLevel,
147
+ lastCycleCard,
115
148
  nextDepositLimit,
116
149
  nextTurnoverLimit,
117
- currentTotalDeposit: currentDeposit,
118
- currentTotalTurnover: currentTurnover,
150
+ accumulateTotalDeposit,
151
+ accumulateTotalValidTurnover,
119
152
  retainAmount,
120
- yesterdayReward,
153
+ yesterdayRewardsAmount,
121
154
  calculateWalletMode,
155
+ isAccumulationPeriod,
156
+ isAwardPeriod,
122
157
  }
123
158
  }),
124
159
  setDuration: assign((context, event) => {
125
- const { currentEndTime } = context?.activityDetail
160
+ const { rewardPeriodSameAsAccumulationPeriod, accumulateEndTime, lastCycleCardEndTime } = context?.activityDetail
161
+ const { isAwardPeriod } = context
162
+ // 若為累積期,則倒數時間以累積期結束時間計算
163
+ let currentEndTime = accumulateEndTime
164
+ // 若為領獎期,則倒數時間以領獎期結束時間計算
165
+ if (!rewardPeriodSameAsAccumulationPeriod && isAwardPeriod) {
166
+ currentEndTime = lastCycleCardEndTime
167
+ }
126
168
  return {
127
169
  duration: Math.max(parseInt(currentEndTime) - new Date().getTime() / 1000, 0),
128
170
  }
@@ -134,6 +176,11 @@ export default function (request) {
134
176
  const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }))
135
177
  return data
136
178
  },
179
+ sentAward: async (context, event) => {
180
+ const { activityNo } = context
181
+ const { data } = await request.send(api.sentAward({ activityNo, appSecret }))
182
+ return data
183
+ },
137
184
  },
138
185
  }
139
186
  )
@@ -113,6 +113,7 @@ export default function (request) {
113
113
  actions: 'resetByEnterGame',
114
114
  },
115
115
  LEAVE_GAME_REFRESH: {
116
+ target: '.updating',
116
117
  actions: 'leaveGame',
117
118
  },
118
119
  },
@@ -292,7 +293,8 @@ export default function (request) {
292
293
  return { announcementList: { data } }
293
294
  }),
294
295
  setFeeds: assign((context, event) => {
295
- const { announcementList, broadcastList, mailBoxInfo, siteConfig } = event.data
296
+ const { announcementList, broadcastList, mailBoxInfo } = event.data
297
+ const { siteConfig } = context
296
298
  const promotions = announcementList?.announcements?.filter?.((item) => item.category === 3) || []
297
299
  const customerMessageEnable = siteConfig?.csChat?.some((item) => item.enable && item.name === 'customermessage')
298
300
  if (!customerMessageEnable) {
@@ -205,9 +205,6 @@ export default function (request) {
205
205
  ENTER_GAME_PAUSE: {
206
206
  actions: ['setIsPlaying', 'resetContent', 'resetSHA'],
207
207
  },
208
- LEAVE_GAME_REFRESH: {
209
- actions: 'setIsPlaying',
210
- },
211
208
  },
212
209
  },
213
210
  refreshing: {
@@ -243,9 +240,6 @@ export default function (request) {
243
240
  },
244
241
  },
245
242
  on: {
246
- LEAVE_GAME_REFRESH: {
247
- actions: 'setIsPlaying',
248
- },
249
243
  LOAD: {
250
244
  target: 'routing',
251
245
  actions: 'setLoadable',
@@ -292,6 +286,11 @@ export default function (request) {
292
286
  },
293
287
  },
294
288
  },
289
+ on: {
290
+ LEAVE_GAME_REFRESH: {
291
+ actions: 'setIsPlaying',
292
+ },
293
+ },
295
294
  },
296
295
  {
297
296
  actions: {
@@ -39,6 +39,7 @@ import honor_board from './honor_board.js'
39
39
  import user_photo from './user_photo.js'
40
40
  import navbar from './navbar.js'
41
41
  import websocket from './websocket.js'
42
+ import ranking from './ranking.js'
42
43
 
43
44
  export default {
44
45
  ...activity,
@@ -82,4 +83,5 @@ export default {
82
83
  navbar,
83
84
  ...withdraw,
84
85
  websocket,
86
+ ranking,
85
87
  }
@@ -0,0 +1,216 @@
1
+ import { createMachine, assign } from 'xstate'
2
+ import ranking from '../api/ranking.js'
3
+
4
+ export default function (request) {
5
+ const cycleMapping = ['DAILY', 'WEEKLY', 'MONTHLY']
6
+
7
+ function roundProcess(rounds) {
8
+ const roundArrays = rounds.map((round) => Array.from({ length: round }, (_, i) => i + 1))
9
+ return roundArrays.reduce((acc, roundArray, index) => {
10
+ acc[cycleMapping[index]] = roundArray.reverse()
11
+ return acc
12
+ }, {})
13
+ }
14
+
15
+ function transGameData(item) {
16
+ if (!item) return {}
17
+ item.providerId = item.provider
18
+ return item
19
+ }
20
+
21
+ return createMachine(
22
+ {
23
+ id: 'ranking',
24
+ initial: 'idle',
25
+ context: {
26
+ auth: false,
27
+ site: '',
28
+ activityNo: '',
29
+ // api options 回傳的資料
30
+ currentRound: [],
31
+ cycle: '',
32
+ round: 0,
33
+ rule: '',
34
+ // api detail 資料
35
+ description: '',
36
+ descriptionUrl: [],
37
+ // api detail 排名資料
38
+ playerRanking: {},
39
+ gameRanking: [],
40
+ topRanking: [],
41
+ settleStatus: false,
42
+ // 前端這邊用的選單資料 { cycle, round }
43
+ options: {},
44
+ },
45
+ states: {
46
+ idle: {
47
+ on: {
48
+ SET_ACTIVITY: {
49
+ target: 'loading',
50
+ },
51
+ SET_OPTIONS: {
52
+ target: 'setting',
53
+ },
54
+ },
55
+ },
56
+ loading: {
57
+ entry: 'setActivity',
58
+ always: [{ target: 'getRankingOptions' }],
59
+ },
60
+ setting: {
61
+ entry: 'setOptions',
62
+ always: [{ target: 'getRankingDetail', cond: 'hasAuth' }, { target: 'getTournament' }],
63
+ },
64
+ // 取得排名選單資料
65
+ getRankingOptions: {
66
+ invoke: {
67
+ src: 'fetchRankingOptions',
68
+ onDone: {
69
+ target: 'decideNextAfterOptions',
70
+ actions: 'setRankingOptions',
71
+ },
72
+ onError: {
73
+ target: 'idle',
74
+ },
75
+ },
76
+ },
77
+ // 取得排名選單資料後的跳轉
78
+ decideNextAfterOptions: {
79
+ always: [
80
+ // 有登入且為冠軍: 先拿遊戲排行榜再拿排行榜資料
81
+ { target: 'getRankingGames', cond: 'canGetGameRanking' },
82
+ // 有登入但不為冠軍活動: 直接拿排行榜資料
83
+ { target: 'getRankingDetail', cond: 'hasAuth' },
84
+ // 未登入; 拿未登入的排行榜資料
85
+ { target: 'getTournament' },
86
+ ],
87
+ },
88
+ // 未登入時取得排名資料
89
+ getTournament: {
90
+ invoke: {
91
+ src: 'fetchTournament',
92
+ onDone: {
93
+ target: 'idle',
94
+ actions: 'setRanking',
95
+ },
96
+ onError: {
97
+ target: 'idle',
98
+ },
99
+ },
100
+ },
101
+ // 登入後取得排名資料
102
+ getRankingDetail: {
103
+ invoke: {
104
+ src: 'fetchRankingDetail',
105
+ onDone: {
106
+ target: 'idle',
107
+ actions: 'setRanking',
108
+ },
109
+ onError: {
110
+ target: 'idle',
111
+ },
112
+ },
113
+ },
114
+ getRankingGames: {
115
+ invoke: {
116
+ src: 'fetchRankingGames',
117
+ onDone: {
118
+ target: 'getRankingDetail',
119
+ actions: 'setRankingGames',
120
+ },
121
+ onError: {
122
+ target: 'idle',
123
+ },
124
+ },
125
+ },
126
+ },
127
+ },
128
+ {
129
+ actions: {
130
+ setActivity: assign((context, event) => {
131
+ return {
132
+ site: event.data?.site,
133
+ auth: !!request.getToken(),
134
+ activityNo: event.data?.activityNo,
135
+ }
136
+ }),
137
+ setRanking: assign((context, event) => {
138
+ const topRanking = event.data?.topRanking?.map((rank) => transGameData(rank)) || []
139
+ return {
140
+ description: event.data?.description,
141
+ descriptionUrl: event.data?.descriptionUrl,
142
+ topRanking: topRanking,
143
+ playerRanking: transGameData(event.data?.playerRanking) || {},
144
+ settleStatus: !!topRanking[0]?.settleStatus,
145
+ }
146
+ }),
147
+ setRankingGames: assign((context, event) => {
148
+ const gameRanking = event.data?.map((rank) => transGameData(rank))
149
+ return {
150
+ gameRanking: gameRanking || [],
151
+ }
152
+ }),
153
+ setRankingOptions: assign((context, event) => {
154
+ const cycle = event.data?.cycle
155
+ const currentRound = event.data?.currentRound || []
156
+ // 取得結算週期選單列表
157
+ const cycleOptions = cycleMapping.slice(0, currentRound.length)
158
+ // 取得每週期的歷史期數選單列表
159
+ const roundOptions = roundProcess(currentRound)
160
+ // 如果是月結算,則加入全部選項
161
+ if (cycle === 'MONTHLY') {
162
+ cycleOptions.push('ALL')
163
+ roundOptions.ALL = roundOptions.MONTHLY
164
+ }
165
+ return {
166
+ ...event.data,
167
+ options: { cycle: cycleOptions, round: roundOptions },
168
+ // 初始固定顯示 DAILY
169
+ cycle: event.data?.rule !== 'NORMAL' ? 'DAILY' : cycle,
170
+ round: currentRound[0],
171
+ }
172
+ }),
173
+ setOptions: assign((context, event) => {
174
+ const { cycle, round } = context
175
+ // 處理變更 cycle,如果沒有輸入或沒有變更就不更新
176
+ if (event.data?.cycle && cycle !== event.data?.cycle) {
177
+ const { currentRound } = context
178
+ const cycleForRound = event.data?.cycle === 'ALL' ? 'MONTHLY' : event.data?.cycle
179
+ const cycleIndex = cycleMapping.indexOf(cycleForRound)
180
+ return { cycle: event.data?.cycle, round: currentRound[cycleIndex] }
181
+ }
182
+ if (event.data?.round && round !== event.data?.round) {
183
+ return { round: event.data?.round }
184
+ }
185
+ return {}
186
+ }),
187
+ },
188
+ guards: {
189
+ hasAuth: (context) => context.auth,
190
+ canGetGameRanking: (context) => context.auth && context.rule === 'CHAMPION',
191
+ },
192
+ services: {
193
+ fetchTournament: async (context) => {
194
+ const { activityNo, cycle, round, site } = context
195
+ const { data } = await request.send(ranking.getTournament({ activityNo, cycle, round, site }))
196
+ return data
197
+ },
198
+ fetchRankingOptions: async (context) => {
199
+ const { activityNo } = context
200
+ const { data } = await request.send(ranking.getRankingOptions({ activityNo }))
201
+ return data
202
+ },
203
+ fetchRankingDetail: async (context, event) => {
204
+ const { activityNo, cycle, round } = context
205
+ const { data } = await request.send(ranking.getRankingDetail({ activityNo, cycle, round }))
206
+ return data
207
+ },
208
+ fetchRankingGames: async (context) => {
209
+ const { activityNo } = context
210
+ const { data } = await request.send(ranking.getRankingGames({ activityNo }))
211
+ return data
212
+ },
213
+ },
214
+ }
215
+ )
216
+ }
@@ -37,7 +37,7 @@ export default function (request) {
37
37
  },
38
38
  pending: {
39
39
  after: {
40
- 20000: { target: 'loading', cond: 'isNotInGame' },
40
+ 20000: [{ target: 'loading', cond: 'isNotInGame' }, { target: 'pending' }],
41
41
  },
42
42
  },
43
43
  },
@@ -16,7 +16,6 @@ export default function (request) {
16
16
  activityNo: null,
17
17
  receiveNo: null,
18
18
  withdrawRule: {},
19
- isPlaying: false,
20
19
  callback: () => {},
21
20
  },
22
21
  states: {
@@ -47,7 +46,7 @@ export default function (request) {
47
46
  },
48
47
  pending: {
49
48
  after: {
50
- 20000: [{ target: 'loading', cond: 'isNotInGame' }, { target: 'pending' }],
49
+ 20000: { target: 'loading' },
51
50
  },
52
51
  },
53
52
  },
@@ -74,9 +73,6 @@ export default function (request) {
74
73
  target: 'allPointsReceiving',
75
74
  actions: 'setCallback',
76
75
  },
77
- SET_IS_PLAYING: {
78
- actions: 'setIsPlaying',
79
- },
80
76
  },
81
77
  },
82
78
  fetching: {
@@ -147,11 +143,6 @@ export default function (request) {
147
143
  },
148
144
  },
149
145
  {
150
- guards: {
151
- isNotInGame: (context, event) => {
152
- return !context.isPlaying
153
- },
154
- },
155
146
  actions: {
156
147
  setAuth: assign((context, event) => {
157
148
  return { auth: !!event.data }
@@ -183,11 +174,6 @@ export default function (request) {
183
174
  withdrawRule: event.data,
184
175
  }
185
176
  }),
186
- setIsPlaying: assign((context, event) => {
187
- return {
188
- isPlaying: event.data,
189
- }
190
- }),
191
177
  },
192
178
  services: {
193
179
  fetchRewardList: async (context, event) => {
@@ -2,6 +2,54 @@ import pickBy from 'lodash/pickBy.js'
2
2
  import storage from '../util/storage.js'
3
3
 
4
4
  // const pickBy = require('lodash/pickBy')
5
+ const supportVersion2List = [
6
+ 'game/play',
7
+ 'game/gameReplay',
8
+ 'game/logout',
9
+ 'game/list/v3/root',
10
+ 'game/list/v3/category',
11
+ 'game/list/v3/addition',
12
+ 'game/list/v3/categoryByRange',
13
+ 'game/list/v3/additionByRange',
14
+ 'game/list/v3/myFavorite',
15
+ 'game/list/v3/addMyFavorite',
16
+ 'game/list/v3/removeMyFavorite',
17
+ 'login',
18
+ 'callback/:strategy',
19
+ 'guestLogin',
20
+ 'appLogin',
21
+ 'logout',
22
+ 'self',
23
+ 'register',
24
+ 'settings/password',
25
+ 'verify',
26
+ 'reset',
27
+ 'acknowledge',
28
+ 'friends',
29
+ 'friends/home',
30
+ 'friends/reward-list',
31
+ 'recovery',
32
+ 'recovery/abandon',
33
+ 'recovery/acknowledge',
34
+ 'checkDt',
35
+ 'updateDt',
36
+ 'checkAC',
37
+ 'checkAccount',
38
+ 'getAllAvatar',
39
+ 'updateUserAvatar',
40
+ 'getConfig',
41
+ 'getQuickLayout',
42
+ 'getNavbarSetting',
43
+ 'getAffiliateCode',
44
+ 'get-site-config',
45
+ 'friends/dashboard',
46
+ 'friends/dashboard/list',
47
+ 'mailbox/sendMessage',
48
+ 'mailbox/getMessageList',
49
+ 'mailbox/getMessage',
50
+ 'mailbox/updateMessage',
51
+ 'mailbox/getMessageTypes',
52
+ ]
5
53
 
6
54
  function isValid(value) {
7
55
  return value !== undefined && value !== null
@@ -24,7 +72,8 @@ export default class Request {
24
72
  axiosConfig.headers['X-TH1GAMES-VERSION'] = this.config.version
25
73
  axiosConfig.headers['X-TH1GAMES-PLATFORM'] = this.config.platform
26
74
  if (this.getToken()) {
27
- axiosConfig.headers.Authorization = this.getToken()
75
+ // 為了支援V2版本的API接口新增Bearer來進行身份驗證
76
+ axiosConfig.headers.Authorization = `Bearer ${this.getToken()}`
28
77
  }
29
78
  return axiosConfig
30
79
  })
@@ -85,9 +134,14 @@ export default class Request {
85
134
 
86
135
  _createConfig(req, cancelToken) {
87
136
  const { method, url, params, isPublic, isFormData, headers } = req
137
+ let fullURL = this.config.fullURL
138
+ if (supportVersion2List.includes(url)) {
139
+ console.log('*[DEV_ONLY]supportVersion2List:', url)
140
+ fullURL = fullURL.replace('/v1/', '/v2/')
141
+ }
88
142
  if (isFormData) {
89
143
  return {
90
- baseURL: this.config.fullURL,
144
+ baseURL: fullURL,
91
145
  method,
92
146
  url,
93
147
  cancelToken,
@@ -97,7 +151,7 @@ export default class Request {
97
151
  }
98
152
  } else {
99
153
  return {
100
- baseURL: this.config.fullURL,
154
+ baseURL: fullURL,
101
155
  method,
102
156
  url,
103
157
  cancelToken,