@jetthai/cuora 1.1.439-dev.2 → 1.1.439-dev.5

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.439-dev.5](https://github.com/jetthai/cuora-module/compare/v1.1.439-dev.4...v1.1.439-dev.5) (2026-05-29)
6
+
7
+ ### [1.1.439-dev.4](https://github.com/jetthai/cuora-module/compare/v1.1.439-dev.3...v1.1.439-dev.4) (2026-05-29)
8
+
9
+ ### [1.1.439-dev.3](https://github.com/jetthai/cuora-module/compare/v1.1.439-dev.2...v1.1.439-dev.3) (2026-05-29)
10
+
5
11
  ### [1.1.439-dev.2](https://github.com/jetthai/cuora-module/compare/v1.1.439-dev.1...v1.1.439-dev.2) (2026-05-27)
6
12
 
7
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.439-dev.2",
3
+ "version": "1.1.439-dev.5",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -125,4 +125,14 @@ export default {
125
125
  method: 'get',
126
126
  params: { activityNo, appSecret },
127
127
  }),
128
+ getProgressSummary: ({ appSecret }) => ({
129
+ url: 'activities/progress-summary',
130
+ method: 'get',
131
+ params: { appSecret },
132
+ }),
133
+ getProgressDetail: ({ appSecret }) => ({
134
+ url: 'activities/progress-details',
135
+ method: 'get',
136
+ params: { appSecret },
137
+ }),
128
138
  }
@@ -11,6 +11,7 @@ export default function (request) {
11
11
  context: {
12
12
  tick: 2000,
13
13
  activityList: [],
14
+ progressSummary: {},
14
15
  tournamentList: [],
15
16
  promotionList: [],
16
17
  uidSite: '',
@@ -24,7 +25,7 @@ export default function (request) {
24
25
  src: 'fetchList',
25
26
  onDone: {
26
27
  target: 'checking',
27
- actions: ['setActivityList', 'setTournamentList', 'setPromotionList'],
28
+ actions: ['setActivityList', 'setTournamentList', 'setPromotionList', 'setProgressSummary'],
28
29
  },
29
30
  onError: {
30
31
  target: 'pending',
@@ -96,6 +97,12 @@ export default function (request) {
96
97
  activityList: list,
97
98
  }
98
99
  }),
100
+ setProgressSummary: assign((context, event) => {
101
+ const { progressSummary } = event.data
102
+ return {
103
+ progressSummary: progressSummary || null,
104
+ }
105
+ }),
99
106
  setPromotionList: assign((context, event) => {
100
107
  const { promotionList } = event.data
101
108
  return {
@@ -154,12 +161,20 @@ export default function (request) {
154
161
  services: {
155
162
  fetchList: async (context, event) => {
156
163
  const hasToken = request.getToken()
157
- const [{ data }, promotionList] = await Promise.all([
164
+ const siteConfig = window?.$nuxt?.$store?.state?.siteConfig
165
+ const isProgressEnable = siteConfig?.frontendActivityProgressEnable
166
+
167
+ const [{ data }, promotionList, progressSummaryRes] = await Promise.all([
158
168
  hasToken ? request.send(activity.getActivityList({ appSecret })) : request.send(activity.getAllActivityList({ appSecret })),
159
169
  hasToken ? request.send(payment.getPromotionsList()) : [],
170
+ hasToken && isProgressEnable ? request.send(activity.getProgressSummary({ appSecret })).catch(() => null) : null,
160
171
  ])
161
172
 
162
- return { activityList: data, promotionList }
173
+ return {
174
+ activityList: data,
175
+ promotionList,
176
+ progressSummary: progressSummaryRes?.data || null,
177
+ }
163
178
  },
164
179
  fetchActivityDetailList: async (context, event) => {
165
180
  await new Promise((resolve) => setTimeout(resolve, 1000)) // delay 1 second
@@ -5,7 +5,7 @@ import api from '../api/common.js'
5
5
  import storage from '../util/storage.js'
6
6
 
7
7
  export default function (request) {
8
- const { appSecret, defaultChannel, defaultSubchannel } = request.config
8
+ const { appSecret } = request.config
9
9
  return createMachine(
10
10
  {
11
11
  id: 'common',
@@ -35,8 +35,6 @@ export default function (request) {
35
35
  promotions: [],
36
36
  normalBroadcast: null,
37
37
  sentNormalBroadcastList: [],
38
- channel: null,
39
- subchannel: null,
40
38
  affiliateCode: null,
41
39
  defaultAffiliateCode: null,
42
40
  friendCode: null,
@@ -284,19 +282,9 @@ export default function (request) {
284
282
  return
285
283
  } else {
286
284
  let urlParams = new URLSearchParams(window.location.search)
287
- const channel = urlParams.get('channel') || storage.get('channel') || defaultChannel || 'official'
288
- const subchannel = urlParams.get('subchannel') || storage.get('subchannel') || defaultSubchannel || 'pwa'
289
285
  const affiliateCode = urlParams.get('ac') || urlParams.get('referralCode') || storage.get('ac') || storage.get('referralCode')
290
286
  const friendCode = urlParams.get('fc') || urlParams.get('affiliate') || storage.get('fc') || storage.get('affiliate')
291
287
 
292
- storage.set('channel', channel, {
293
- path: '/',
294
- maxAge: 60 * 60 * 24 * 7,
295
- })
296
- storage.set('subchannel', subchannel, {
297
- path: '/',
298
- maxAge: 60 * 60 * 24 * 7,
299
- })
300
288
  storage.set('ac', affiliateCode, {
301
289
  path: '/',
302
290
  maxAge: 60 * 60 * 24 * 7,
@@ -307,8 +295,6 @@ export default function (request) {
307
295
  })
308
296
 
309
297
  return {
310
- channel,
311
- subchannel,
312
298
  affiliateCode,
313
299
  friendCode,
314
300
  }
@@ -1,19 +1,27 @@
1
1
  import { createMachine, assign } from 'xstate'
2
2
  import ranking from '../api/ranking.js'
3
3
 
4
+ const ROUND_LIMIT = { DAILY: 56, WEEKLY: 8, MONTHLY: 2, ALL: 2 }
5
+ const ONE_DAY_MS = 24 * 60 * 60 * 1000
6
+
7
+ // 後端每個 cycle 只回傳「當前回合」一筆,前台依當前回合往前回填歷史回合
8
+ // 回合長度 = 當期長度(endDate - beginDate)+ 1 天,回合之間連續無間隔
9
+ function expandPeriodOption(option, cycle) {
10
+ if (!option) return []
11
+ const { round, beginDate, endDate } = option
12
+ const step = endDate - beginDate + ONE_DAY_MS
13
+ const count = Math.min(ROUND_LIMIT[cycle] || round, round)
14
+ // 降冪排列,當前回合在最前
15
+ return Array.from({ length: count }, (_, i) => ({
16
+ round: round - i,
17
+ beginDate: beginDate - i * step,
18
+ endDate: endDate - i * step,
19
+ }))
20
+ }
21
+
4
22
  export default function (request) {
5
23
  const { appSecret } = request.config
6
24
  const cycleMapping = ['DAILY', 'WEEKLY', 'MONTHLY']
7
- const limit = { DAILY: 56, WEEKLY: 8, MONTHLY: 2, ALL: 2 }
8
-
9
- function roundProcess(rounds, cycles) {
10
- const roundArrays = rounds.map((round) => Array.from({ length: round }, (_, i) => i + 1))
11
- return roundArrays.reduce((acc, roundArray, index) => {
12
- const max = limit[cycles[index]] || rounds[index] // 若沒限制則取全部
13
- acc[cycles[index]] = roundArray.reverse().slice(0, max)
14
- return acc
15
- }, {})
16
- }
17
25
 
18
26
  function transGameData(item) {
19
27
  if (!item) return {}
@@ -30,7 +38,6 @@ export default function (request) {
30
38
  site: '',
31
39
  activityNo: '',
32
40
  // api options 回傳的資料
33
- currentRound: [],
34
41
  cycle: '',
35
42
  round: 0,
36
43
  rule: '',
@@ -42,7 +49,7 @@ export default function (request) {
42
49
  gameRanking: [],
43
50
  topRanking: [],
44
51
  settleStatus: false,
45
- // 前端這邊用的選單資料 { cycle, round }
52
+ // 前端這邊用的選單資料 { cycle: [string], round: { [cycle]: [{ round, beginDate, endDate }] } }
46
53
  options: {},
47
54
  },
48
55
  states: {
@@ -156,31 +163,41 @@ export default function (request) {
156
163
  setRankingOptions: assign((context, event) => {
157
164
  const isChampion = event.data?.rule === 'CHAMPION'
158
165
  const cycle = event.data?.cycle
159
- const currentRound = event.data?.currentRound || []
160
- // 取得結算週期選單列表
161
- const cycleOptions = isChampion ? cycleMapping.slice(0, currentRound.length) : [cycle]
162
- const roundOptions = roundProcess(currentRound, cycleOptions)
166
+ const periodOptions = event.data?.periodOptions || []
167
+ // 每個 cycle 對應一筆「當前回合」
168
+ const optionByCycle = periodOptions.reduce((acc, option) => {
169
+ acc[option.cycle] = option
170
+ return acc
171
+ }, {})
172
+ // 依照 cycleMapping 順序取出有資料的 cycle
173
+ const cycleOptions = isChampion ? cycleMapping.filter((c) => optionByCycle[c]) : [cycle]
174
+ // 將每個 cycle 的當前回合往前回填為完整回合列表 { [cycle]: [{ round, beginDate, endDate }] }
175
+ const roundOptions = cycleOptions.reduce((acc, c) => {
176
+ acc[c] = expandPeriodOption(optionByCycle[c], c)
177
+ return acc
178
+ }, {})
163
179
  // 如果是冠軍龍虎月結算,則加入全部選項
164
180
  if (cycle === 'MONTHLY' && isChampion) {
165
181
  cycleOptions.push('ALL')
166
- roundOptions.ALL = roundOptions.MONTHLY
182
+ roundOptions.ALL = expandPeriodOption(optionByCycle.MONTHLY, 'ALL')
167
183
  }
184
+ // 初始 cycle 與 round
185
+ const initialCycle = isChampion ? 'DAILY' : cycle
186
+ const initialRound = roundOptions[initialCycle]?.[0]?.round
168
187
  return {
169
188
  ...event.data,
170
189
  options: { cycle: cycleOptions, round: roundOptions },
171
- // 初始固定顯示 DAILY
172
- cycle: isChampion ? 'DAILY' : cycle,
173
- round: currentRound[0],
190
+ cycle: initialCycle,
191
+ round: initialRound,
174
192
  }
175
193
  }),
176
194
  setOptions: assign((context, event) => {
177
- const { cycle, round } = context
195
+ const { cycle, round, options } = context
178
196
  // 處理變更 cycle,如果沒有輸入或沒有變更就不更新
179
197
  if (event.data?.cycle && cycle !== event.data?.cycle) {
180
- const { currentRound } = context
181
- const cycleForRound = event.data?.cycle === 'ALL' ? 'MONTHLY' : event.data?.cycle
182
- const cycleIndex = cycleMapping.indexOf(cycleForRound)
183
- return { cycle: event.data?.cycle, round: currentRound[cycleIndex] }
198
+ const newCycle = event.data?.cycle
199
+ const newRound = options?.round?.[newCycle]?.[0]?.round
200
+ return { cycle: newCycle, round: newRound }
184
201
  }
185
202
  if (event.data?.round && round !== event.data?.round) {
186
203
  return { round: event.data?.round }