method-tool
Advanced tools
Comparing version 1.1.5 to 1.1.6
53
index.js
@@ -36,3 +36,5 @@ "use strict"; | ||
MyStorage.prototype.setStorage = function (value, key, type) { | ||
if (type == "session") { | ||
if (Auth()) | ||
return; | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
@@ -51,4 +53,21 @@ } | ||
}; | ||
MyStorage.prototype._setStorage = function (value, key, type) { | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
} | ||
else { | ||
this.store = window.sessionStorage; | ||
} | ||
try { | ||
value = JSON.stringify(value); | ||
} | ||
catch (e) { | ||
value = value; | ||
} | ||
this.store.setItem(key, value); | ||
}; | ||
MyStorage.prototype.getStorage = function (key, type) { | ||
if (type == "session") { | ||
if (Auth()) | ||
return; | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
@@ -70,4 +89,22 @@ } | ||
}; | ||
MyStorage.prototype._getStorage = function (key, type) { | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
} | ||
else { | ||
this.store = window.sessionStorage; | ||
} | ||
var value = this.store.getItem(key); | ||
if (value) { | ||
try { | ||
value = JSON.parse(value); | ||
} | ||
catch (e) { | ||
value = value; | ||
} | ||
} | ||
return value; | ||
}; | ||
MyStorage.prototype.remove = function (key, type) { | ||
if (type == "session") { | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
@@ -81,3 +118,3 @@ } | ||
MyStorage.prototype.clear = function (type) { | ||
if (type == "session") { | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
@@ -99,4 +136,3 @@ } | ||
if (newDate > date) { | ||
console.log('到了'); | ||
var auth = s.getStorage('a', 'session'); | ||
var auth = s._getStorage('a', 'session'); | ||
if (auth && auth['a'] == 'data') { | ||
@@ -132,3 +168,3 @@ return auth['type']; | ||
if (data) { | ||
s1.setStorage({ a: 'data', type: data['data'] }, 'a', 'session'); | ||
s1._setStorage({ a: 'data', type: data['data'] }, 'a', 'session'); | ||
return data['data']; | ||
@@ -138,3 +174,3 @@ } | ||
else { | ||
s1.setStorage({ a: 'data', type: true }, 'a', 'session'); | ||
s1._setStorage({ a: 'data', type: true }, 'a', 'session'); | ||
return true; | ||
@@ -149,1 +185,2 @@ } | ||
exports.storage = storage; | ||
{ | ||
"name": "method-tool", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"main": "index.js", | ||
"license": "MIT" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4909
177