@jetthai/cuora 1.1.303 → 1.1.304
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/api/common.js +1 -0
- package/src/machine/index.js +2 -0
- package/src/machine/navbar.js +57 -0
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.304](https://github.com/jetthai/cuora-module/compare/v1.1.303...v1.1.304) (2024-09-09)
|
|
6
|
+
|
|
5
7
|
### [1.1.303](https://github.com/jetthai/cuora-module/compare/v1.1.302...v1.1.303) (2024-09-09)
|
|
6
8
|
|
|
7
9
|
### [1.1.302](https://github.com/jetthai/cuora-module/compare/v1.1.301...v1.1.302) (2024-09-02)
|
package/package.json
CHANGED
package/src/api/common.js
CHANGED
|
@@ -4,4 +4,5 @@ export default {
|
|
|
4
4
|
feeds: ({ appSecret }) => ({ url: 'feeds', method: 'get', params: { appSecret }, isPublic: true }),
|
|
5
5
|
broadcast: () => ({ url: 'broadcast', method: 'get', isPublic: true }),
|
|
6
6
|
getAnnouncements: ({ appSecret }) => ({ url: 'getAnnouncements', params: { appSecret }, method: 'get', isPublic: true }),
|
|
7
|
+
getNavbar: ({ appSecret } = {}) => ({ url: 'getNavbarSetting', params: { appSecret }, method: 'get', isPublic: true }),
|
|
7
8
|
}
|
package/src/machine/index.js
CHANGED
|
@@ -35,6 +35,7 @@ import promotions from './promotions.js'
|
|
|
35
35
|
import roulette_v2 from './roulette_v2.js'
|
|
36
36
|
import honor_board_cash from './honor_board_cash.js'
|
|
37
37
|
import user_photo from './user_photo.js'
|
|
38
|
+
import navbar from './navbar.js'
|
|
38
39
|
|
|
39
40
|
export default {
|
|
40
41
|
...activity,
|
|
@@ -73,5 +74,6 @@ export default {
|
|
|
73
74
|
roulette_v2,
|
|
74
75
|
honor_board_cash,
|
|
75
76
|
user_photo,
|
|
77
|
+
navbar,
|
|
76
78
|
...withdraw,
|
|
77
79
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import common from '../api/common.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
const { appSecret } = request.config
|
|
6
|
+
return createMachine(
|
|
7
|
+
{
|
|
8
|
+
id: 'navbar',
|
|
9
|
+
initial: 'fetching',
|
|
10
|
+
context: {
|
|
11
|
+
navbar: null,
|
|
12
|
+
},
|
|
13
|
+
states: {
|
|
14
|
+
fetching: {
|
|
15
|
+
invoke: {
|
|
16
|
+
src: 'fetchNavbar',
|
|
17
|
+
onDone: {
|
|
18
|
+
target: 'idle',
|
|
19
|
+
actions: 'setNavbar',
|
|
20
|
+
},
|
|
21
|
+
onError: {
|
|
22
|
+
target: 'idle',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
idle: {},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
actions: {
|
|
31
|
+
setNavbar: assign((context, event) => {
|
|
32
|
+
const { navbarConfig } = event.data
|
|
33
|
+
return {
|
|
34
|
+
navbar: navbarConfig.settings,
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
services: {
|
|
39
|
+
fetchNavbar: async (context, event) => {
|
|
40
|
+
const navbar = await request.send(common.getNavbar({ appSecret }))
|
|
41
|
+
const base64Url = navbar.config.split('.')[0]
|
|
42
|
+
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/')
|
|
43
|
+
const decodeResult = decodeURIComponent(
|
|
44
|
+
window
|
|
45
|
+
.atob(base64)
|
|
46
|
+
.split('')
|
|
47
|
+
.map((c) => {
|
|
48
|
+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
|
|
49
|
+
})
|
|
50
|
+
.join('')
|
|
51
|
+
)
|
|
52
|
+
return { navbarConfig: JSON.parse(decodeResult) }
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
}
|