@jetthai/cuora 1.1.341-rank-5 → 1.1.341

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,16 +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.1.341-rank-5](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-4...v1.1.341-rank-5) (2025-03-13)
6
-
7
- ### [1.1.341-rank-4](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-3...v1.1.341-rank-4) (2025-03-12)
8
-
9
- ### [1.1.341-rank-3](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-2...v1.1.341-rank-3) (2025-03-10)
10
-
11
- ### [1.1.341-rank-2](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-1...v1.1.341-rank-2) (2025-03-06)
12
-
13
- ### [1.1.341-rank-1](https://github.com/jetthai/cuora-module/compare/v1.1.341...v1.1.341-rank-1) (2025-03-05)
14
-
15
5
  ### [1.1.341](https://github.com/jetthai/cuora-module/compare/v1.1.340...v1.1.341) (2025-02-25)
16
6
 
17
7
  ### [1.1.338-perf-1](https://github.com/jetthai/cuora-module/compare/v1.1.338...v1.1.338-perf-1) (2025-02-12)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.341-rank-5",
3
+ "version": "1.1.341",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
package/src/api/index.js CHANGED
@@ -6,6 +6,5 @@ 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'
10
9
 
11
- export default { activity, auth, common, game, mailbox, payment, user, form, ranking }
10
+ export default { activity, auth, common, game, mailbox, payment, user, form }
@@ -39,7 +39,6 @@ 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 dragon_tiger_ranking from './dragon_tiger_ranking.js'
43
42
 
44
43
  export default {
45
44
  ...activity,
@@ -83,5 +82,4 @@ export default {
83
82
  navbar,
84
83
  ...withdraw,
85
84
  websocket,
86
- dragon_tiger_ranking,
87
85
  }
@@ -1,26 +0,0 @@
1
- export default {
2
- // 未登入排名資料
3
- getTournament: ({ activityNo }) => ({
4
- url: 'tournament/detail',
5
- method: 'get',
6
- params: { activityNo },
7
- isPublic: true,
8
- }),
9
- // 登入後排名預設期數資料
10
- getRankingOptions: ({ activityNo }) => ({
11
- url: 'ranking/detail/option',
12
- method: 'get',
13
- params: { activityNo },
14
- }),
15
- // 登入後排名資料
16
- getRankingDetail: ({ activityNo, cycle, round }) => ({
17
- url: 'ranking/detail',
18
- method: 'post',
19
- params: { activityNo, cycle, round },
20
- }),
21
- getRankingGames: ({ activityNo }) => ({
22
- url: 'hot-game/ranking',
23
- method: 'get',
24
- params: { activityNo },
25
- }),
26
- }
@@ -1,200 +0,0 @@
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: 'dragon_tiger_ranking',
24
- initial: 'idle',
25
- context: {
26
- auth: false,
27
- activityNo: '',
28
- // api options 回傳的資料
29
- currentRound: [],
30
- cycle: '',
31
- round: 0,
32
- rule: '',
33
- // api detail 資料
34
- description: '',
35
- descriptionUrl: [],
36
- // api detail 排名資料
37
- playerRanking: {},
38
- gameRanking: [],
39
- topRanking: [],
40
- // 前端這邊用的選單資料 { cycle, round }
41
- options: {},
42
- },
43
- states: {
44
- idle: {
45
- on: {
46
- SET_ACTIVITY: {
47
- target: 'loading',
48
- },
49
- SET_OPTIONS: {
50
- target: 'setting',
51
- },
52
- },
53
- },
54
- loading: {
55
- entry: 'setActivity',
56
- always: [{ target: 'getRankingOptions', cond: 'hasAuth' }, { target: 'getTournament' }],
57
- },
58
- setting: {
59
- entry: 'setOptions',
60
- always: [{ target: 'getRankingDetail' }],
61
- },
62
- // 未登入時取得排名資料
63
- getTournament: {
64
- invoke: {
65
- src: 'fetchTournament',
66
- onDone: {
67
- target: 'idle',
68
- actions: 'setRanking',
69
- },
70
- onError: {
71
- target: 'idle',
72
- },
73
- },
74
- },
75
- // 登入後取得排名選單資料
76
- getRankingOptions: {
77
- invoke: {
78
- src: 'fetchRankingOptions',
79
- onDone: {
80
- target: 'getRankingGames',
81
- actions: 'setRankingOptions',
82
- },
83
- onError: {
84
- target: 'idle',
85
- },
86
- },
87
- },
88
- // 登入後取得排名資料
89
- getRankingDetail: {
90
- invoke: {
91
- src: 'fetchRankingDetail',
92
- onDone: {
93
- target: 'idle',
94
- actions: 'setRanking',
95
- },
96
- onError: {
97
- target: 'idle',
98
- },
99
- },
100
- },
101
- getRankingGames: {
102
- invoke: {
103
- src: 'fetchRankingGames',
104
- onDone: {
105
- target: 'getRankingDetail',
106
- actions: 'setRankingGames',
107
- },
108
- onError: {
109
- target: 'idle',
110
- },
111
- },
112
- },
113
- },
114
- },
115
- {
116
- actions: {
117
- setActivity: assign((context, event) => {
118
- return {
119
- auth: !!request.getToken(),
120
- activityNo: event.data?.activityNo,
121
- }
122
- }),
123
- setRanking: assign((context, event) => {
124
- const topRanking = event.data?.topRanking?.map((rank) => transGameData(rank))
125
- return {
126
- description: event.data?.description,
127
- descriptionUrl: event.data?.descriptionUrl,
128
- topRanking: topRanking || [],
129
- playerRanking: transGameData(event.data?.playerRanking) || {},
130
- }
131
- }),
132
- setRankingGames: assign((context, event) => {
133
- const gameRanking = event.data?.map((rank) => transGameData(rank))
134
- return {
135
- gameRanking: gameRanking || [],
136
- }
137
- }),
138
- setRankingOptions: assign((context, event) => {
139
- const cycle = event.data?.cycle
140
- const currentRound = event.data?.currentRound || []
141
- // 取得結算週期選單列表
142
- const cycleOptions = cycleMapping.slice(0, currentRound.length)
143
- // 取得每週期的歷史期數選單列表
144
- const roundOptions = roundProcess(currentRound)
145
- // 如果是月結算,則加入全部選項
146
- if (cycle === 'MONTHLY') {
147
- cycleOptions.push('ALL')
148
- roundOptions.ALL = roundOptions.MONTHLY
149
- }
150
- return {
151
- ...event.data,
152
- options: { cycle: cycleOptions, round: roundOptions },
153
- // 初始固定顯示 DAILY
154
- cycle: event.data?.rule !== 'NORMAL' ? 'DAILY' : cycle,
155
- round: currentRound[0],
156
- }
157
- }),
158
- setOptions: assign((context, event) => {
159
- const { cycle, round } = context
160
- // 處理變更 cycle,如果沒有輸入或沒有變更就不更新
161
- if (event.data?.cycle && cycle !== event.data?.cycle) {
162
- const { currentRound } = context
163
- const cycleForRound = event.data?.cycle === 'ALL' ? 'MONTHLY' : event.data?.cycle
164
- const cycleIndex = cycleMapping.indexOf(cycleForRound)
165
- return { cycle: event.data?.cycle, round: currentRound[cycleIndex] }
166
- }
167
- if (event.data?.round && round !== event.data?.round) {
168
- return { round: event.data?.round }
169
- }
170
- return {}
171
- }),
172
- },
173
- guards: {
174
- hasAuth: (context) => context.auth,
175
- },
176
- services: {
177
- fetchTournament: async (context) => {
178
- const { activityNo } = context
179
- const { data } = await request.send(ranking.getTournament({ activityNo }))
180
- return data
181
- },
182
- fetchRankingOptions: async (context) => {
183
- const { activityNo } = context
184
- const { data } = await request.send(ranking.getRankingOptions({ activityNo }))
185
- return data
186
- },
187
- fetchRankingDetail: async (context, event) => {
188
- const { activityNo, cycle, round } = context
189
- const { data } = await request.send(ranking.getRankingDetail({ activityNo, cycle, round }))
190
- return data
191
- },
192
- fetchRankingGames: async (context) => {
193
- const { activityNo } = context
194
- const { data } = await request.send(ranking.getRankingGames({ activityNo }))
195
- return data
196
- },
197
- },
198
- }
199
- )
200
- }