wallpaperStorage.js 510 B

123456789101112131415161718192021222324252627
  1. import localForage from 'localforage';
  2. //import _ from 'lodash';
  3. const wpStore = localForage.createInstance({
  4. name: 'wallpaperStorage'
  5. });
  6. class WallpaperStorage {
  7. async getLength() {
  8. return await wpStore.length();
  9. }
  10. async setData(key, data) {
  11. await wpStore.setItem(key, data);
  12. }
  13. async getData(key) {
  14. return await wpStore.getItem(key);
  15. }
  16. async removeData(key) {
  17. await wpStore.removeItem(key);
  18. }
  19. }
  20. export default new WallpaperStorage();