@jetthai/cuora 1.1.359-dev-4 → 1.1.359-dev-6
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 +4 -0
- package/package.json +1 -1
- package/src/machine/common.js +3 -2
- package/src/util/sessionStorage.js +28 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
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.359-dev-6](https://github.com/jetthai/cuora-module/compare/v1.1.359-dev-5...v1.1.359-dev-6) (2025-06-02)
|
|
6
|
+
|
|
7
|
+
### [1.1.359-dev-5](https://github.com/jetthai/cuora-module/compare/v1.1.359-dev-4...v1.1.359-dev-5) (2025-06-02)
|
|
8
|
+
|
|
5
9
|
### [1.1.359-dev-4](https://github.com/jetthai/cuora-module/compare/v1.1.359-dev-3...v1.1.359-dev-4) (2025-05-26)
|
|
6
10
|
|
|
7
11
|
### [1.1.359-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.359-dev-2...v1.1.359-dev-3) (2025-05-26)
|
package/package.json
CHANGED
package/src/machine/common.js
CHANGED
|
@@ -3,6 +3,7 @@ import { assign, createMachine } from 'xstate'
|
|
|
3
3
|
import pickBy from 'lodash/pickBy.js'
|
|
4
4
|
import api from '../api/common.js'
|
|
5
5
|
import storage from '../util/storage.js'
|
|
6
|
+
import sessionStorage from '../util/sessionStorage.js'
|
|
6
7
|
|
|
7
8
|
export default function (request) {
|
|
8
9
|
const { appSecret, defaultChannel, defaultSubchannel } = request.config
|
|
@@ -258,7 +259,7 @@ export default function (request) {
|
|
|
258
259
|
const channel = urlParams.get('channel') || storage.get('channel') || defaultChannel || 'official'
|
|
259
260
|
const subchannel = urlParams.get('subchannel') || storage.get('subchannel') || defaultSubchannel || 'pwa'
|
|
260
261
|
const affiliateCode = urlParams.get('ac') || urlParams.get('referralCode') || storage.get('ac') || storage.get('referralCode')
|
|
261
|
-
const friendCode = urlParams.get('fc') || urlParams.get('affiliate') ||
|
|
262
|
+
const friendCode = urlParams.get('fc') || urlParams.get('affiliate') || sessionStorage.get('fc') || sessionStorage.get('affiliate')
|
|
262
263
|
|
|
263
264
|
storage.set('channel', channel, {
|
|
264
265
|
path: '/',
|
|
@@ -272,7 +273,7 @@ export default function (request) {
|
|
|
272
273
|
path: '/',
|
|
273
274
|
maxAge: 60 * 60 * 24 * 7,
|
|
274
275
|
})
|
|
275
|
-
|
|
276
|
+
sessionStorage.set('fc', friendCode, {
|
|
276
277
|
path: '/',
|
|
277
278
|
maxAge: 60 * 60 * 24 * 7,
|
|
278
279
|
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
get(name, options) {
|
|
3
|
+
const itemStr = sessionStorage.getItem(name)
|
|
4
|
+
|
|
5
|
+
if (!itemStr) {
|
|
6
|
+
return null
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const item = JSON.parse(itemStr)
|
|
10
|
+
if (item.expiry && new Date().getTime() > item.expiry) {
|
|
11
|
+
sessionStorage.removeItem(name)
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return item.value
|
|
16
|
+
},
|
|
17
|
+
set(name, value, options) {
|
|
18
|
+
const item = { value }
|
|
19
|
+
|
|
20
|
+
if (options?.maxAge) {
|
|
21
|
+
item.expiry = new Date().getTime() + options.maxAge * 1000
|
|
22
|
+
}
|
|
23
|
+
sessionStorage.setItem(name, JSON.stringify(item))
|
|
24
|
+
},
|
|
25
|
+
remove(name, options) {
|
|
26
|
+
sessionStorage.removeItem(name)
|
|
27
|
+
},
|
|
28
|
+
}
|