t-comm
Version:
专业、稳定、纯粹的工具库
45 lines (40 loc) • 1.37 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var storage_persistData = require('../storage/persist-data.js');
require('../env/env.js');
var LocationStorage = /** @class */function () {
function LocationStorage() {}
// 从sessionStorage获取缓存位置信息
LocationStorage.getLocationFromSessionStorage = function () {
var storageSession = window.sessionStorage.getItem('position');
if (storageSession) {
try {
var location_1 = JSON.parse(storageSession);
return location_1;
} catch (_a) {
return null;
}
}
return null;
};
// 从localStorage获取缓存位置信息
LocationStorage.getLocationFromLocalStorage = function () {
var persistPosition = storage_persistData.getPersist('position');
if (persistPosition) {
try {
var location_2 = JSON.parse(persistPosition);
return location_2;
} catch (_a) {
return null;
}
}
return null;
};
// 存储缓存位置信息到sessionStorage和localStorage
LocationStorage.setLocationToStorage = function (location, expireMS) {
window.sessionStorage.setItem('position', JSON.stringify(location));
storage_persistData.savePersist('position', JSON.stringify(location), expireMS);
};
return LocationStorage;
}();
exports["default"] = LocationStorage;