@jetthai/cuora 1.1.224 → 1.1.226
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 +8 -0
- package/package.json +1 -1
- package/src/api/common.js +1 -0
- package/src/machine/common.js +26 -8
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
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.226](https://github.com/jetthai/cuora-module/compare/v1.1.225...v1.1.226) (2024-02-26)
|
|
6
|
+
|
|
7
|
+
### [1.1.225](https://github.com/jetthai/cuora-module/compare/v1.1.221-layout-1...v1.1.225) (2024-02-07)
|
|
8
|
+
|
|
9
|
+
### [1.1.224](https://github.com/jetthai/cuora-module/compare/v1.1.222...v1.1.224) (2024-02-02)
|
|
10
|
+
|
|
11
|
+
### [1.1.222](https://github.com/jetthai/cuora-module/compare/v1.1.221-layout...v1.1.222) (2024-02-02)
|
|
12
|
+
|
|
5
13
|
### [1.1.224](https://github.com/jetthai/cuora-module/compare/v1.1.222...v1.1.224) (2024-02-02)
|
|
6
14
|
|
|
7
15
|
### [1.1.222](https://github.com/jetthai/cuora-module/compare/v1.1.221...v1.1.222) (2024-02-02)
|
package/package.json
CHANGED
package/src/api/common.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
getConfig: ({ appSecret }) => ({ url: 'getConfig', method: 'get', params: { appSecret }, isPublic: true }),
|
|
3
|
+
getLayoutConfig: ({ appSecret }) => ({ url: 'getQuickLayout', method: 'get', params: { appSecret }, isPublic: true }),
|
|
3
4
|
feeds: ({ appSecret }) => ({ url: 'feeds', method: 'get', params: { appSecret }, isPublic: true }),
|
|
4
5
|
broadcast: () => ({ url: 'broadcast', method: 'get', isPublic: true }),
|
|
5
6
|
getAnnouncements: ({ appSecret }) => ({ url: 'getAnnouncements', params: { appSecret }, method: 'get', isPublic: true }),
|
package/src/machine/common.js
CHANGED
|
@@ -29,6 +29,7 @@ export default function (request) {
|
|
|
29
29
|
},
|
|
30
30
|
paymentMethods: {},
|
|
31
31
|
},
|
|
32
|
+
layoutConfig: null,
|
|
32
33
|
userAgent: '',
|
|
33
34
|
isMobile: false,
|
|
34
35
|
announcementList: null,
|
|
@@ -56,10 +57,10 @@ export default function (request) {
|
|
|
56
57
|
fetching: {
|
|
57
58
|
entry: ['setUA', 'setAgent', 'setPixel', 'setKPixel'],
|
|
58
59
|
invoke: {
|
|
59
|
-
src: '
|
|
60
|
+
src: 'fetchConfig',
|
|
60
61
|
onDone: {
|
|
61
62
|
target: 'idle',
|
|
62
|
-
actions: '
|
|
63
|
+
actions: 'setConfig',
|
|
63
64
|
},
|
|
64
65
|
onError: {
|
|
65
66
|
target: 'idle',
|
|
@@ -158,10 +159,27 @@ export default function (request) {
|
|
|
158
159
|
},
|
|
159
160
|
},
|
|
160
161
|
actions: {
|
|
161
|
-
|
|
162
|
-
const {
|
|
162
|
+
setConfig: assign((context, event) => {
|
|
163
|
+
const { siteConfig, layoutConfig } = event.data
|
|
164
|
+
const { loginMethods = {}, registerMethods = {} } = siteConfig
|
|
165
|
+
let layoutConfigDecoded = ''
|
|
166
|
+
|
|
167
|
+
if (layoutConfig) {
|
|
168
|
+
const base64Url = layoutConfig.split('.')[0]
|
|
169
|
+
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/')
|
|
170
|
+
layoutConfigDecoded = decodeURIComponent(
|
|
171
|
+
window
|
|
172
|
+
.atob(base64)
|
|
173
|
+
.split('')
|
|
174
|
+
.map((c) => {
|
|
175
|
+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
|
|
176
|
+
})
|
|
177
|
+
.join('')
|
|
178
|
+
)
|
|
179
|
+
}
|
|
163
180
|
return {
|
|
164
|
-
siteConfig: { ...
|
|
181
|
+
siteConfig: { ...siteConfig, loginMethods: pickBy(loginMethods), registerMethods: pickBy(registerMethods) },
|
|
182
|
+
layoutConfig: layoutConfigDecoded,
|
|
165
183
|
}
|
|
166
184
|
}),
|
|
167
185
|
setUA: assign((context, event) => {
|
|
@@ -265,9 +283,9 @@ export default function (request) {
|
|
|
265
283
|
}),
|
|
266
284
|
},
|
|
267
285
|
services: {
|
|
268
|
-
|
|
269
|
-
const
|
|
270
|
-
return JSON.parse(window.atob(config))
|
|
286
|
+
fetchConfig: async (context, event) => {
|
|
287
|
+
const [site, layout] = await Promise.all([request.send(api.getConfig({ appSecret })), request.send(api.getLayoutConfig({ appSecret }))])
|
|
288
|
+
return { siteConfig: JSON.parse(window.atob(site.config)), layoutConfig: JSON.parse(window.atob(layout.config)) }
|
|
271
289
|
},
|
|
272
290
|
fetchFeeds: async (context, event) => {
|
|
273
291
|
return await request.send(api.feeds({ appSecret }))
|