StorageController.weapp.js 770 B

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