重构项目文件夹目录
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
const STORAGE_KEYS = {
|
||||
ACCESS_TOKEN: 'accessToken',
|
||||
REFRESH_TOKEN: 'refreshToken',
|
||||
USER_INFO: 'userInfo',
|
||||
NEED_SET_PASSWORD: 'needSetPassword',
|
||||
PREFERRED_MINI_LOGIN_SHOP_ID: 'preferredMiniLoginShopId',
|
||||
DEVICE_ID: 'miniDeviceId'
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function getStorage(key, defaultValue) {
|
||||
try {
|
||||
const value = wx.getStorageSync(key)
|
||||
return value === '' || value === undefined ? defaultValue : value
|
||||
} catch (error) {
|
||||
return defaultValue
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function setStorage(key, value) {
|
||||
wx.setStorageSync(key, value)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function removeStorage(key) {
|
||||
wx.removeStorageSync(key)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
STORAGE_KEYS,
|
||||
getStorage,
|
||||
setStorage,
|
||||
removeStorage
|
||||
}
|
||||
Reference in New Issue
Block a user