@jetthai/cuora 1.1.444-dev.2 → 1.1.444
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/auto-git-flow.md +12 -5
- package/.claude/commands/commit-push.md +4 -15
- package/.claude/commands/sync-ai-prompts.md +1 -88
- package/.claude/settings.local.json +1 -3
- package/.github/copilot-instructions.md +399 -551
- package/.husky/post-checkout +3 -3
- package/.husky/pre-push +1 -1
- package/.prettierignore +1 -2
- package/AGENTS.md +399 -551
- package/AI_PROMPT_SOURCE.md +130 -662
- package/CHANGELOG.md +22 -311
- package/CLAUDE.md +399 -551
- package/GEMINI.md +399 -551
- package/README.md +137 -40
- package/package.json +1 -1
- package/scripts/auto-version.js +0 -1
- package/scripts/clean-tags.sh +1 -26
- package/src/api/activity.js +0 -10
- package/src/api/common.js +1 -1
- package/src/machine/activity/activity_cash.js +3 -18
- package/src/machine/auth_otp_v3.js +4 -11
- package/src/machine/user_sign_up.js +4 -22
- package/src/request/request.js +8 -2
package/README.md
CHANGED
|
@@ -1,8 +1,34 @@
|
|
|
1
1
|
# @jetthai/cuora
|
|
2
2
|
|
|
3
|
-
ESM JavaScript
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
`@jetthai/cuora` 是一個純 ESM JavaScript 函式庫,無建置步驟,原始 `.js` 檔案直接發佈至 npm。透過 XState v4 狀態機整合 API 呼叫與業務邏輯,服務於線上遊戲平台,處理認證、支付(存款/提款)、遊戲管理、活動及即時 WebSocket 通訊。設計用於 Nuxt.js 客戶端應用程式(`ssr: false`)。
|
|
4
|
+
|
|
5
|
+
- **模組格式**:`"type": "module"`
|
|
6
|
+
- **進入點**:`./src/index.js`
|
|
7
|
+
- **無建置步驟**:無 Webpack/Rollup/TypeScript,無測試框架,無 Linter
|
|
8
|
+
- **程式碼格式化**:Prettier(不加分號、單引號、2 空格縮排、150 字元行寬、ES5 尾隨逗號)
|
|
9
|
+
- **Pre-commit Hook**:Husky 執行 `npm run format && git add .`
|
|
10
|
+
|
|
11
|
+
## 目錄
|
|
12
|
+
|
|
13
|
+
- [Installation](#installation)
|
|
14
|
+
- [Setup](#setup)
|
|
15
|
+
- [Usage](#usage)
|
|
16
|
+
- [模組匯出](#模組匯出)
|
|
17
|
+
- [Config](#config)
|
|
18
|
+
- [Request](#request)
|
|
19
|
+
- [API](#api)
|
|
20
|
+
- [Machine](#machine)
|
|
21
|
+
- [Utilities](#utilities)
|
|
22
|
+
- [Dependencies](#dependencies)
|
|
23
|
+
- [Architecture](#architecture)
|
|
24
|
+
- [Development](#development)
|
|
25
|
+
- [Git 分支版本發佈流程](#git-分支版本發佈流程)
|
|
26
|
+
- [分支策略](#分支策略)
|
|
27
|
+
- [腳本權責分離](#腳本權責分離)
|
|
28
|
+
- [dev / qa 分支自動版本流程](#dev--qa-分支自動版本流程)
|
|
29
|
+
- [版號計算規則](#版號計算規則)
|
|
30
|
+
- [Husky Hooks 總覽](#husky-hooks-總覽)
|
|
31
|
+
- [License](#license)
|
|
6
32
|
|
|
7
33
|
## Installation
|
|
8
34
|
|
|
@@ -30,6 +56,18 @@ export default {
|
|
|
30
56
|
import { api, machine, Request, Config, util, constant, storage } from '@jetthai/cuora'
|
|
31
57
|
```
|
|
32
58
|
|
|
59
|
+
### 模組匯出
|
|
60
|
+
|
|
61
|
+
| 匯出名稱 | 說明 |
|
|
62
|
+
| ---------- | ------------------------------------------------------- |
|
|
63
|
+
| `api` | 11 個 API 模組的聚合物件 |
|
|
64
|
+
| `machine` | 91 個 XState 狀態機工廠函式的聚合物件 |
|
|
65
|
+
| `Request` | Axios 封裝類別(攔截器、Token、版本控制) |
|
|
66
|
+
| `Config` | 設定類別(apiURL、clientId、appSecret 等) |
|
|
67
|
+
| `util` | 工具函式(`getDeviceToken`、`getDeviceTokenWithRetry`) |
|
|
68
|
+
| `constant` | 遊戲類型常數(16 種遊戲類型) |
|
|
69
|
+
| `storage` | localStorage 封裝(支援 TTL/過期) |
|
|
70
|
+
|
|
33
71
|
### Config
|
|
34
72
|
|
|
35
73
|
初始化 API 設定:
|
|
@@ -120,36 +158,35 @@ storage.set('key', value, ttl)
|
|
|
120
158
|
storage.get('key')
|
|
121
159
|
|
|
122
160
|
// 遊戲類型常數
|
|
123
|
-
constant.
|
|
124
|
-
constant.
|
|
125
|
-
constant.
|
|
126
|
-
constant.SPORT
|
|
161
|
+
constant.GAME_TYPE_LIST // 16 種遊戲類型陣列,每筆為 { typeId, name, gameTypeMappingId }
|
|
162
|
+
constant.MY_FAVORITE // 'MyFavorite'
|
|
163
|
+
constant.GAME_SEARCH // 'GameSearch'
|
|
127
164
|
```
|
|
128
165
|
|
|
166
|
+
## Dependencies
|
|
167
|
+
|
|
168
|
+
| 套件 | 版本 | 角色 | 使用位置 |
|
|
169
|
+
| ------------------ | ---------- | ---------------------------------------------------------------------------------- | ---------------------- |
|
|
170
|
+
| `xstate` | `^4.25.0` | 狀態機核心框架 | 所有 `machine/` 檔案 |
|
|
171
|
+
| `socket.io-client` | `^4.8.3` | WebSocket 即時通訊 | `machine/websocket.js` |
|
|
172
|
+
| `lodash` | `^4.17.21` | 工具函式(`pickBy`、`uniqBy`、`findLastIndex`、`padStart`、`toNumber`、`isEqual`) | 分散於 12 個檔案 |
|
|
173
|
+
| `ua-parser-js` | `^0.7.34` | 使用者代理解析(行動裝置偵測) | `machine/common.js` |
|
|
174
|
+
| `url-join` | `^4.0.1` | URL 路徑安全組合 | `request/config.js` |
|
|
175
|
+
| `universal-cookie` | `^4.0.4` | Cookie 操作 | `machine/common.js` |
|
|
176
|
+
|
|
129
177
|
## Architecture
|
|
130
178
|
|
|
131
179
|
```
|
|
132
180
|
src/
|
|
133
181
|
├── index.js # 進入點
|
|
134
182
|
├── api/ # API 請求描述物件
|
|
135
|
-
│ ├── auth.js
|
|
136
|
-
│ ├── account.js
|
|
137
|
-
│ ├── activity.js
|
|
138
|
-
│ ├── common.js
|
|
139
|
-
│ ├── form.js
|
|
140
|
-
│ ├── game.js
|
|
141
|
-
│ ├── mailbox.js
|
|
142
|
-
│ ├── otp.js
|
|
143
|
-
│ ├── payment.js
|
|
144
|
-
│ ├── ranking.js
|
|
145
|
-
│ └── user.js
|
|
146
183
|
├── machine/ # XState v4 狀態機
|
|
147
184
|
│ ├── auth.js # 登入/註冊流程
|
|
148
185
|
│ ├── common.js # 網站設定、UA、聯盟行銷
|
|
149
186
|
│ ├── websocket.js # Socket.IO 即時通訊
|
|
150
|
-
│ ├── deposit/ # 存款狀態機
|
|
151
|
-
│ ├── withdraw/ # 提款狀態機
|
|
152
|
-
│ └── activity/ # 活動狀態機
|
|
187
|
+
│ ├── deposit/ # 存款狀態機
|
|
188
|
+
│ ├── withdraw/ # 提款狀態機
|
|
189
|
+
│ └── activity/ # 活動狀態機
|
|
153
190
|
├── request/
|
|
154
191
|
│ ├── config.js # Config 設定類別
|
|
155
192
|
│ └── request.js # Axios 封裝 + 攔截器
|
|
@@ -180,32 +217,92 @@ npm run release:qa
|
|
|
180
217
|
|
|
181
218
|
程式碼風格由 Prettier 管理(無分號、單引號、尾隨逗號 ES5、2 空格縮排、150 字元行寬),Husky pre-commit hook 會在每次提交時自動格式化。
|
|
182
219
|
|
|
183
|
-
|
|
220
|
+
## Git 分支版本發佈流程
|
|
221
|
+
|
|
222
|
+
### 分支策略
|
|
223
|
+
|
|
224
|
+
| 分支 | 用途 | 版本格式 |
|
|
225
|
+
| -------- | -------- | -------------------------- |
|
|
226
|
+
| `master` | 正式發佈 | `x.y.z`(如 `1.1.430`) |
|
|
227
|
+
| `dev` | 開發測試 | `{master_version}-dev.{N}` |
|
|
228
|
+
| `qa` | QA 測試 | `{master_version}-qa.{N}` |
|
|
229
|
+
|
|
230
|
+
### 腳本權責分離
|
|
231
|
+
|
|
232
|
+
dev/qa 分支的自動版本發佈由三個腳本各司其職:
|
|
233
|
+
|
|
234
|
+
| 腳本 | 職責 | 說明 |
|
|
235
|
+
| ------------------------------------ | --------------------- | ----------------------------------------------------------------------------------------------------- |
|
|
236
|
+
| `scripts/auto-version.sh` | **流程控制**(Shell) | pre-push hook 入口。依序呼叫版號計算 → standard-version → push + publish,最後 `exit 1` 中止原始 push |
|
|
237
|
+
| `scripts/auto-version.js` | **版號計算**(ESM) | 純計算邏輯。讀取 master 版本、比對當前版本與 git log 歷史(historyMax 防倒退),stdout 輸出新版號 |
|
|
238
|
+
| `scripts/branch-auto-npm-publish.js` | **推送與發佈**(ESM) | 執行 `git push --follow-tags` 推送至遠端,再 `npm publish --tag {branch}` 發佈至 npm registry |
|
|
184
239
|
|
|
185
|
-
|
|
240
|
+
### dev / qa 分支自動版本流程
|
|
241
|
+
|
|
242
|
+
當開發者在 `dev` 或 `qa` 分支執行 `git push` 時,Husky `pre-push` hook 觸發以下流程:
|
|
186
243
|
|
|
187
244
|
```
|
|
188
|
-
git push
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
245
|
+
git push origin dev
|
|
246
|
+
│
|
|
247
|
+
├─ .husky/pre-push
|
|
248
|
+
│ ├─ sh scripts/clean-tags.sh # 清理本地 tag
|
|
249
|
+
│ └─ sh scripts/auto-version.sh "$1" # 流程入口(傳入 remote name)
|
|
250
|
+
│
|
|
251
|
+
├─ auto-version.sh 流程控制
|
|
252
|
+
│ │
|
|
253
|
+
│ ├─ ① node scripts/auto-version.js ← 版號計算
|
|
254
|
+
│ │ ├─ git show origin/master:package.json → 取得 master version(如 1.1.430)
|
|
255
|
+
│ │ │ └─ fallback: git show master:package.json
|
|
256
|
+
│ │ ├─ 讀取當前 package.json version
|
|
257
|
+
│ │ ├─ 從 currentVersion 推算下一編號
|
|
258
|
+
│ │ ├─ 掃描 git log 最近 50 筆 commit(historyMax 防倒退)
|
|
259
|
+
│ │ └─ stdout 輸出新版號(如 1.1.430-dev.3)
|
|
260
|
+
│ │ └─ 若版號無變更 → 靜默退出,auto-version.sh 跳過後續步驟
|
|
261
|
+
│ │
|
|
262
|
+
│ ├─ ② npx standard-version --release-as {version}
|
|
263
|
+
│ │ └─ 更新 CHANGELOG.md + 建立 commit + 建立 git tag
|
|
264
|
+
│ │
|
|
265
|
+
│ ├─ ③ node scripts/branch-auto-npm-publish.js ← 推送與發佈
|
|
266
|
+
│ │ ├─ git push --follow-tags origin dev
|
|
267
|
+
│ │ └─ npm publish --tag dev
|
|
268
|
+
│ │
|
|
269
|
+
│ └─ exit 1(中止原始 push,因為 script 已完成推送)
|
|
270
|
+
│
|
|
271
|
+
└─ 終端顯示 push 失敗,但實際發佈已成功(以 Released x.x.x 訊息為準)
|
|
192
272
|
```
|
|
193
273
|
|
|
194
|
-
|
|
274
|
+
### 版號計算規則
|
|
275
|
+
|
|
276
|
+
**基本遞增**:
|
|
277
|
+
|
|
278
|
+
- master 為 `1.1.430` → dev 第一次 push:`1.1.430-dev.0`
|
|
279
|
+
- 再次 push:`1.1.430-dev.1`、`1.1.430-dev.2`、...
|
|
280
|
+
- master 升版至 `1.1.431` → dev 重置為 `1.1.431-dev.0`
|
|
281
|
+
- qa 分支同理:`1.1.430-qa.0`、`1.1.430-qa.1`、...
|
|
195
282
|
|
|
196
|
-
|
|
197
|
-
| ------------------------------------ | ---------- | --------------------------------------------------------- |
|
|
198
|
-
| `scripts/auto-version.sh` | 流程控制 | pre-push 入口,串接版號計算 → standard-version → 發佈 |
|
|
199
|
-
| `scripts/auto-version.js` | 版號計算 | 讀取 master 版本 + 掃描 git log 防倒退,stdout 輸出新版號 |
|
|
200
|
-
| `scripts/branch-auto-npm-publish.js` | 推送與發佈 | `git push --follow-tags` + `npm publish --tag {branch}` |
|
|
283
|
+
**historyMax 防倒退機制**:
|
|
201
284
|
|
|
202
|
-
|
|
285
|
+
merge 其他分支後,`package.json` 的 version 可能被覆蓋為舊值(如從 `1.1.430-dev.4` 退回 `1.0.9-dev.20`)。此時腳本會掃描 git log 找出該 prefix 歷史上用過的最大編號,確保新版號不會倒退:
|
|
203
286
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
287
|
+
```
|
|
288
|
+
currentVersion = "1.0.9-dev.20" ← merge 後被覆蓋
|
|
289
|
+
git log 發現歷史有 "1.1.430-dev.4"
|
|
290
|
+
→ historyMax = 4, nextNum = 5
|
|
291
|
+
→ 新版號 = "1.1.430-dev.5"(而非從 0 重新開始)
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Husky Hooks 總覽
|
|
295
|
+
|
|
296
|
+
| Hook | 檔案 | 說明 |
|
|
297
|
+
| --------------- | ---------------------- | ---------------------------------------------------- |
|
|
298
|
+
| `pre-commit` | `.husky/pre-commit` | 執行 `npm run format && git add .`(Prettier) |
|
|
299
|
+
| `pre-push` | `.husky/pre-push` | dev/qa 分支自動版本發佈(`scripts/auto-version.sh`) |
|
|
300
|
+
| `post-checkout` | `.husky/post-checkout` | dev/qa/hotfix 分支自動 `git pull --rebase` |
|
|
301
|
+
| `post-commit` | `.husky/post-commit` | (保留,目前無額外操作) |
|
|
302
|
+
| `post-merge` | `.husky/post-merge` | (保留,目前無額外操作) |
|
|
210
303
|
|
|
211
304
|
> **注意**:`pre-push` hook 完成推送後會以 `exit 1` 中止原始 push(因為已推送完成),終端會顯示 push 失敗訊息,但實際發佈已成功。以 `Released x.x.x on {branch}` 訊息為準。
|
|
305
|
+
|
|
306
|
+
## License
|
|
307
|
+
|
|
308
|
+
ISC
|
package/package.json
CHANGED
package/scripts/auto-version.js
CHANGED
package/scripts/clean-tags.sh
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
# 不符合規範 tag 的刪除規則:
|
|
7
7
|
# 1. commit 不屬於任何分支 → 刪除(remote + local)
|
|
8
8
|
# 2. commit 存在於 origin/master → 刪除(remote + local)
|
|
9
|
-
# 3. commit
|
|
10
|
-
# 4. commit 在其他分支上 → 跳過保留
|
|
9
|
+
# 3. commit 在其他分支上 → 跳過保留
|
|
11
10
|
PATTERN="^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"
|
|
12
11
|
|
|
13
12
|
# 確保遠端 ref 為最新,避免本地 master 落後造成誤判
|
|
@@ -41,27 +40,9 @@ safe_delete_tag() {
|
|
|
41
40
|
fi
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
# 判斷 commit 是否位於 dev 或 qa 分支(含對應遠端分支)
|
|
45
|
-
is_on_dev_or_qa() {
|
|
46
|
-
git branch -a --contains "$1" 2>/dev/null \
|
|
47
|
-
| sed 's/^[* ]*//' \
|
|
48
|
-
| grep -qE '^(remotes/origin/)?(dev|qa)$'
|
|
49
|
-
}
|
|
50
|
-
|
|
51
43
|
TAGS=$(git tag -l | grep -vE "$PATTERN")
|
|
52
44
|
if [ -n "$TAGS" ]; then
|
|
53
45
|
echo "檢查不符合規範的 tag"
|
|
54
|
-
|
|
55
|
-
# 先找出所有 commit 在 dev/qa 且未進 master 的 tag,版本最新的一個予以保留
|
|
56
|
-
KEEP_DEVQA_TAG=$(
|
|
57
|
-
for TAG in $TAGS; do
|
|
58
|
-
TAG_COMMIT=$(git rev-list -n 1 "$TAG" 2>/dev/null)
|
|
59
|
-
[ -z "$TAG_COMMIT" ] && continue
|
|
60
|
-
git merge-base --is-ancestor "$TAG_COMMIT" origin/master 2>/dev/null && continue
|
|
61
|
-
is_on_dev_or_qa "$TAG_COMMIT" && echo "$TAG"
|
|
62
|
-
done | sort -V | tail -n 1
|
|
63
|
-
)
|
|
64
|
-
|
|
65
46
|
for TAG in $TAGS; do
|
|
66
47
|
TAG_COMMIT=$(git rev-list -n 1 "$TAG" 2>/dev/null)
|
|
67
48
|
BRANCHES=$(git branch -a --contains "$TAG_COMMIT" 2>/dev/null)
|
|
@@ -69,12 +50,6 @@ if [ -n "$TAGS" ]; then
|
|
|
69
50
|
safe_delete_tag "$TAG" "commit 不屬於任何分支"
|
|
70
51
|
elif git merge-base --is-ancestor "$TAG_COMMIT" origin/master 2>/dev/null; then
|
|
71
52
|
safe_delete_tag "$TAG" "commit 存在於 origin/master"
|
|
72
|
-
elif is_on_dev_or_qa "$TAG_COMMIT"; then
|
|
73
|
-
if [ "$TAG" = "$KEEP_DEVQA_TAG" ]; then
|
|
74
|
-
echo "保留 tag $TAG(dev/qa 最新的一個)"
|
|
75
|
-
else
|
|
76
|
-
safe_delete_tag "$TAG" "dev/qa 僅保留最新的一個 tag"
|
|
77
|
-
fi
|
|
78
53
|
else
|
|
79
54
|
echo "跳過 tag $TAG(commit 在其他分支上)"
|
|
80
55
|
fi
|
package/src/api/activity.js
CHANGED
|
@@ -125,14 +125,4 @@ 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
|
-
}),
|
|
138
128
|
}
|
package/src/api/common.js
CHANGED
|
@@ -2,7 +2,7 @@ export default {
|
|
|
2
2
|
getConfig: ({ appSecret }) => ({ url: 'getConfig', method: 'get', params: { appSecret }, isPublic: true }),
|
|
3
3
|
getLayoutConfig: ({ appSecret }) => ({ url: 'getQuickLayout', method: 'get', params: { appSecret }, isPublic: true }),
|
|
4
4
|
feeds: ({ appSecret }) => ({ url: 'feeds', method: 'get', params: { appSecret }, isPublic: true }),
|
|
5
|
-
broadcast: (
|
|
5
|
+
broadcast: () => ({ url: 'broadcast', method: 'get', params: { appSecret }, isPublic: true }),
|
|
6
6
|
getAnnouncements: ({ appSecret }) => ({ url: 'getAnnouncements', params: { appSecret }, method: 'get', isPublic: true }),
|
|
7
7
|
getNavbar: ({ appSecret } = {}) => ({ url: 'getNavbarSetting', params: { appSecret }, method: 'get', isPublic: true }),
|
|
8
8
|
getDefaultAffiliateCode: ({ appSecret }) => ({ url: 'getAffiliateCode', params: { appSecret }, method: 'get', isPublic: true }),
|
|
@@ -11,7 +11,6 @@ export default function (request) {
|
|
|
11
11
|
context: {
|
|
12
12
|
tick: 2000,
|
|
13
13
|
activityList: [],
|
|
14
|
-
progressSummary: {},
|
|
15
14
|
tournamentList: [],
|
|
16
15
|
promotionList: [],
|
|
17
16
|
uidSite: '',
|
|
@@ -25,7 +24,7 @@ export default function (request) {
|
|
|
25
24
|
src: 'fetchList',
|
|
26
25
|
onDone: {
|
|
27
26
|
target: 'checking',
|
|
28
|
-
actions: ['setActivityList', 'setTournamentList', 'setPromotionList'
|
|
27
|
+
actions: ['setActivityList', 'setTournamentList', 'setPromotionList'],
|
|
29
28
|
},
|
|
30
29
|
onError: {
|
|
31
30
|
target: 'pending',
|
|
@@ -97,12 +96,6 @@ export default function (request) {
|
|
|
97
96
|
activityList: list,
|
|
98
97
|
}
|
|
99
98
|
}),
|
|
100
|
-
setProgressSummary: assign((context, event) => {
|
|
101
|
-
const { progressSummary } = event.data
|
|
102
|
-
return {
|
|
103
|
-
progressSummary: progressSummary || null,
|
|
104
|
-
}
|
|
105
|
-
}),
|
|
106
99
|
setPromotionList: assign((context, event) => {
|
|
107
100
|
const { promotionList } = event.data
|
|
108
101
|
return {
|
|
@@ -161,20 +154,12 @@ export default function (request) {
|
|
|
161
154
|
services: {
|
|
162
155
|
fetchList: async (context, event) => {
|
|
163
156
|
const hasToken = request.getToken()
|
|
164
|
-
const
|
|
165
|
-
const isProgressEnable = siteConfig?.frontendActivityProgressEnable
|
|
166
|
-
|
|
167
|
-
const [{ data }, promotionList, progressSummaryRes] = await Promise.all([
|
|
157
|
+
const [{ data }, promotionList] = await Promise.all([
|
|
168
158
|
hasToken ? request.send(activity.getActivityList({ appSecret })) : request.send(activity.getAllActivityList({ appSecret })),
|
|
169
159
|
hasToken ? request.send(payment.getPromotionsList()) : [],
|
|
170
|
-
hasToken && isProgressEnable ? request.send(activity.getProgressSummary({ appSecret })).catch(() => null) : null,
|
|
171
160
|
])
|
|
172
161
|
|
|
173
|
-
return {
|
|
174
|
-
activityList: data,
|
|
175
|
-
promotionList,
|
|
176
|
-
progressSummary: progressSummaryRes?.data || null,
|
|
177
|
-
}
|
|
162
|
+
return { activityList: data, promotionList }
|
|
178
163
|
},
|
|
179
164
|
fetchActivityDetailList: async (context, event) => {
|
|
180
165
|
await new Promise((resolve) => setTimeout(resolve, 1000)) // delay 1 second
|
|
@@ -217,25 +217,18 @@ export default function (request) {
|
|
|
217
217
|
},
|
|
218
218
|
guards: {
|
|
219
219
|
isVerified: (context, event) => {
|
|
220
|
-
|
|
221
|
-
if (strategy === 'phone') return !!userInfo?.phone_verification_status
|
|
222
|
-
if (strategy === 'email') return !!userInfo?.email_verification_status
|
|
223
|
-
return false
|
|
220
|
+
return context.userInfo?.verification_status === 1
|
|
224
221
|
},
|
|
225
222
|
isNotVerified: (context, event) => {
|
|
226
|
-
|
|
227
|
-
if (!userInfo) return false
|
|
228
|
-
if (strategy === 'phone') return !userInfo.phone_verification_status
|
|
229
|
-
if (strategy === 'email') return !userInfo.email_verification_status
|
|
230
|
-
return false
|
|
223
|
+
return context.userInfo && context.userInfo.verification_status !== 1
|
|
231
224
|
},
|
|
232
225
|
isPhoneNotVerified: (context, event) => {
|
|
233
226
|
const { strategy, userInfo } = context
|
|
234
|
-
return strategy === 'phone' &&
|
|
227
|
+
return strategy === 'phone' && userInfo && userInfo.verification_status !== 1 && !userInfo.phone
|
|
235
228
|
},
|
|
236
229
|
isEmailNotVerified: (context, event) => {
|
|
237
230
|
const { strategy, userInfo } = context
|
|
238
|
-
return strategy === 'email' &&
|
|
231
|
+
return strategy === 'email' && userInfo && userInfo.verification_status !== 1 && !userInfo.email
|
|
239
232
|
},
|
|
240
233
|
hasNoPhone: (context, event) => {
|
|
241
234
|
const { error } = context
|
|
@@ -72,25 +72,11 @@ export default function (request) {
|
|
|
72
72
|
return { fc }
|
|
73
73
|
}),
|
|
74
74
|
setSignUpId: assign((context, event) => {
|
|
75
|
-
const {
|
|
76
|
-
|
|
77
|
-
username,
|
|
78
|
-
nick_name,
|
|
79
|
-
password,
|
|
80
|
-
countryCode,
|
|
81
|
-
phone,
|
|
82
|
-
bankCode,
|
|
83
|
-
bankAccount,
|
|
84
|
-
holderName,
|
|
85
|
-
branch,
|
|
86
|
-
branchCode,
|
|
87
|
-
affiliateCode,
|
|
88
|
-
birthday,
|
|
89
|
-
} = event.data
|
|
75
|
+
const { email, username, nick_name, password, countryCode, phone, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode } =
|
|
76
|
+
event.data
|
|
90
77
|
return {
|
|
91
78
|
signUpData: {
|
|
92
79
|
provider: 'local',
|
|
93
|
-
birthday,
|
|
94
80
|
email,
|
|
95
81
|
username,
|
|
96
82
|
nick_name,
|
|
@@ -107,12 +93,10 @@ export default function (request) {
|
|
|
107
93
|
}
|
|
108
94
|
}),
|
|
109
95
|
setSignUpPhone: assign((context, event) => {
|
|
110
|
-
const { email, countryCode, phone, nick_name, password, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode
|
|
111
|
-
event.data
|
|
96
|
+
const { email, countryCode, phone, nick_name, password, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode } = event.data
|
|
112
97
|
return {
|
|
113
98
|
signUpData: {
|
|
114
99
|
provider: 'phone',
|
|
115
|
-
birthday,
|
|
116
100
|
email,
|
|
117
101
|
countryCode,
|
|
118
102
|
phone,
|
|
@@ -128,12 +112,10 @@ export default function (request) {
|
|
|
128
112
|
}
|
|
129
113
|
}),
|
|
130
114
|
setSignUpEmail: assign((context, event) => {
|
|
131
|
-
const { email, nick_name, password, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode, countryCode, phone
|
|
132
|
-
event.data
|
|
115
|
+
const { email, nick_name, password, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode, countryCode, phone } = event.data
|
|
133
116
|
return {
|
|
134
117
|
signUpData: {
|
|
135
118
|
provider: 'email',
|
|
136
|
-
birthday,
|
|
137
119
|
email,
|
|
138
120
|
nick_name,
|
|
139
121
|
password,
|
package/src/request/request.js
CHANGED
|
@@ -252,8 +252,8 @@ export default class Request {
|
|
|
252
252
|
async send(req, customToken) {
|
|
253
253
|
try {
|
|
254
254
|
const cancelToken = customToken || this.source.token
|
|
255
|
-
|
|
256
|
-
|
|
255
|
+
this._checkToken(req)
|
|
256
|
+
|
|
257
257
|
const requestConfig = this._createConfig(req, cancelToken)
|
|
258
258
|
const configUrls = ['getConfig', 'get-config']
|
|
259
259
|
if (this.isBlocked && !configUrls.includes(requestConfig.url)) {
|
|
@@ -363,6 +363,12 @@ export default class Request {
|
|
|
363
363
|
return queryString ? `${convertedPath}?${queryString}` : convertedPath
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
+
_checkToken(req) {
|
|
367
|
+
if (!req.isPublic && !this.getToken()) {
|
|
368
|
+
throw { code: 'ERR_A103', url: req.url }
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
366
372
|
getToken() {
|
|
367
373
|
return storage.get(this.key)
|
|
368
374
|
}
|