@jetthai/cuora 1.0.0 → 1.0.2
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 +11 -0
- package/index.js +6 -0
- package/package.json +10 -3
- package/plugin/activity.js +7 -7
- package/plugin/core.js +93 -143
- package/plugin/game.js +26 -26
- package/plugin/inbox.js +10 -5
- package/plugin/information.js +2 -2
- package/plugin/job/network.js +59 -0
- package/plugin/payment.js +25 -21
- package/plugin/request.js +75 -30
- package/plugin/search.js +6 -6
- package/plugin/user.js +41 -29
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
### [1.0.2](https://github.com/jetthai/cuora-module/compare/v1.0.1...v1.0.2) (2021-08-05)
|
|
6
|
+
|
|
7
|
+
### 1.0.1 (2021-08-04)
|
|
8
|
+
|
|
9
|
+
### 1.0.1 (2021-08-04)
|
|
10
|
+
|
|
11
|
+
### 1.0.2 (2021-08-04)
|
package/index.js
CHANGED
|
@@ -3,6 +3,12 @@ import path from 'path'
|
|
|
3
3
|
export default function (moduleOptions) {
|
|
4
4
|
const options = { ...this.options.cuora, ...moduleOptions }
|
|
5
5
|
|
|
6
|
+
this.addPlugin({
|
|
7
|
+
src: path.resolve(__dirname, './plugin/job/network.js'),
|
|
8
|
+
options,
|
|
9
|
+
mode: 'client'
|
|
10
|
+
})
|
|
11
|
+
|
|
6
12
|
this.addPlugin({
|
|
7
13
|
src: path.resolve(__dirname, './plugin/search.js'),
|
|
8
14
|
options,
|
package/package.json
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jetthai/cuora",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"release": "standard-version",
|
|
9
|
+
"push": "git push --follow-tags origin master && npm publish"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/jetthai/cuora-module.git"
|
|
8
14
|
},
|
|
9
15
|
"author": "Neil",
|
|
10
16
|
"license": "ISC",
|
|
11
17
|
"devDependencies": {
|
|
12
|
-
"prettier": "^2.3.0"
|
|
18
|
+
"prettier": "^2.3.0",
|
|
19
|
+
"standard-version": "^9.3.1"
|
|
13
20
|
},
|
|
14
21
|
"dependencies": {
|
|
15
22
|
"lodash": "^4.17.21",
|
package/plugin/activity.js
CHANGED
|
@@ -29,7 +29,7 @@ const api = {
|
|
|
29
29
|
|
|
30
30
|
const clientSecret = process.env.CLIENT_SECRET
|
|
31
31
|
|
|
32
|
-
function createStore(request) {
|
|
32
|
+
function createStore({$request}) {
|
|
33
33
|
return {
|
|
34
34
|
namespaced: true,
|
|
35
35
|
state: () => ({
|
|
@@ -212,7 +212,7 @@ function createStore(request) {
|
|
|
212
212
|
actions: {
|
|
213
213
|
async getActivityTypes({ commit }) {
|
|
214
214
|
try {
|
|
215
|
-
const types = await request(api.getActivityTypes({ appSecret: clientSecret }))
|
|
215
|
+
const types = await $request(api.getActivityTypes({ appSecret: clientSecret }))
|
|
216
216
|
commit(`setActivities`, { types: types?.data || {} })
|
|
217
217
|
} catch (err) {
|
|
218
218
|
console.log(err)
|
|
@@ -220,7 +220,7 @@ function createStore(request) {
|
|
|
220
220
|
},
|
|
221
221
|
async getActivityList({ commit, getters, dispatch }) {
|
|
222
222
|
try {
|
|
223
|
-
const activities = await request(api.getActivityList({ appSecret: clientSecret, include: 'cl' }))
|
|
223
|
+
const activities = await $request(api.getActivityList({ appSecret: clientSecret, include: 'cl' }))
|
|
224
224
|
commit(`setActivities`, { list: activities?.data || {} })
|
|
225
225
|
const activitiesById = {}
|
|
226
226
|
activities.data.forEach((val, index) => {
|
|
@@ -239,7 +239,7 @@ function createStore(request) {
|
|
|
239
239
|
}
|
|
240
240
|
},
|
|
241
241
|
async getActivityDetail({ commit }, activityNo) {
|
|
242
|
-
const { data } = await request(api.getActivityDetail({ activityNo, appSecret: clientSecret }))
|
|
242
|
+
const { data } = await $request(api.getActivityDetail({ activityNo, appSecret: clientSecret }))
|
|
243
243
|
commit(`setSingleActivities`, { key: activityNo, data })
|
|
244
244
|
return data
|
|
245
245
|
},
|
|
@@ -253,7 +253,7 @@ function createStore(request) {
|
|
|
253
253
|
async fetchAchievements({ rootGetters, commit }, pageIdx = 0) {
|
|
254
254
|
try {
|
|
255
255
|
if (rootGetters[`core/isAuthorized`] && !rootGetters['user/isInline']) {
|
|
256
|
-
const achievements = await request(
|
|
256
|
+
const achievements = await $request(
|
|
257
257
|
api.getAchievements({
|
|
258
258
|
limit: 10,
|
|
259
259
|
page: pageIdx,
|
|
@@ -267,7 +267,7 @@ function createStore(request) {
|
|
|
267
267
|
}
|
|
268
268
|
},
|
|
269
269
|
async getAchievementDetail({}, achievementNo) {
|
|
270
|
-
const { data } = await request(api.getAchievementsProgress({ achievementNo, appSecret: clientSecret }))
|
|
270
|
+
const { data } = await $request(api.getAchievementsProgress({ achievementNo, appSecret: clientSecret }))
|
|
271
271
|
return data
|
|
272
272
|
},
|
|
273
273
|
},
|
|
@@ -276,5 +276,5 @@ function createStore(request) {
|
|
|
276
276
|
|
|
277
277
|
export default (ctx, inject) => {
|
|
278
278
|
const { store, $request } = ctx
|
|
279
|
-
store.registerModule('activity', createStore($request))
|
|
279
|
+
store.registerModule('activity', createStore({$request}))
|
|
280
280
|
}
|
package/plugin/core.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
const UAParser = require('ua-parser-js')
|
|
2
|
-
|
|
3
2
|
const tick = 2000
|
|
4
|
-
let isUpdatingFlag = false
|
|
5
|
-
let isRefreshingFlag = false
|
|
6
|
-
|
|
7
3
|
const clientSecret = process.env.CLIENT_SECRET
|
|
8
4
|
|
|
9
5
|
const api = {
|
|
10
|
-
getConfig: ({ appSecret }) => ({ url: 'getConfig', method: 'get', params: { appSecret } }),
|
|
11
|
-
login: (
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
getConfig: ({ appSecret }) => ({ url: 'getConfig', method: 'get', params: { appSecret }, public: true }),
|
|
7
|
+
login: ({ username, password, provider, countryCode, phone }) => ({
|
|
8
|
+
url: 'login',
|
|
9
|
+
method: 'post',
|
|
10
|
+
params: { username, password, provider, countryCode, phone },
|
|
11
|
+
public: true,
|
|
12
|
+
}),
|
|
13
|
+
register: (data) => ({ url: 'register?channel=official&subchannel=pwa', method: 'post', params: data, public: true }),
|
|
14
14
|
logout: () => ({ url: 'logout', method: 'post' }),
|
|
15
|
-
feeds: () => ({ url: 'feeds', method: 'get', params: { appSecret: clientSecret } }),
|
|
15
|
+
feeds: () => ({ url: 'feeds', method: 'get', params: { appSecret: clientSecret }, public: true }),
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function createStore(request, ignoreErrorRequest,
|
|
18
|
+
function createStore({ $request, $ignoreErrorRequest, $loadingRequest, $updateSource, $cookie }) {
|
|
19
19
|
return {
|
|
20
20
|
namespaced: true,
|
|
21
21
|
state: () => ({
|
|
@@ -33,7 +33,6 @@ function createStore(request, ignoreErrorRequest, cookie, updateSource) {
|
|
|
33
33
|
imageUrl: process.env.IMAGE_URL,
|
|
34
34
|
},
|
|
35
35
|
authorized: false,
|
|
36
|
-
lastInteractive: null,
|
|
37
36
|
token: null,
|
|
38
37
|
globalError: null,
|
|
39
38
|
globalLoading: false,
|
|
@@ -61,7 +60,8 @@ function createStore(request, ignoreErrorRequest, cookie, updateSource) {
|
|
|
61
60
|
idleTime: 0,
|
|
62
61
|
idleLimit: 180,
|
|
63
62
|
animationInitData: null,
|
|
64
|
-
|
|
63
|
+
refreshDataFlag: false,
|
|
64
|
+
keepUserTimer: null,
|
|
65
65
|
keepFreshTimer: null,
|
|
66
66
|
}),
|
|
67
67
|
getters: {
|
|
@@ -138,12 +138,6 @@ function createStore(request, ignoreErrorRequest, cookie, updateSource) {
|
|
|
138
138
|
getError(state) {
|
|
139
139
|
return state.globalError
|
|
140
140
|
},
|
|
141
|
-
getToken(state, getters) {
|
|
142
|
-
return state.token
|
|
143
|
-
},
|
|
144
|
-
lastInteractive(state, getters) {
|
|
145
|
-
return state.lastInteractive
|
|
146
|
-
},
|
|
147
141
|
isAuthorized(state, getters) {
|
|
148
142
|
return state.authorized
|
|
149
143
|
},
|
|
@@ -185,9 +179,9 @@ function createStore(request, ignoreErrorRequest, cookie, updateSource) {
|
|
|
185
179
|
},
|
|
186
180
|
},
|
|
187
181
|
mutations: {
|
|
188
|
-
setToken(state, data) {
|
|
189
|
-
|
|
190
|
-
},
|
|
182
|
+
// setToken(state, data) {
|
|
183
|
+
// state.token = data
|
|
184
|
+
// },
|
|
191
185
|
setAuthorized(state, data) {
|
|
192
186
|
state.authorized = data
|
|
193
187
|
},
|
|
@@ -250,14 +244,14 @@ function createStore(request, ignoreErrorRequest, cookie, updateSource) {
|
|
|
250
244
|
setIdleTime(state, data) {
|
|
251
245
|
state.idleTime++
|
|
252
246
|
},
|
|
253
|
-
setLastInteractive(state, data) {
|
|
254
|
-
state.lastInteractive = data
|
|
255
|
-
},
|
|
256
247
|
setAnimationInitData(state, data) {
|
|
257
248
|
state.animationInitData = data
|
|
258
249
|
},
|
|
259
|
-
|
|
260
|
-
state.
|
|
250
|
+
setRefreshDataFlag(state, data) {
|
|
251
|
+
state.refreshDataFlag = data
|
|
252
|
+
},
|
|
253
|
+
setKeepUserTimer(state, data) {
|
|
254
|
+
state.keepUserTimer = data
|
|
261
255
|
},
|
|
262
256
|
setKeepFreshTimer(state, data) {
|
|
263
257
|
state.keepFreshTimer = data
|
|
@@ -266,12 +260,7 @@ function createStore(request, ignoreErrorRequest, cookie, updateSource) {
|
|
|
266
260
|
actions: {
|
|
267
261
|
checkVerification({ getters, commit, dispatch, rootGetters }) {
|
|
268
262
|
// 特別注意排隊中不需驗證
|
|
269
|
-
if (
|
|
270
|
-
!rootGetters['user/isInline'] &&
|
|
271
|
-
getters.isAuthorized &&
|
|
272
|
-
getters.hasForceValidation &&
|
|
273
|
-
!rootGetters['user/isValidAccount']
|
|
274
|
-
) {
|
|
263
|
+
if (!rootGetters['user/isInline'] && getters.hasForceValidation && !rootGetters['user/isValidAccount']) {
|
|
275
264
|
if (getters.getModal?.type !== 'verificationCancel') {
|
|
276
265
|
commit('setModal', { type: 'verification' })
|
|
277
266
|
}
|
|
@@ -292,7 +281,7 @@ function createStore(request, ignoreErrorRequest, cookie, updateSource) {
|
|
|
292
281
|
commit('SET_LANG', lang, { root: true })
|
|
293
282
|
}
|
|
294
283
|
},
|
|
295
|
-
solveError({ state, commit, getters, dispatch }) {
|
|
284
|
+
solveError({ state, commit, getters, rootGetters, dispatch }) {
|
|
296
285
|
const solution = state.errorHandlerMap[getters.getError.code]
|
|
297
286
|
switch (solution) {
|
|
298
287
|
case 1:
|
|
@@ -302,13 +291,10 @@ function createStore(request, ignoreErrorRequest, cookie, updateSource) {
|
|
|
302
291
|
console.log('[Bridge] Auth Reset')
|
|
303
292
|
})
|
|
304
293
|
}
|
|
305
|
-
// if (this.state.route.fullPath !== '/') {
|
|
306
|
-
// this.$router.push('/')
|
|
307
|
-
// }
|
|
308
294
|
this.$router.push('/')
|
|
309
295
|
break
|
|
310
296
|
case 2: // Promote
|
|
311
|
-
if (
|
|
297
|
+
if (rootGetters['user/userInfo'].retain >= 1) {
|
|
312
298
|
commit('setModal', { type: 'mergeRetain' })
|
|
313
299
|
} else {
|
|
314
300
|
commit('setModal', { type: 'promotionTable' })
|
|
@@ -338,113 +324,73 @@ function createStore(request, ignoreErrorRequest, cookie, updateSource) {
|
|
|
338
324
|
)
|
|
339
325
|
}
|
|
340
326
|
},
|
|
341
|
-
async login({ state, commit, getters, dispatch }, data) {
|
|
327
|
+
async login({ state, commit, getters, rootGetters, dispatch }, data) {
|
|
342
328
|
try {
|
|
343
|
-
|
|
344
|
-
const loginResult = await request(api.login(data))
|
|
329
|
+
const loginResult = await $loadingRequest(api.login(data))
|
|
345
330
|
const token = loginResult.token
|
|
346
|
-
cookie.setToken(token)
|
|
347
|
-
cookie.setUser(data.username)
|
|
348
|
-
|
|
349
|
-
await dispatch('checkAuth', token)
|
|
350
|
-
commit('setLoading', false)
|
|
331
|
+
$cookie.setToken(token)
|
|
332
|
+
$cookie.setUser(data.username)
|
|
333
|
+
await dispatch('checkAuth')
|
|
351
334
|
return loginResult
|
|
352
335
|
} catch (err) {
|
|
353
336
|
console.log('[ ERR ] Login Fail')
|
|
354
337
|
await dispatch('detachToken')
|
|
355
|
-
commit('setLoading', false)
|
|
356
338
|
throw err
|
|
357
339
|
}
|
|
358
340
|
},
|
|
359
|
-
async checkAuth({ state, commit, getters, dispatch }
|
|
341
|
+
async checkAuth({ state, commit, getters, dispatch }) {
|
|
360
342
|
try {
|
|
361
343
|
commit('setLoading', true)
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
cookie.setToken(accessToken)
|
|
365
|
-
await dispatch('updateUserInfo')
|
|
366
|
-
dispatch('keepAlive')
|
|
367
|
-
commit('setToken', accessToken)
|
|
344
|
+
if ($cookie.getToken()) {
|
|
345
|
+
await dispatch('fetchUserInfo')
|
|
368
346
|
commit('setAuthorized', true)
|
|
369
|
-
|
|
370
|
-
|
|
347
|
+
dispatch('game/examineGame', null, { root: true })
|
|
348
|
+
dispatch('refreshData')
|
|
349
|
+
dispatch('keepAlive')
|
|
371
350
|
return true
|
|
372
351
|
} else {
|
|
373
|
-
commit('setAuthorized', false)
|
|
374
|
-
commit(`setLoading`, false)
|
|
375
352
|
return false
|
|
376
353
|
}
|
|
377
354
|
} catch (err) {
|
|
378
|
-
console.
|
|
379
|
-
commit(`setLoading`, false)
|
|
380
|
-
await dispatch('detachToken')
|
|
355
|
+
console.error(err)
|
|
381
356
|
return false
|
|
357
|
+
} finally {
|
|
358
|
+
commit(`setLoading`, false)
|
|
382
359
|
}
|
|
383
360
|
},
|
|
384
|
-
async
|
|
385
|
-
// 若沒有 interceptor 的話,連試都不要試
|
|
386
|
-
// if (this.request.interceptors.request.handlers.length >= 1 && !isUpdatingFlag) {
|
|
361
|
+
async fetchUserInfo({ state, commit, getters, dispatch, rootGetters }) {
|
|
387
362
|
try {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
if (isUpdatingFlag) {
|
|
391
|
-
console.log('[updateUserInfo] Ignored')
|
|
392
|
-
return
|
|
393
|
-
}
|
|
394
|
-
isUpdatingFlag = true
|
|
395
|
-
const time = new Date()
|
|
396
|
-
const userInfo = await request(api.getUserInfo())
|
|
397
|
-
commit('user/setUserInfo', userInfo, { root: true })
|
|
398
|
-
if (rootGetters[`user/getSavedLevel`] === null) {
|
|
399
|
-
commit('user/setSavedLevel', userInfo.level, { root: true })
|
|
400
|
-
}
|
|
363
|
+
await dispatch('user/getUserInfo', null, { root: true })
|
|
364
|
+
$cookie.prolongToken()
|
|
401
365
|
dispatch(`checkVerification`)
|
|
402
|
-
//
|
|
403
|
-
if (
|
|
404
|
-
cookie.setToken(getters[`getToken`])
|
|
405
|
-
}
|
|
406
|
-
if (userInfo.rank) {
|
|
407
|
-
commit('user/setInline', true, { root: true })
|
|
366
|
+
// todo test inline
|
|
367
|
+
if (rootGetters['user/userInfo']?.rank < 10) {
|
|
408
368
|
// 如果排名在 10 名以內的話,暴力連續呼叫
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
}, 500)
|
|
413
|
-
}
|
|
414
|
-
} else {
|
|
415
|
-
commit('user/setInline', false, { root: true })
|
|
369
|
+
setTimeout(() => {
|
|
370
|
+
dispatch('fetchUserInfo')
|
|
371
|
+
}, 500)
|
|
416
372
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
if (!state.isInline && !rootGetters[`payment/getRefreshBank`] && userInfo.bank_account) {
|
|
422
|
-
commit(`payment/setRefreshBank`, true, { root: true })
|
|
423
|
-
dispatch(
|
|
424
|
-
'payment/makeTransactionIgnoreError',
|
|
425
|
-
{ type: 'DEPOSIT', payload: null, paymentMethod: 'amb' },
|
|
426
|
-
{ root: true }
|
|
427
|
-
)
|
|
373
|
+
// only for sabai
|
|
374
|
+
if (!rootGetters['user/isInline'] && rootGetters['user/userInfo'].bank_account) {
|
|
375
|
+
dispatch('payment/refreshAmbBankAccount', null, { root: true })
|
|
428
376
|
}
|
|
429
377
|
} catch (err) {
|
|
430
|
-
console.log(err)
|
|
431
378
|
await dispatch('detachToken')
|
|
432
|
-
commit('user/setInline', false, { root: true })
|
|
433
|
-
isUpdatingFlag = false
|
|
434
379
|
throw err
|
|
435
380
|
}
|
|
436
381
|
},
|
|
437
382
|
async detachToken({ state, commit, getters, dispatch, rootGetters }) {
|
|
383
|
+
commit('user/setUserInfoFlag', false, { root: true })
|
|
384
|
+
|
|
438
385
|
console.info('TOKEN DETACHED')
|
|
439
|
-
clearInterval(state.
|
|
386
|
+
clearInterval(state.keepUserTimer)
|
|
440
387
|
clearInterval(state.keepFreshTimer)
|
|
441
388
|
clearInterval(rootGetters['game/getGameTimer'])
|
|
442
389
|
|
|
443
|
-
updateSource()
|
|
444
|
-
commit('setToken', null)
|
|
390
|
+
$updateSource()
|
|
445
391
|
commit('setAuthorized', false)
|
|
446
392
|
commit('payment/setRefreshBank', false, { root: true })
|
|
447
|
-
cookie.removeToken()
|
|
393
|
+
$cookie.removeToken()
|
|
448
394
|
|
|
449
395
|
// Reset Store
|
|
450
396
|
commit(`activity/resetActivities`, null, { root: true })
|
|
@@ -455,52 +401,46 @@ function createStore(request, ignoreErrorRequest, cookie, updateSource) {
|
|
|
455
401
|
async refreshData({ state, commit, getters, dispatch, rootGetters }, refreshTarget) {
|
|
456
402
|
// 重新請求基礎資料
|
|
457
403
|
try {
|
|
458
|
-
if (
|
|
459
|
-
console.info('[Cuora]
|
|
460
|
-
|
|
461
|
-
await Promise.all([
|
|
462
|
-
await dispatch('getFeeds'),
|
|
463
|
-
await dispatch('activity/fetchActivities', null, { root: true }),
|
|
464
|
-
await dispatch('activity/fetchAchievements', null, { root: true }),
|
|
465
|
-
])
|
|
466
|
-
isRefreshingFlag = false
|
|
467
|
-
} else {
|
|
468
|
-
isRefreshingFlag = false
|
|
469
|
-
console.log('[Cuora] Refresh Ignored')
|
|
404
|
+
if (rootGetters['app/isPlaying'] || state.refreshDataFlag) {
|
|
405
|
+
console.info('[Cuora] Refresh Ignored')
|
|
406
|
+
return
|
|
470
407
|
}
|
|
408
|
+
|
|
409
|
+
commit('setRefreshDataFlag', true)
|
|
410
|
+
console.info('[Cuora] Refreshing Feeds')
|
|
411
|
+
await Promise.all([
|
|
412
|
+
await dispatch('getFeeds'),
|
|
413
|
+
await dispatch('activity/fetchActivities', null, { root: true }),
|
|
414
|
+
await dispatch('activity/fetchAchievements', null, { root: true }),
|
|
415
|
+
])
|
|
471
416
|
} catch (err) {
|
|
472
|
-
isRefreshingFlag = false
|
|
473
417
|
throw err
|
|
418
|
+
} finally {
|
|
419
|
+
commit('setRefreshDataFlag', false)
|
|
474
420
|
}
|
|
475
421
|
},
|
|
476
422
|
async signUp({ state, commit, getters, dispatch, rootGetters }, data) {
|
|
477
423
|
try {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
cookie.setUser(data.username)
|
|
481
|
-
commit(`setLoading`, false)
|
|
424
|
+
const signUpResult = await $loadingRequest(api.register(data))
|
|
425
|
+
$cookie.setUser(data.username)
|
|
482
426
|
return signUpResult
|
|
483
427
|
} catch (err) {
|
|
484
|
-
|
|
485
|
-
console.log('[ ERR ] Signup Fail')
|
|
428
|
+
console.log('[ERR] Signup Fail')
|
|
486
429
|
throw err
|
|
487
430
|
}
|
|
488
431
|
},
|
|
489
432
|
async logout({ state, commit, getters, dispatch, rootGetters }) {
|
|
490
433
|
try {
|
|
491
|
-
commit(`setModal`, null)
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
dispatch('detachToken')
|
|
495
|
-
commit('setAuthorized', false)
|
|
496
|
-
}
|
|
434
|
+
// commit(`setModal`, null)
|
|
435
|
+
await $request(api.logout())
|
|
436
|
+
dispatch('detachToken')
|
|
497
437
|
} catch (err) {
|
|
498
|
-
console.log('[
|
|
438
|
+
console.log('[ERR] Logout Fail')
|
|
499
439
|
}
|
|
500
440
|
},
|
|
501
441
|
async fetchSiteConfig({ state, commit, getters, dispatch, rootGetters }) {
|
|
502
442
|
try {
|
|
503
|
-
const { config } = await request(api.getConfig({ appSecret: clientSecret }))
|
|
443
|
+
const { config } = await $request(api.getConfig({ appSecret: clientSecret }))
|
|
504
444
|
const configObj = JSON.parse(window.atob(config))
|
|
505
445
|
commit('payment/setPaymentMethods', configObj?.paymentMethods || {}, { root: true })
|
|
506
446
|
commit('setSiteConfig', configObj)
|
|
@@ -521,7 +461,7 @@ function createStore(request, ignoreErrorRequest, cookie, updateSource) {
|
|
|
521
461
|
commit('setUA', parser.getResult())
|
|
522
462
|
},
|
|
523
463
|
async getFeeds({ commit, dispatch }) {
|
|
524
|
-
const data = await request(api.feeds())
|
|
464
|
+
const data = await $request(api.feeds())
|
|
525
465
|
commit('information/setAnnouncements', data.announcementList, { root: true })
|
|
526
466
|
commit('information/setBroadcasts', data.broadcastList, { root: true })
|
|
527
467
|
const type = await dispatch('inbox/setSummary', data.mailBoxInfo, { root: true })
|
|
@@ -532,17 +472,17 @@ function createStore(request, ignoreErrorRequest, cookie, updateSource) {
|
|
|
532
472
|
}
|
|
533
473
|
},
|
|
534
474
|
keepAlive({ state, rootGetters, commit, dispatch }) {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
clearInterval(state.keepFreshTimer)
|
|
538
|
-
const keepAliveTimer = setInterval(async () => {
|
|
475
|
+
clearInterval(state.keepUserTimer)
|
|
476
|
+
const keepUserTimer = setInterval(async () => {
|
|
539
477
|
try {
|
|
540
|
-
await dispatch('
|
|
478
|
+
await dispatch('fetchUserInfo')
|
|
541
479
|
} catch (err) {
|
|
542
480
|
console.log(err)
|
|
543
481
|
}
|
|
544
482
|
}, tick * (rootGetters['app/isPlaying'] ? 5 : 1))
|
|
545
|
-
commit('
|
|
483
|
+
commit('setKeepUserTimer', keepUserTimer)
|
|
484
|
+
|
|
485
|
+
clearInterval(state.keepFreshTimer)
|
|
546
486
|
const keepFreshTimer = setInterval(async () => {
|
|
547
487
|
try {
|
|
548
488
|
await dispatch('refreshData')
|
|
@@ -551,12 +491,22 @@ function createStore(request, ignoreErrorRequest, cookie, updateSource) {
|
|
|
551
491
|
}
|
|
552
492
|
}, tick * 10)
|
|
553
493
|
commit('setKeepFreshTimer', keepFreshTimer)
|
|
494
|
+
|
|
495
|
+
clearInterval(rootGetters['game/getGameTimer'])
|
|
496
|
+
const gameTimer = setInterval(async () => {
|
|
497
|
+
try {
|
|
498
|
+
await dispatch('game/examineGame', null, { root: true })
|
|
499
|
+
} catch (err) {
|
|
500
|
+
console.log(err)
|
|
501
|
+
}
|
|
502
|
+
}, tick * 10)
|
|
503
|
+
commit('game/setGameTimer', gameTimer, { root: true })
|
|
554
504
|
},
|
|
555
505
|
},
|
|
556
506
|
}
|
|
557
507
|
}
|
|
558
508
|
|
|
559
509
|
export default (ctx, inject) => {
|
|
560
|
-
const { store, $request, $ignoreErrorRequest, $
|
|
561
|
-
store.registerModule('core', createStore($request, $ignoreErrorRequest, $
|
|
510
|
+
const { store, $request, $ignoreErrorRequest, $loadingRequest, $updateSource, $cookie } = ctx
|
|
511
|
+
store.registerModule('core', createStore({ $request, $ignoreErrorRequest, $loadingRequest, $updateSource, $cookie }))
|
|
562
512
|
}
|
package/plugin/game.js
CHANGED
|
@@ -11,7 +11,7 @@ const api = {
|
|
|
11
11
|
logoutGame: ({ uid_site, provider_id }) => ({ url: 'game/logout', method: 'get', params: { uid_site, provider_id } }),
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function createStore(request, loadingRequest) {
|
|
14
|
+
function createStore({$request, $loadingRequest}) {
|
|
15
15
|
return {
|
|
16
16
|
namespaced: true,
|
|
17
17
|
state: () => ({
|
|
@@ -195,7 +195,7 @@ function createStore(request, loadingRequest) {
|
|
|
195
195
|
setStatements(state, data) {
|
|
196
196
|
state.statements = data
|
|
197
197
|
},
|
|
198
|
-
|
|
198
|
+
setGameTimer(state, timer) {
|
|
199
199
|
state.gameTimer = timer
|
|
200
200
|
},
|
|
201
201
|
},
|
|
@@ -205,7 +205,7 @@ function createStore(request, loadingRequest) {
|
|
|
205
205
|
if (isPlayingGame(currentPath)) return
|
|
206
206
|
|
|
207
207
|
const oldSHA = rootGetters['localStorage/getGameV2SHA']
|
|
208
|
-
const newSHA = await request(api.getGameSHA())
|
|
208
|
+
const newSHA = await $request(api.getGameSHA())
|
|
209
209
|
const isGameChanged = newSHA?.status !== oldSHA?.status
|
|
210
210
|
const isCategoryChanged = newSHA?.category !== oldSHA?.category
|
|
211
211
|
|
|
@@ -213,7 +213,7 @@ function createStore(request, loadingRequest) {
|
|
|
213
213
|
console.log(`[Gamehall] game changed`, newSHA?.status)
|
|
214
214
|
commit(`localStorage/setGameV2SHA`, newSHA, { root: true })
|
|
215
215
|
const oldStatus = rootGetters['localStorage/getGameV2Status']
|
|
216
|
-
const newStatus = await request(api.getGameStatus())
|
|
216
|
+
const newStatus = await $request(api.getGameStatus())
|
|
217
217
|
const infoChangedList = extractInfoChangedGames(oldStatus, newStatus)
|
|
218
218
|
commit(`localStorage/setGameV2Status`, newStatus, { root: true })
|
|
219
219
|
|
|
@@ -244,7 +244,7 @@ function createStore(request, loadingRequest) {
|
|
|
244
244
|
}
|
|
245
245
|
},
|
|
246
246
|
async addGameOption({ getters, commit, dispatch }, code) {
|
|
247
|
-
const option = await request(api.getGameMap(code))
|
|
247
|
+
const option = await $request(api.getGameMap(code))
|
|
248
248
|
if (Object.keys(option || {}).length > 0) {
|
|
249
249
|
commit('_appendGameMap', { key: code, value: option })
|
|
250
250
|
commit('_appendInverseGameMap', { key: code, value: option })
|
|
@@ -266,9 +266,9 @@ function createStore(request, loadingRequest) {
|
|
|
266
266
|
if (!isInLocalStorage || fullScan === true) {
|
|
267
267
|
// 首次使用
|
|
268
268
|
const [newSHA, newStatus, option] = await Promise.all([
|
|
269
|
-
request(api.getGameSHA()),
|
|
270
|
-
request(api.getGameStatus()),
|
|
271
|
-
request(api.getGameMap()),
|
|
269
|
+
$request(api.getGameSHA()),
|
|
270
|
+
$request(api.getGameStatus()),
|
|
271
|
+
$request(api.getGameMap()),
|
|
272
272
|
])
|
|
273
273
|
commit('localStorage/setGameV2SHA', newSHA, { root: true })
|
|
274
274
|
commit('localStorage/setGameV2Status', newStatus, { root: true })
|
|
@@ -287,7 +287,7 @@ function createStore(request, loadingRequest) {
|
|
|
287
287
|
|
|
288
288
|
if (isInGamehall(currentPath)) {
|
|
289
289
|
commit('_setCategoryId', id)
|
|
290
|
-
const category = await request(api.getGameCategory({ id }))
|
|
290
|
+
const category = await $request(api.getGameCategory({ id }))
|
|
291
291
|
const categoryChildren = category?.list || []
|
|
292
292
|
|
|
293
293
|
if (state.primaryCategoryList.map((item) => item.category).includes(category.name)) {
|
|
@@ -299,7 +299,7 @@ function createStore(request, loadingRequest) {
|
|
|
299
299
|
} else {
|
|
300
300
|
commit('game/_setPrimaryCategoryList', categoryChildren, { root: true })
|
|
301
301
|
const favoriteId = categoryChildren.find((item) => item.category === 'SYSTEM_MY_FAVORITE').id
|
|
302
|
-
const category = await request(api.getGameCategory({ id: favoriteId }))
|
|
302
|
+
const category = await $request(api.getGameCategory({ id: favoriteId }))
|
|
303
303
|
const list = category?.list || []
|
|
304
304
|
commit('_setFavorite', { ...state.favorite, code: favoriteId, list: list.map((item) => item.g) })
|
|
305
305
|
}
|
|
@@ -309,7 +309,7 @@ function createStore(request, loadingRequest) {
|
|
|
309
309
|
try {
|
|
310
310
|
const appendedList = [...getters.getFavoriteList, code]
|
|
311
311
|
commit('_setFavoriteList', appendedList)
|
|
312
|
-
await request(api.addFavoriteGame({ games: [code] }))
|
|
312
|
+
await $request(api.addFavoriteGame({ games: [code] }))
|
|
313
313
|
} catch (err) {
|
|
314
314
|
console.log(err)
|
|
315
315
|
const restoredList = getters.getFavoriteList.filter((item) => item !== code)
|
|
@@ -320,7 +320,7 @@ function createStore(request, loadingRequest) {
|
|
|
320
320
|
try {
|
|
321
321
|
const reservedList = getters.getFavoriteList.filter((item) => item !== code)
|
|
322
322
|
commit('_setFavoriteList', reservedList)
|
|
323
|
-
await request(api.removeFavoriteGame({ games: [code] }))
|
|
323
|
+
await $request(api.removeFavoriteGame({ games: [code] }))
|
|
324
324
|
} catch (err) {
|
|
325
325
|
console.log(err)
|
|
326
326
|
const restoredList = [...getters.getFavoriteList, code]
|
|
@@ -330,7 +330,7 @@ function createStore(request, loadingRequest) {
|
|
|
330
330
|
async getStatements({ state, commit, getters, dispatch, rootState, rootGetters }) {
|
|
331
331
|
try {
|
|
332
332
|
commit(`core/setLoading`, true, { root: true })
|
|
333
|
-
const data = await request(api.getStatements())
|
|
333
|
+
const data = await $request(api.getStatements())
|
|
334
334
|
commit(`setStatements`, data)
|
|
335
335
|
commit(`core/setLoading`, false, { root: true })
|
|
336
336
|
return data
|
|
@@ -340,21 +340,21 @@ function createStore(request, loadingRequest) {
|
|
|
340
340
|
}
|
|
341
341
|
},
|
|
342
342
|
async setPreference({}, defaultCategory) {
|
|
343
|
-
return await request(api.setPreference({ defaultCategory }))
|
|
344
|
-
},
|
|
345
|
-
executeGameTimer({ state, commit, dispatch }) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
},
|
|
343
|
+
return await $request(api.setPreference({ defaultCategory }))
|
|
344
|
+
},
|
|
345
|
+
// executeGameTimer({ state, commit, dispatch }) {
|
|
346
|
+
// clearInterval(state.gameTimer)
|
|
347
|
+
// dispatch('examineGame')
|
|
348
|
+
// const timer = setInterval(() => {
|
|
349
|
+
// dispatch('examineGame')
|
|
350
|
+
// }, 20000)
|
|
351
|
+
// commit('setGameTimer', timer)
|
|
352
|
+
// },
|
|
353
353
|
async exitGame({ commit, rootGetters }) {
|
|
354
354
|
const uid_site = rootGetters['user/userInfo'].uid_site
|
|
355
355
|
const provider_id = rootGetters['gameStore/getCurrentProvider']
|
|
356
356
|
if (provider_id) {
|
|
357
|
-
await loadingRequest(api.logoutGame({ uid_site, provider_id }))
|
|
357
|
+
await $loadingRequest(api.logoutGame({ uid_site, provider_id }))
|
|
358
358
|
}
|
|
359
359
|
commit('setCurrentProvider', null)
|
|
360
360
|
commit('setCurrentGameId', null)
|
|
@@ -386,7 +386,7 @@ function createStore(request, loadingRequest) {
|
|
|
386
386
|
? `${window.location.origin}/return`
|
|
387
387
|
: window.location.href, // For providers to return.
|
|
388
388
|
}
|
|
389
|
-
const data = await request(api.playGame(params))
|
|
389
|
+
const data = await $request(api.playGame(params))
|
|
390
390
|
commit('gameMatching', false)
|
|
391
391
|
const targetUrl = data.redirect_url
|
|
392
392
|
commit('setGameURL', targetUrl)
|
|
@@ -409,7 +409,7 @@ function createStore(request, loadingRequest) {
|
|
|
409
409
|
|
|
410
410
|
export default (ctx, inject) => {
|
|
411
411
|
const { store, $request, $loadingRequest } = ctx
|
|
412
|
-
store.registerModule('game', createStore($request, $loadingRequest))
|
|
412
|
+
store.registerModule('game', createStore({$request, $loadingRequest}))
|
|
413
413
|
}
|
|
414
414
|
|
|
415
415
|
function extractInfoChangedGames(oldStatus, newStatus) {
|
package/plugin/inbox.js
CHANGED
|
@@ -19,7 +19,7 @@ const api = {
|
|
|
19
19
|
deleteMessage: ({ mid, isDelete }) => ({ url: 'mailbox/deleteMessage', method: 'post', params: { mid, isDelete } }),
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
function createStore(request) {
|
|
22
|
+
function createStore({$request}) {
|
|
23
23
|
return {
|
|
24
24
|
namespaced: true,
|
|
25
25
|
state: () => ({
|
|
@@ -60,6 +60,11 @@ function createStore(request) {
|
|
|
60
60
|
_getTabContent(state, getters) {
|
|
61
61
|
return state.inbox.find((item) => item.tab === state.tab) || {}
|
|
62
62
|
},
|
|
63
|
+
shouldOpenInbox(state, getters, rootState, rootGetters) {
|
|
64
|
+
const isEnable = rootGetters['core/getSiteConfig'].mailboxEnable === '1'
|
|
65
|
+
const isModalOpening = rootGetters['core/getModal']?.type
|
|
66
|
+
return isEnable && !state.isCrash && !isModalOpening && getters.hasSystemMessage
|
|
67
|
+
}
|
|
63
68
|
},
|
|
64
69
|
mutations: {
|
|
65
70
|
_setSummary(state, data) {
|
|
@@ -89,7 +94,7 @@ function createStore(request) {
|
|
|
89
94
|
},
|
|
90
95
|
actions: {
|
|
91
96
|
async initialize({ state, getters, commit, dispatch }) {
|
|
92
|
-
const { data = [] } = await request(api.getMessageTypes())
|
|
97
|
+
const { data = [] } = await $request(api.getMessageTypes())
|
|
93
98
|
const tabList = data?.map((item) => item.type)
|
|
94
99
|
const inbox = tabList.map((type) => ({ tab: type, data: [], page: -1 }))
|
|
95
100
|
commit('_setTabList', tabList)
|
|
@@ -107,7 +112,7 @@ function createStore(request) {
|
|
|
107
112
|
|
|
108
113
|
if (!totalPage || maxIndex > nextIndex) {
|
|
109
114
|
try {
|
|
110
|
-
const data = await request(api.getMessageList({ type: tab, page: nextIndex }))
|
|
115
|
+
const data = await $request(api.getMessageList({ type: tab, page: nextIndex }))
|
|
111
116
|
if (data.data.length === 0) {
|
|
112
117
|
complete()
|
|
113
118
|
return
|
|
@@ -199,7 +204,7 @@ function createStore(request) {
|
|
|
199
204
|
}
|
|
200
205
|
})
|
|
201
206
|
commit('_setInbox', cloneInbox)
|
|
202
|
-
request(api.updateMessage({ groupId: message.groupId, isRead: true }))
|
|
207
|
+
$request(api.updateMessage({ groupId: message.groupId, isRead: true }))
|
|
203
208
|
},
|
|
204
209
|
},
|
|
205
210
|
}
|
|
@@ -207,5 +212,5 @@ function createStore(request) {
|
|
|
207
212
|
|
|
208
213
|
export default (ctx, inject) => {
|
|
209
214
|
const { store, $request } = ctx
|
|
210
|
-
store.registerModule('inbox', createStore($request))
|
|
215
|
+
store.registerModule('inbox', createStore({$request}))
|
|
211
216
|
}
|
package/plugin/information.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function createStore(request) {
|
|
1
|
+
function createStore({$request}) {
|
|
2
2
|
return {
|
|
3
3
|
namespaced: true,
|
|
4
4
|
state: () => ({
|
|
@@ -53,5 +53,5 @@ function createStore(request) {
|
|
|
53
53
|
|
|
54
54
|
export default (ctx, inject) => {
|
|
55
55
|
const { store, $request } = ctx
|
|
56
|
-
store.registerModule('information', createStore($request))
|
|
56
|
+
store.registerModule('information', createStore({$request}))
|
|
57
57
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const timeout = 60 * 1000
|
|
2
|
+
export default async ({ app, store, $cuoraConfig }, inject) => {
|
|
3
|
+
if (!$cuoraConfig) {
|
|
4
|
+
throw Error('network plugin must be after CuoraConfig module')
|
|
5
|
+
}
|
|
6
|
+
const url = `https://storage.googleapis.com/btc-storage-rd/site_resources/${$cuoraConfig.clientId}/target/target.json`
|
|
7
|
+
const networkTester = new NetworkTester(url)
|
|
8
|
+
$cuoraConfig.apiURL = await networkTester.test()
|
|
9
|
+
setInterval(async () => {
|
|
10
|
+
$cuoraConfig.apiURL = await networkTester.test()
|
|
11
|
+
}, timeout)
|
|
12
|
+
inject('networkTester', networkTester)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
class NetworkTester {
|
|
16
|
+
constructor(url) {
|
|
17
|
+
this.url = url
|
|
18
|
+
this.host = []
|
|
19
|
+
this.cdn = []
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async init() {
|
|
23
|
+
const target = await fetch(this.url)
|
|
24
|
+
const { host, cdn } = await target.json()
|
|
25
|
+
this.host = host
|
|
26
|
+
this.cdn = cdn
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async test() {
|
|
30
|
+
try {
|
|
31
|
+
if (this.host.length === 0) {
|
|
32
|
+
await this.init()
|
|
33
|
+
}
|
|
34
|
+
const { url, index } = await Promise.any(
|
|
35
|
+
this.host.map((url, i) => {
|
|
36
|
+
return this.ping(url, i)
|
|
37
|
+
})
|
|
38
|
+
)
|
|
39
|
+
console.info(`[Network] Host ${index} is chosen. (${url})`)
|
|
40
|
+
return url
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error('[Network] Network Test Fail.', error)
|
|
43
|
+
return this.host[0]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async ping(url, index) {
|
|
48
|
+
let ts, response
|
|
49
|
+
try {
|
|
50
|
+
ts = new Date().getTime()
|
|
51
|
+
response = await fetch(`${url}/health?ts=${ts}`)
|
|
52
|
+
return { url, index }
|
|
53
|
+
} finally {
|
|
54
|
+
const speed = new Date().getTime() - ts
|
|
55
|
+
const status = !!response?.ok ? 'Success' : 'Failure'
|
|
56
|
+
console.info(`[Network] Host: ${index}, URL: ${url}, Status: ${status}, Speed: ${speed}ms`)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
package/plugin/payment.js
CHANGED
|
@@ -31,7 +31,7 @@ const api = {
|
|
|
31
31
|
mergeWallet: () => ({ url: 'payment/mergeWallet', method: 'post' }),
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
function createStore(request, loadingRequest, ignoreErrorRequest) {
|
|
34
|
+
function createStore({ $request, $loadingRequest, $ignoreErrorRequest }) {
|
|
35
35
|
return {
|
|
36
36
|
namespaced: true,
|
|
37
37
|
state: () => ({
|
|
@@ -99,7 +99,7 @@ function createStore(request, loadingRequest, ignoreErrorRequest) {
|
|
|
99
99
|
async getPaymentHistory({ commit, getters }) {
|
|
100
100
|
try {
|
|
101
101
|
commit(`core/setLoading`, true, { root: true })
|
|
102
|
-
const data = await request(api.getPaymentHistory())
|
|
102
|
+
const data = await $request(api.getPaymentHistory())
|
|
103
103
|
commit(`core/setLoading`, false, { root: true })
|
|
104
104
|
return data
|
|
105
105
|
} catch (err) {
|
|
@@ -110,7 +110,7 @@ function createStore(request, loadingRequest, ignoreErrorRequest) {
|
|
|
110
110
|
async sentAward({ commit, getters, dispatch }, rewardTarget) {
|
|
111
111
|
try {
|
|
112
112
|
commit(`core/setLoading`, true, { root: true })
|
|
113
|
-
const { data } = await request(api.sentAward({ appSecret: clientSecret, ...rewardTarget }))
|
|
113
|
+
const { data } = await $request(api.sentAward({ appSecret: clientSecret, ...rewardTarget }))
|
|
114
114
|
await dispatch('activity/fetchActivities', null, { root: true })
|
|
115
115
|
commit(`core/setLoading`, false, { root: true })
|
|
116
116
|
return data
|
|
@@ -122,7 +122,7 @@ function createStore(request, loadingRequest, ignoreErrorRequest) {
|
|
|
122
122
|
async getReward({ commit, getters, dispatch }, rewardTarget) {
|
|
123
123
|
try {
|
|
124
124
|
commit(`core/setLoading`, true, { root: true })
|
|
125
|
-
const { data } = await request(api.getReward({ appSecret: clientSecret, ...rewardTarget }))
|
|
125
|
+
const { data } = await $request(api.getReward({ appSecret: clientSecret, ...rewardTarget }))
|
|
126
126
|
await dispatch('activity/fetchActivities', null, { root: true })
|
|
127
127
|
commit(`core/setLoading`, false, { root: true })
|
|
128
128
|
return data
|
|
@@ -133,7 +133,7 @@ function createStore(request, loadingRequest, ignoreErrorRequest) {
|
|
|
133
133
|
},
|
|
134
134
|
async getRewardList({ commit }) {
|
|
135
135
|
try {
|
|
136
|
-
const rewards = await request(api.getRewardList({ count: 30, appSecret: clientSecret }))
|
|
136
|
+
const rewards = await $request(api.getRewardList({ count: 30, appSecret: clientSecret }))
|
|
137
137
|
commit(`activity/setActivities`, { rewards: rewards?.data || {} }, { root: true })
|
|
138
138
|
} catch (err) {
|
|
139
139
|
console.log(err)
|
|
@@ -142,7 +142,7 @@ function createStore(request, loadingRequest, ignoreErrorRequest) {
|
|
|
142
142
|
async getPaymentInfo({ commit }) {
|
|
143
143
|
try {
|
|
144
144
|
commit(`core/setLoading`, true, { root: true })
|
|
145
|
-
const paymentInfo = await request(api.getPaymentInfo())
|
|
145
|
+
const paymentInfo = await $request(api.getPaymentInfo())
|
|
146
146
|
commit(`core/setLoading`, false, { root: true })
|
|
147
147
|
return paymentInfo
|
|
148
148
|
} catch (err) {
|
|
@@ -151,13 +151,13 @@ function createStore(request, loadingRequest, ignoreErrorRequest) {
|
|
|
151
151
|
}
|
|
152
152
|
},
|
|
153
153
|
async updatePaymentInfo({ dispatch }, payload) {
|
|
154
|
-
const data = loadingRequest(api.updatePaymentInfo(payload))
|
|
155
|
-
await dispatch('core/
|
|
154
|
+
const data = $loadingRequest(api.updatePaymentInfo(payload))
|
|
155
|
+
await dispatch('core/fetchUserInfo', null, { root: true })
|
|
156
156
|
return data
|
|
157
157
|
},
|
|
158
158
|
async fetchAvailableBanks({ commit }, paymentMethod = 'amb') {
|
|
159
159
|
try {
|
|
160
|
-
const data = await request(api.getBankList(paymentMethod))
|
|
160
|
+
const data = await $request(api.getBankList(paymentMethod))
|
|
161
161
|
commit(`setAvailableBanks`, data)
|
|
162
162
|
return data
|
|
163
163
|
} catch (err) {
|
|
@@ -169,7 +169,7 @@ function createStore(request, loadingRequest, ignoreErrorRequest) {
|
|
|
169
169
|
const status = await dispatch('core/checkStatus', null, { root: true })
|
|
170
170
|
if (status === true) {
|
|
171
171
|
commit(`core/setLoading`, true, { root: true })
|
|
172
|
-
const data = await request(api.makeTransaction({ type, payload, paymentMethod }))
|
|
172
|
+
const data = await $request(api.makeTransaction({ type, payload, paymentMethod }))
|
|
173
173
|
commit(`core/setLoading`, false, { root: true })
|
|
174
174
|
return data
|
|
175
175
|
} else {
|
|
@@ -179,13 +179,17 @@ function createStore(request, loadingRequest, ignoreErrorRequest) {
|
|
|
179
179
|
commit(`core/setLoading`, false, { root: true })
|
|
180
180
|
}
|
|
181
181
|
},
|
|
182
|
-
async
|
|
183
|
-
|
|
182
|
+
async refreshAmbBankAccount({ commit, getters, dispatch }) {
|
|
183
|
+
const done = getters.getRefreshBank
|
|
184
|
+
if (!done) {
|
|
185
|
+
commit('setRefreshBank', true)
|
|
186
|
+
await $ignoreErrorRequest(api.makeTransaction( { type: 'DEPOSIT', payload: null, paymentMethod: 'amb' }))
|
|
187
|
+
}
|
|
184
188
|
},
|
|
185
189
|
async checkTransaction({ commit, dispatch }, paymentMethod) {
|
|
186
190
|
try {
|
|
187
191
|
commit(`core/setLoading`, true, { root: true })
|
|
188
|
-
const data = await request(api.checkTransaction(paymentMethod))
|
|
192
|
+
const data = await $request(api.checkTransaction(paymentMethod))
|
|
189
193
|
commit(`core/setLoading`, false, { root: true })
|
|
190
194
|
return data
|
|
191
195
|
} catch (err) {
|
|
@@ -205,24 +209,24 @@ function createStore(request, loadingRequest, ignoreErrorRequest) {
|
|
|
205
209
|
}
|
|
206
210
|
},
|
|
207
211
|
async collect({ commit, dispatch }, activityNo) {
|
|
208
|
-
const { data } = await loadingRequest(api.collect({ appSecret: clientSecret }))
|
|
212
|
+
const { data } = await $loadingRequest(api.collect({ appSecret: clientSecret }))
|
|
209
213
|
await dispatch('getActivityDetail', activityNo, { root: true })
|
|
210
214
|
},
|
|
211
215
|
async setBonusSetting({ commit, dispatch }, data) {
|
|
212
|
-
return await loadingRequest(api.setBonusSetting({ bonus: data }))
|
|
216
|
+
return await $loadingRequest(api.setBonusSetting({ bonus: data }))
|
|
213
217
|
},
|
|
214
218
|
async getCurrentWithdrawRule({ commit, dispatch }) {
|
|
215
|
-
const currentRule = await request(api.getCurrentWithdrawRule())
|
|
219
|
+
const currentRule = await $request(api.getCurrentWithdrawRule())
|
|
216
220
|
return ruleFormatter(currentRule.rules)
|
|
217
221
|
},
|
|
218
222
|
async convertFreeCredit({ dispatch }, exchangeType) {
|
|
219
|
-
const convertResult = await loadingRequest(api.convertFreeCredit({ exchangeType }))
|
|
220
|
-
await dispatch('core/
|
|
223
|
+
const convertResult = await $loadingRequest(api.convertFreeCredit({ exchangeType }))
|
|
224
|
+
await dispatch('core/fetchUserInfo', null, { root: true })
|
|
221
225
|
return convertResult
|
|
222
226
|
},
|
|
223
227
|
async mergeWallet({ dispatch }) {
|
|
224
|
-
const convertResult = await loadingRequest(api.mergeWallet())
|
|
225
|
-
await dispatch('core/
|
|
228
|
+
const convertResult = await $loadingRequest(api.mergeWallet())
|
|
229
|
+
await dispatch('core/fetchUserInfo', null, { root: true })
|
|
226
230
|
return convertResult
|
|
227
231
|
},
|
|
228
232
|
},
|
|
@@ -231,7 +235,7 @@ function createStore(request, loadingRequest, ignoreErrorRequest) {
|
|
|
231
235
|
|
|
232
236
|
export default (ctx, inject) => {
|
|
233
237
|
const { store, $request, $loadingRequest, $ignoreErrorRequest } = ctx
|
|
234
|
-
store.registerModule('payment', createStore($request, $loadingRequest, $ignoreErrorRequest))
|
|
238
|
+
store.registerModule('payment', createStore({ $request, $loadingRequest, $ignoreErrorRequest }))
|
|
235
239
|
}
|
|
236
240
|
|
|
237
241
|
function ruleFormatter(rules) {
|
package/plugin/request.js
CHANGED
|
@@ -2,20 +2,43 @@ import pickBy from 'lodash/pickBy'
|
|
|
2
2
|
import Cookies from 'universal-cookie'
|
|
3
3
|
import urljoin from 'url-join'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
class CuoraConfig {
|
|
6
|
+
constructor({apiURL, apiVersion, clientId, product, version}) {
|
|
7
|
+
this._apiURL = apiURL
|
|
8
|
+
this._apiVersion = apiVersion
|
|
9
|
+
this._clientId = clientId
|
|
10
|
+
this.product = product
|
|
11
|
+
this.version = version
|
|
12
|
+
this.fullURL = urljoin(this._apiURL, this._apiVersion, this._clientId)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
set apiURL(url) {
|
|
16
|
+
this._apiURL = url
|
|
17
|
+
this.fullURL = urljoin(this._apiURL, this._apiVersion, this._clientId)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get apiURL() {
|
|
21
|
+
return this._apiURL
|
|
22
|
+
}
|
|
10
23
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const version = 'v<%= options.version %>'
|
|
24
|
+
set apiVersion(version) {
|
|
25
|
+
this._apiVersion = version
|
|
26
|
+
this.fullURL = urljoin(this._apiURL, this._apiVersion, this._clientId)
|
|
27
|
+
}
|
|
16
28
|
|
|
17
|
-
|
|
18
|
-
|
|
29
|
+
get apiVersion() {
|
|
30
|
+
return this._apiVersion
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
set clientId(id) {
|
|
34
|
+
this._clientId = id
|
|
35
|
+
this.fullURL = urljoin(this._apiURL, this._apiVersion, this._clientId)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get clientId() {
|
|
39
|
+
return this._clientId
|
|
40
|
+
}
|
|
41
|
+
}
|
|
19
42
|
|
|
20
43
|
class Cookie {
|
|
21
44
|
constructor(tokenKey) {
|
|
@@ -30,6 +53,13 @@ class Cookie {
|
|
|
30
53
|
})
|
|
31
54
|
}
|
|
32
55
|
|
|
56
|
+
prolongToken() {
|
|
57
|
+
const token = this.getToken()
|
|
58
|
+
if (token) {
|
|
59
|
+
this.setToken(token)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
33
63
|
getToken() {
|
|
34
64
|
return this.cookies.get(this.tokenKey)
|
|
35
65
|
}
|
|
@@ -53,25 +83,30 @@ class Cookie {
|
|
|
53
83
|
}
|
|
54
84
|
}
|
|
55
85
|
|
|
86
|
+
const cuoraConfig = new CuoraConfig({
|
|
87
|
+
apiURL: process.env.API_URL,
|
|
88
|
+
apiVersion: process.env.API_VERSION,
|
|
89
|
+
clientId: process.env.CLIENT_ID,
|
|
90
|
+
product: 'pwa',
|
|
91
|
+
version: 'v<%= options.version %>'
|
|
92
|
+
})
|
|
93
|
+
const tokenKey = `cuora_${cuoraConfig.clientId}`
|
|
56
94
|
const cookie = new Cookie(tokenKey)
|
|
57
95
|
|
|
58
|
-
function createMethods($axios, store) {
|
|
59
|
-
const instance = $axios.create({
|
|
60
|
-
baseURL: fullURL,
|
|
61
|
-
})
|
|
96
|
+
function createMethods($axios, store, cuoraConfig) {
|
|
62
97
|
const CancelToken = $axios.CancelToken
|
|
63
98
|
let source = CancelToken.source()
|
|
64
99
|
|
|
65
|
-
|
|
66
|
-
config.headers['X-TH1GAMES-VERSION'] = version
|
|
67
|
-
config.headers['X-TH1GAMES-PLATFORM'] = product
|
|
100
|
+
$axios.interceptors.request.use((config) => {
|
|
101
|
+
config.headers['X-TH1GAMES-VERSION'] = cuoraConfig.version
|
|
102
|
+
config.headers['X-TH1GAMES-PLATFORM'] = cuoraConfig.product
|
|
68
103
|
if (cookie.getToken()) {
|
|
69
104
|
config.headers.Authorization = cookie.getToken()
|
|
70
105
|
}
|
|
71
106
|
return config
|
|
72
107
|
})
|
|
73
108
|
|
|
74
|
-
|
|
109
|
+
$axios.interceptors.response.use(
|
|
75
110
|
function (response) {
|
|
76
111
|
if (response.data.error) {
|
|
77
112
|
return Promise.reject(response.data.error)
|
|
@@ -90,8 +125,9 @@ function createMethods($axios, store) {
|
|
|
90
125
|
normal: async (req, customToken) => {
|
|
91
126
|
try {
|
|
92
127
|
const cancelToken = customToken || source.token
|
|
93
|
-
|
|
94
|
-
const
|
|
128
|
+
checkToken(req, cookie.getToken())
|
|
129
|
+
const config = createConfig(cuoraConfig, req, cancelToken)
|
|
130
|
+
const { data } = await $axios.request(config)
|
|
95
131
|
return data
|
|
96
132
|
} catch (error) {
|
|
97
133
|
if (error.code) {
|
|
@@ -104,8 +140,9 @@ function createMethods($axios, store) {
|
|
|
104
140
|
try {
|
|
105
141
|
store.commit('core/setLoading', true)
|
|
106
142
|
const cancelToken = customToken || source.token
|
|
107
|
-
|
|
108
|
-
const
|
|
143
|
+
checkToken(req, cookie.getToken())
|
|
144
|
+
const config = createConfig(cuoraConfig, req, cancelToken)
|
|
145
|
+
const { data } = await $axios.request(config)
|
|
109
146
|
return data
|
|
110
147
|
} catch (error) {
|
|
111
148
|
if (error.code) {
|
|
@@ -119,8 +156,9 @@ function createMethods($axios, store) {
|
|
|
119
156
|
ignoreError: async (req, customToken) => {
|
|
120
157
|
try {
|
|
121
158
|
const cancelToken = customToken || source.token
|
|
122
|
-
|
|
123
|
-
const
|
|
159
|
+
checkToken(req, cookie.getToken())
|
|
160
|
+
const config = createConfig(cuoraConfig, req, cancelToken)
|
|
161
|
+
const { data } = await $axios.request(config)
|
|
124
162
|
return data
|
|
125
163
|
} catch (error) {
|
|
126
164
|
console.log('[ Ignore Error ] ', error)
|
|
@@ -136,9 +174,9 @@ function createMethods($axios, store) {
|
|
|
136
174
|
}
|
|
137
175
|
}
|
|
138
176
|
|
|
139
|
-
function createConfig(req, cancelToken) {
|
|
177
|
+
function createConfig(cuoraConfig, req, cancelToken) {
|
|
140
178
|
const { method, url, params } = req
|
|
141
|
-
const config = { method, url, cancelToken }
|
|
179
|
+
const config = { baseURL: cuoraConfig.fullURL, method, url, cancelToken, public: req.public }
|
|
142
180
|
if (method.toUpperCase() === 'GET') {
|
|
143
181
|
config.params = pickBy(params, checkValuable)
|
|
144
182
|
} else {
|
|
@@ -151,14 +189,21 @@ function checkValuable(value) {
|
|
|
151
189
|
return value !== undefined && value !== null
|
|
152
190
|
}
|
|
153
191
|
|
|
192
|
+
function checkToken(req, token) {
|
|
193
|
+
if (!req.public && !token) {
|
|
194
|
+
throw { code: 'ERR_A103', url: req.url }
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
154
198
|
export default (ctx, inject) => {
|
|
155
199
|
const { $axios, store } = ctx
|
|
156
|
-
const { normal, loading, ignoreError, updateSource, generateSource } = createMethods($axios, store)
|
|
200
|
+
const { normal, loading, ignoreError, updateSource, generateSource } = createMethods($axios, store, cuoraConfig)
|
|
157
201
|
inject('request', normal)
|
|
158
202
|
inject('loadingRequest', loading)
|
|
159
203
|
inject('ignoreErrorRequest', ignoreError)
|
|
160
204
|
inject('updateSource', updateSource)
|
|
161
205
|
inject('generateSource', generateSource)
|
|
162
206
|
inject('cookie', cookie)
|
|
163
|
-
inject('fullURL', fullURL)
|
|
207
|
+
inject('fullURL', cuoraConfig.fullURL)
|
|
208
|
+
inject('cuoraConfig', cuoraConfig)
|
|
164
209
|
}
|
package/plugin/search.js
CHANGED
|
@@ -22,7 +22,7 @@ const api = {
|
|
|
22
22
|
|
|
23
23
|
let source = null
|
|
24
24
|
|
|
25
|
-
function createStore(request, generateSource) {
|
|
25
|
+
function createStore({$request, $generateSource}) {
|
|
26
26
|
return {
|
|
27
27
|
namespaced: true,
|
|
28
28
|
state: () => ({
|
|
@@ -229,14 +229,14 @@ function createStore(request, generateSource) {
|
|
|
229
229
|
if (source) {
|
|
230
230
|
source.cancel('Requests Cancelled')
|
|
231
231
|
}
|
|
232
|
-
source = generateSource()
|
|
233
|
-
return await request(api.getGameTags({ q }), source.token)
|
|
232
|
+
source = $generateSource()
|
|
233
|
+
return await $request(api.getGameTags({ q }), source.token)
|
|
234
234
|
},
|
|
235
235
|
async getGameSearchList({}, { id, index, q, click, clickDefault }) {
|
|
236
|
-
return await request(api.getGameSearchList({ id, index, q, click, clickDefault }))
|
|
236
|
+
return await $request(api.getGameSearchList({ id, index, q, click, clickDefault }))
|
|
237
237
|
},
|
|
238
238
|
async setGameSearchTrace({}, { traceId, tagId, tagIndex, gameCode, gameCodeIndex, query, click }) {
|
|
239
|
-
return await request(
|
|
239
|
+
return await $request(
|
|
240
240
|
api.setGameSearchTrace({
|
|
241
241
|
traceId,
|
|
242
242
|
tagId,
|
|
@@ -254,7 +254,7 @@ function createStore(request, generateSource) {
|
|
|
254
254
|
|
|
255
255
|
export default (ctx, inject) => {
|
|
256
256
|
const { store, $request, $generateSource } = ctx
|
|
257
|
-
store.registerModule('search', createStore($request, $generateSource))
|
|
257
|
+
store.registerModule('search', createStore({$request, $generateSource}))
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
function wait(interval, fn) {
|
package/plugin/user.js
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
import qs from 'qs'
|
|
2
2
|
|
|
3
3
|
const api = {
|
|
4
|
+
getUserInfo: () => ({ url: 'self', method: 'get' }),
|
|
4
5
|
updateUserInfo: (data) => ({ url: 'self', method: 'post', params: data }),
|
|
5
6
|
changePassword: (data) => ({ url: 'settings/password', method: 'post', params: data }),
|
|
6
7
|
reset: ({ requestId, number }) => ({ url: 'reset', method: 'post', params: { requestId, number } }),
|
|
7
8
|
getAffiliate: () => ({ url: 'affiliate', method: 'get' }),
|
|
8
9
|
postAffiliate: ({ affiliateCode }) => ({ url: 'affiliate', method: 'post', params: { affiliateCode } }),
|
|
9
|
-
passwordRecovery: (recoveryData) => ({ url: () => 'recovery', method: 'post', params: recoveryData }),
|
|
10
|
-
passwordAbandon: ({number}) => ({
|
|
10
|
+
passwordRecovery: (recoveryData) => ({ url: () => 'recovery', method: 'post', params: recoveryData, public: true }),
|
|
11
|
+
passwordAbandon: ({ number }) => ({
|
|
12
|
+
url: () => 'recovery/abandon',
|
|
13
|
+
method: 'post',
|
|
14
|
+
params: { number },
|
|
15
|
+
public: true,
|
|
16
|
+
}),
|
|
11
17
|
passwordAcknowledge: (acknowledgeData) => ({
|
|
12
18
|
url: () => 'recovery/acknowledge',
|
|
13
19
|
method: 'post',
|
|
14
20
|
params: acknowledgeData,
|
|
21
|
+
public: true,
|
|
15
22
|
}),
|
|
16
23
|
verify: () => ({ url: 'verify', method: 'post' }),
|
|
17
24
|
acknowledge: ({ requestId, code }) => ({ url: 'acknowledge', method: 'post', params: { requestId, code } }),
|
|
18
25
|
}
|
|
19
26
|
|
|
20
|
-
function createStore(request, loadingRequest, fullURL) {
|
|
27
|
+
function createStore({ $request, $loadingRequest, $fullURL }) {
|
|
21
28
|
return {
|
|
22
29
|
namespaced: true,
|
|
23
30
|
state: () => ({
|
|
@@ -25,6 +32,7 @@ function createStore(request, loadingRequest, fullURL) {
|
|
|
25
32
|
savedLevel: null,
|
|
26
33
|
isInline: false,
|
|
27
34
|
recoveryData: {},
|
|
35
|
+
userInfoFlag: false,
|
|
28
36
|
}),
|
|
29
37
|
getters: {
|
|
30
38
|
isLocked(state, getters) {
|
|
@@ -96,70 +104,74 @@ function createStore(request, loadingRequest, fullURL) {
|
|
|
96
104
|
setRecoveryData(state, data) {
|
|
97
105
|
state.recoveryData = data
|
|
98
106
|
},
|
|
107
|
+
setUserInfoFlag(state, data) {
|
|
108
|
+
state.userInfoFlag = data
|
|
109
|
+
},
|
|
99
110
|
},
|
|
100
111
|
actions: {
|
|
101
112
|
async modifyUserInfo({ commit }, payload) {
|
|
102
113
|
try {
|
|
103
|
-
|
|
104
|
-
const data = await request(api.updateUserInfo(payload))
|
|
105
|
-
commit(`core/setLoading`, false, { root: true })
|
|
106
|
-
return data
|
|
114
|
+
return await $loadingRequest(api.updateUserInfo(payload))
|
|
107
115
|
} catch (err) {
|
|
108
|
-
commit(`core/setLoading`, false, { root: true })
|
|
109
116
|
console.log(err)
|
|
110
117
|
}
|
|
111
118
|
},
|
|
112
|
-
async
|
|
113
|
-
|
|
114
|
-
commit(
|
|
115
|
-
const
|
|
116
|
-
commit(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
async getUserInfo({ state, getters, commit }) {
|
|
120
|
+
if (!state.userInfoFlag) {
|
|
121
|
+
commit('setUserInfoFlag', true)
|
|
122
|
+
const userInfo = await $request(api.getUserInfo())
|
|
123
|
+
commit('setUserInfo', userInfo)
|
|
124
|
+
commit('setInline', !!userInfo.rank)
|
|
125
|
+
if (getters[`getSavedLevel`] === null) {
|
|
126
|
+
commit('setSavedLevel', userInfo.level)
|
|
127
|
+
}
|
|
128
|
+
commit('setUserInfoFlag', false)
|
|
129
|
+
return userInfo
|
|
121
130
|
}
|
|
122
131
|
},
|
|
132
|
+
async changePassword({ commit }, payload) {
|
|
133
|
+
return await $loadingRequest(api.changePassword(payload))
|
|
134
|
+
},
|
|
123
135
|
async resetOTP({ commit }, { requestId, number }) {
|
|
124
136
|
try {
|
|
125
137
|
commit(`core/setLoading`, true, { root: true })
|
|
126
|
-
const data = await request(api.reset({ requestId, number }))
|
|
138
|
+
const data = await $request(api.reset({ requestId, number }))
|
|
127
139
|
commit(`core/setVerificationData`, data, { root: true })
|
|
128
|
-
commit(`core/setLoading`, false, { root: true })
|
|
129
140
|
} catch (err) {
|
|
130
141
|
console.log(err)
|
|
142
|
+
} finally {
|
|
131
143
|
commit(`core/setLoading`, false, { root: true })
|
|
132
144
|
}
|
|
133
145
|
},
|
|
134
146
|
async getAffiliate({}) {
|
|
135
|
-
return await request(api.getAffiliate())
|
|
147
|
+
return await $request(api.getAffiliate())
|
|
136
148
|
},
|
|
137
149
|
async postAffiliate({}, affiliateCode) {
|
|
138
|
-
return await request(api.postAffiliate({ affiliateCode }))
|
|
150
|
+
return await $request(api.postAffiliate({ affiliateCode }))
|
|
139
151
|
},
|
|
140
152
|
async passwordAbandon({ commit }, number) {
|
|
141
|
-
await request(api.passwordAbandon({number}))
|
|
153
|
+
await $request(api.passwordAbandon({ number }))
|
|
142
154
|
commit(`setRecoveryData`, {})
|
|
143
155
|
},
|
|
144
156
|
async passwordRecovery({ commit }, recoveryData) {
|
|
145
|
-
const data = await request(api.passwordRecovery(recoveryData))
|
|
157
|
+
const data = await $request(api.passwordRecovery(recoveryData))
|
|
146
158
|
commit(`setRecoveryData`, data)
|
|
147
159
|
},
|
|
148
160
|
async passwordAcknowledge({ commit }, acknowledgeData) {
|
|
149
|
-
await request(api.passwordAcknowledge(acknowledgeData))
|
|
161
|
+
await $request(api.passwordAcknowledge(acknowledgeData))
|
|
150
162
|
commit(`setRecoveryData`, {})
|
|
151
163
|
},
|
|
152
164
|
async verify({ commit }) {
|
|
153
|
-
const data = await loadingRequest(api.verify())
|
|
165
|
+
const data = await $loadingRequest(api.verify())
|
|
154
166
|
commit(`core/setVerificationData`, data, { root: true })
|
|
155
167
|
return data
|
|
156
168
|
},
|
|
157
169
|
async acknowledge({}, requestId, code) {
|
|
158
|
-
return loadingRequest(api.acknowledge({ requestId, code }))
|
|
170
|
+
return $loadingRequest(api.acknowledge({ requestId, code }))
|
|
159
171
|
},
|
|
160
172
|
thirdPartyRedirect({}, method) {
|
|
161
173
|
return (
|
|
162
|
-
fullURL +
|
|
174
|
+
$fullURL +
|
|
163
175
|
'login?' +
|
|
164
176
|
qs.stringify({
|
|
165
177
|
provider: method,
|
|
@@ -174,6 +186,6 @@ function createStore(request, loadingRequest, fullURL) {
|
|
|
174
186
|
}
|
|
175
187
|
|
|
176
188
|
export default (ctx, inject) => {
|
|
177
|
-
const { store, $request, $loadingRequest, fullURL } = ctx
|
|
178
|
-
store.registerModule('user', createStore($request, $loadingRequest, fullURL))
|
|
189
|
+
const { store, $request, $loadingRequest, $fullURL } = ctx
|
|
190
|
+
store.registerModule('user', createStore({ $request, $loadingRequest, $fullURL }))
|
|
179
191
|
}
|