1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import { useStores } from "@/store/modules/index";
- // 存储变量名
- let storageKey = 'storage_data'
- const storage = {
- set: function (key, value) {
- let tmp = uni.getStorageSync(storageKey)
- tmp = tmp ? tmp : {}
- tmp[key] = value
- uni.setStorageSync(storageKey, tmp)
- },
- get: function (key) {
- return uni.getStorageSync(storageKey)[key] || ""
- },
- remove: function (key) {
- delete uni.getStorageSync(storageKey)[key]
- uni.setStorageSync(storageKey, uni.getStorageSync(storageKey))
- },
- clean: function () {
- uni.removeStorageSync(storageKey)
- }
- }
- const storageSystem = {
- init: function (key) { },
- set: function (key, value) {
- let tmp = uni.getStorageSync(useStores().userId + "_storage_System")
- tmp = tmp ? tmp : {}
- tmp[key] = value
- uni.setStorageSync(useStores().userId + "_storage_System", tmp)
- },
- get: function (key) {
- return uni.getStorageSync(useStores().userId + "_storage_System")[key] || ""
- },
- remove: function (key) {
- delete uni.getStorageSync(useStores().userId + "_storage_System")[key]
- uni.setStorageSync(useStores().userId + "_storage_System", uni.getStorageSync(useStores().userId + "_storage_System"))
- },
- clean: function () {
- uni.removeStorageSync(useStores().userId + "_storage_System")
- }
- }
- export { storage, storageSystem }
|