Files

55 lines
782 B
JavaScript
Raw Normal View History

2020-03-15 13:59:43 +08:00
import { trim, isType } from "@/utils";
const doc = null;
// const doc = window.document;
function get(key) {
if (!key || !_has(key)) {
return null;
}
2020-03-18 19:01:12 +08:00
return uni.getStorageSync(key)
2020-03-15 13:59:43 +08:00
}
function all() {
2020-03-18 19:01:12 +08:00
return uni.getStorageInfoSync()
2020-03-15 13:59:43 +08:00
}
function set(key, data, time) {
if (!key) {
return;
}
2020-03-18 19:01:12 +08:00
uni.setStorageSync(key, data)
2020-03-15 13:59:43 +08:00
}
function remove(key) {
if (!key || !_has(key)) {
return;
}
2020-03-18 19:01:12 +08:00
uni.removeStorageSync(key)
2020-03-15 13:59:43 +08:00
}
function clearAll() {
2020-03-18 19:01:12 +08:00
uni.clearStorage()
2020-03-15 13:59:43 +08:00
}
function _has(key) {
if (!key) {
return
}
2020-03-18 19:01:12 +08:00
let value = uni.getStorageSync(key)
console.log(key)
2020-03-15 13:59:43 +08:00
if (value) {
return true
}
return false
}
export default {
get,
all,
set,
remove,
clearAll,
has: _has
};