功能:同步小程序流程

This commit is contained in:
xiaowang
2026-05-23 18:45:41 +08:00
parent 844516988b
commit 30ae763e18
117 changed files with 8823 additions and 76 deletions
+56
View File
@@ -1,6 +1,14 @@
const { STORAGE_KEYS, getStorage, removeStorage, setStorage } = require('./storage')
/**
* Purpose: SIGNED_URL_SAFE_BUFFER_MS supports auth.js by holding or executing the signed url safe buffer ms page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const SIGNED_URL_SAFE_BUFFER_MS = 60 * 1000
/**
* Purpose: parseSignedUrlExpireAt supports auth.js by holding or executing the parse signed url expire at page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function parseSignedUrlExpireAt(url) {
const rawUrl = String(url || '').trim()
if (!rawUrl || rawUrl.indexOf('?') < 0) {
@@ -42,6 +50,10 @@ function parseSignedUrlExpireAt(url) {
return 0
}
/**
* Purpose: sanitizeStoredUserInfo supports auth.js by holding or executing the sanitize stored user info page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function sanitizeStoredUserInfo(userInfo) {
if (!userInfo || typeof userInfo !== 'object') {
return userInfo
@@ -57,14 +69,26 @@ function sanitizeStoredUserInfo(userInfo) {
return nextUserInfo
}
/**
* Purpose: getAccessToken supports auth.js by holding or executing the get access token page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function getAccessToken() {
return getStorage(STORAGE_KEYS.ACCESS_TOKEN, '')
}
/**
* Purpose: getRefreshToken supports auth.js by holding or executing the get refresh token page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function getRefreshToken() {
return getStorage(STORAGE_KEYS.REFRESH_TOKEN, '')
}
/**
* Purpose: getStoredUserInfo supports auth.js by holding or executing the get stored user info page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function getStoredUserInfo() {
const userInfo = sanitizeStoredUserInfo(getStorage(STORAGE_KEYS.USER_INFO, null))
if (userInfo) {
@@ -73,18 +97,34 @@ function getStoredUserInfo() {
return userInfo
}
/**
* Purpose: getNeedSetPassword supports auth.js by holding or executing the get need set password page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function getNeedSetPassword() {
return Boolean(getStorage(STORAGE_KEYS.NEED_SET_PASSWORD, false))
}
/**
* Purpose: getPreferredMiniLoginShopId supports auth.js by holding or executing the get preferred mini login shop id page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function getPreferredMiniLoginShopId() {
return getStorage(STORAGE_KEYS.PREFERRED_MINI_LOGIN_SHOP_ID, '')
}
/**
* Purpose: isLoggedIn supports auth.js by holding or executing the is logged in page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function isLoggedIn() {
return Boolean(getAccessToken())
}
/**
* Purpose: setSession supports auth.js by holding or executing the set session page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function setSession(payload) {
if (!payload || !payload.accessToken || !payload.refreshToken) {
return
@@ -104,6 +144,10 @@ function setSession(payload) {
}
}
/**
* Purpose: updateStoredUserInfo supports auth.js by holding or executing the update stored user info page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function updateStoredUserInfo(userInfo) {
if (!userInfo) {
removeStorage(STORAGE_KEYS.USER_INFO)
@@ -113,6 +157,10 @@ function updateStoredUserInfo(userInfo) {
setStorage(STORAGE_KEYS.USER_INFO, sanitizeStoredUserInfo(userInfo))
}
/**
* Purpose: setNeedSetPassword supports auth.js by holding or executing the set need set password page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function setNeedSetPassword(value) {
if (value) {
setStorage(STORAGE_KEYS.NEED_SET_PASSWORD, true)
@@ -122,6 +170,10 @@ function setNeedSetPassword(value) {
removeStorage(STORAGE_KEYS.NEED_SET_PASSWORD)
}
/**
* Purpose: clearSession supports auth.js by holding or executing the clear session page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function clearSession() {
removeStorage(STORAGE_KEYS.ACCESS_TOKEN)
removeStorage(STORAGE_KEYS.REFRESH_TOKEN)
@@ -129,6 +181,10 @@ function clearSession() {
removeStorage(STORAGE_KEYS.NEED_SET_PASSWORD)
}
/**
* Purpose: setPreferredMiniLoginShopId supports auth.js by holding or executing the set preferred mini login shop id page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function setPreferredMiniLoginShopId(shopId) {
if (shopId === undefined || shopId === null || shopId === '') {
removeStorage(STORAGE_KEYS.PREFERRED_MINI_LOGIN_SHOP_ID)