2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: STORAGE_KEYS supports storage.js by holding or executing the storage keys 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.
|
|
|
|
|
*/
|
2026-04-20 16:02:57 +08:00
|
|
|
const STORAGE_KEYS = {
|
|
|
|
|
ACCESS_TOKEN: 'adminAccessToken',
|
|
|
|
|
REFRESH_TOKEN: 'adminRefreshToken',
|
|
|
|
|
USER_INFO: 'adminUserInfo',
|
|
|
|
|
PERMISSIONS: 'adminPermissions',
|
|
|
|
|
CURRENT_SHOP: 'adminCurrentShop',
|
|
|
|
|
DEVICE_ID: 'adminMiniDeviceId'
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: TEMP_RECORD_PREFIX supports storage.js by holding or executing the temp record prefix 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.
|
|
|
|
|
*/
|
2026-04-20 16:02:57 +08:00
|
|
|
const TEMP_RECORD_PREFIX = 'adminTempRecord:'
|
|
|
|
|
|
2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: getStorage supports storage.js by holding or executing the get storage 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.
|
|
|
|
|
*/
|
2026-04-20 16:02:57 +08:00
|
|
|
function getStorage(key, defaultValue) {
|
|
|
|
|
try {
|
|
|
|
|
const value = wx.getStorageSync(key)
|
|
|
|
|
return value === '' || value === undefined ? defaultValue : value
|
|
|
|
|
} catch (error) {
|
|
|
|
|
return defaultValue
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: setStorage supports storage.js by holding or executing the set storage 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.
|
|
|
|
|
*/
|
2026-04-20 16:02:57 +08:00
|
|
|
function setStorage(key, value) {
|
|
|
|
|
wx.setStorageSync(key, value)
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: removeStorage supports storage.js by holding or executing the remove storage 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.
|
|
|
|
|
*/
|
2026-04-20 16:02:57 +08:00
|
|
|
function removeStorage(key) {
|
|
|
|
|
wx.removeStorageSync(key)
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: setTempRecord supports storage.js by holding or executing the set temp record 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.
|
|
|
|
|
*/
|
2026-04-20 16:02:57 +08:00
|
|
|
function setTempRecord(name, value) {
|
|
|
|
|
setStorage(`${TEMP_RECORD_PREFIX}${name}`, value)
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: getTempRecord supports storage.js by holding or executing the get temp record 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.
|
|
|
|
|
*/
|
2026-04-20 16:02:57 +08:00
|
|
|
function getTempRecord(name, defaultValue) {
|
|
|
|
|
return getStorage(`${TEMP_RECORD_PREFIX}${name}`, defaultValue)
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: clearTempRecord supports storage.js by holding or executing the clear temp record 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.
|
|
|
|
|
*/
|
2026-04-20 16:02:57 +08:00
|
|
|
function clearTempRecord(name) {
|
|
|
|
|
removeStorage(`${TEMP_RECORD_PREFIX}${name}`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
STORAGE_KEYS,
|
|
|
|
|
getStorage,
|
|
|
|
|
setStorage,
|
|
|
|
|
removeStorage,
|
|
|
|
|
setTempRecord,
|
|
|
|
|
getTempRecord,
|
|
|
|
|
clearTempRecord
|
|
|
|
|
}
|