@jetthai/cuora 1.1.400-dev-12 → 1.1.400-dev-13
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 +2 -0
- package/package.json +1 -1
- package/src/machine/auth.js +1 -0
- package/src/request/request.js +18 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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.400-dev-13](https://github.com/jetthai/cuora-module/compare/v1.1.400-dev-12...v1.1.400-dev-13) (2025-12-18)
|
|
6
|
+
|
|
5
7
|
### [1.1.400-dev-12](https://github.com/jetthai/cuora-module/compare/v1.1.400-dev-11...v1.1.400-dev-12) (2025-12-18)
|
|
6
8
|
|
|
7
9
|
### [1.1.400-dev-11](https://github.com/jetthai/cuora-module/compare/v1.1.400-dev-10...v1.1.400-dev-11) (2025-12-18)
|
package/package.json
CHANGED
package/src/machine/auth.js
CHANGED
package/src/request/request.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import pickBy from 'lodash/pickBy.js'
|
|
2
2
|
import storage from '../util/storage.js'
|
|
3
3
|
|
|
4
|
+
// const pickBy = require('lodash/pickBy')
|
|
4
5
|
const supportVersion2List = [
|
|
5
6
|
// 04-09 Update
|
|
6
7
|
'game/play',
|
|
@@ -242,13 +243,10 @@ export default class Request {
|
|
|
242
243
|
this._checkToken(req)
|
|
243
244
|
|
|
244
245
|
const requestConfig = this._createConfig(req, cancelToken)
|
|
245
|
-
// console.log('*請求資料Check', requestConfig)
|
|
246
246
|
const configUrls = ['getConfig', 'get-config']
|
|
247
247
|
if (this.isBlocked && !configUrls.includes(requestConfig.url)) {
|
|
248
248
|
// 狀態是維護中&請求非siteConfig,終止所有的請求,除了維護頁需要的資料(siteConfig)
|
|
249
|
-
// console.log('%c*禁止的請求目標', requestConfig)
|
|
250
249
|
} else {
|
|
251
|
-
// console.log('%c*允許的請求目標', requestConfig)
|
|
252
250
|
const { data } = await this.axios.request(requestConfig)
|
|
253
251
|
return data
|
|
254
252
|
}
|
|
@@ -280,7 +278,23 @@ export default class Request {
|
|
|
280
278
|
_createConfig(req, cancelToken) {
|
|
281
279
|
const { method, url, params, isPublic, isFormData, headers } = req
|
|
282
280
|
let fullURL = this.config.fullURL
|
|
283
|
-
let urlName =
|
|
281
|
+
let urlName = url
|
|
282
|
+
|
|
283
|
+
// 有些API會將參數(/?)直接帶在URL上,所以要將參數排除
|
|
284
|
+
const cleanUrl = url.split('?')[0]
|
|
285
|
+
const isV2Supported = supportVersion2List.some((supportedUrl) => {
|
|
286
|
+
// 如果包含動態參數(:parameter),則使用模式匹配
|
|
287
|
+
if (supportedUrl.includes(':')) {
|
|
288
|
+
const pattern = supportedUrl.replace(/:[^/]+/g, '[^/]+')
|
|
289
|
+
const regex = new RegExp(`^${pattern}$`)
|
|
290
|
+
return regex.test(cleanUrl)
|
|
291
|
+
}
|
|
292
|
+
return supportedUrl === cleanUrl
|
|
293
|
+
})
|
|
294
|
+
// 符合轉換規則的API進行路徑調整
|
|
295
|
+
if (isV2Supported) {
|
|
296
|
+
urlName = this._convertUrlToKebabCase(url)
|
|
297
|
+
}
|
|
284
298
|
|
|
285
299
|
if (isFormData) {
|
|
286
300
|
return {
|