StorageController.weapp.js 822 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. "use strict";
  2. /**
  3. * Copyright (c) 2015-present, Parse, LLC.
  4. * All rights reserved.
  5. *
  6. * This source code is licensed under the BSD-style license found in the
  7. * LICENSE file in the root directory of this source tree. An additional grant
  8. * of patent rights can be found in the PATENTS file in the same directory.
  9. *
  10. * @flow
  11. */
  12. var StorageController = {
  13. async: 0,
  14. getItem: function (path
  15. /*: string*/
  16. )
  17. /*: ?string*/
  18. {
  19. return wx.getStorageSync(path);
  20. },
  21. setItem: function (path
  22. /*: string*/
  23. , value
  24. /*: string*/
  25. ) {
  26. try {
  27. wx.setStorageSync(path, value);
  28. } catch (e) {// Quota exceeded
  29. }
  30. },
  31. removeItem: function (path
  32. /*: string*/
  33. ) {
  34. wx.removeStorageSync(path);
  35. },
  36. clear: function () {
  37. wx.clearStorageSync();
  38. }
  39. };
  40. module.exports = StorageController;