StorageController.weapp.js 785 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. const StorageController = {
  13. async: 0,
  14. getItem(path
  15. /*: string*/
  16. )
  17. /*: ?string*/
  18. {
  19. return wx.getStorageSync(path);
  20. },
  21. setItem(path
  22. /*: string*/
  23. , value
  24. /*: string*/
  25. ) {
  26. try {
  27. wx.setStorageSync(path, value);
  28. } catch (e) {// Quota exceeded
  29. }
  30. },
  31. removeItem(path
  32. /*: string*/
  33. ) {
  34. wx.removeStorageSync(path);
  35. },
  36. clear() {
  37. wx.clearStorageSync();
  38. }
  39. };
  40. module.exports = StorageController;