StorageController.weapp.js 818 B

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3. var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  4. /**
  5. * @flow
  6. * @private
  7. */
  8. var StorageController = {
  9. async: 0,
  10. getItem: function (path /*: string*/) /*: ?string*/{
  11. return wx.getStorageSync(path);
  12. },
  13. setItem: function (path /*: string*/, value /*: string*/) {
  14. try {
  15. wx.setStorageSync(path, value);
  16. } catch (e) {
  17. // Quota exceeded
  18. }
  19. },
  20. removeItem: function (path /*: string*/) {
  21. wx.removeStorageSync(path);
  22. },
  23. getAllKeys: function () {
  24. var res = wx.getStorageInfoSync();
  25. return (0, _keys.default)(res);
  26. },
  27. clear: function () {
  28. wx.clearStorageSync();
  29. }
  30. };
  31. module.exports = StorageController;