Falcon.SugarApi/JS/StaticData.js

34 lines
901 B
JavaScript
Raw Normal View History

//<2F><EFBFBD><E6B4A2>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
function createSetStaticData() {
if (window.sessionStorage) {
return (k, v) => window.sessionStorage.setItem(k, v);
} else if ($ && $.cookie) {
return (k, v) => $.cookie(k, v);
} else {
throw new Error(<><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD>ֵĴ洢<C4B4><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
}
var setStaticData = createSetStaticData();
//<2F><>ȡ<EFBFBD><EFBFBD>ľ<EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
function CreateGetStaticData() {
if (window.sessionStorage) {
return (k) => window.sessionStorage.getItem(k);
} else if ($ && $.cookie) {
return (k) => $.cookie(k);
} else {
throw new Error(<><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD>ֵĴ洢<C4B4><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
}
var getStaticData = CreateGetStaticData();
//<2F><>̬<EFBFBD><CCAC><EFBFBD>ݴ<EFBFBD>ȡ<EFBFBD><C8A1>
class StaticData {
constructor(k, v) {
this.key = k;
this.value = v;
if (v) {
setStaticData(k, v);
} else {
this.value = getStaticData(k);
}
}
}