useCache.ts 357 B

1234567891011121314151617
  1. /**
  2. * 配置浏览器本地存储的方式,可直接存储对象数组。
  3. */
  4. import WebStorageCache from 'web-storage-cache'
  5. type CacheType = 'localStorage' | 'sessionStorage'
  6. export const useCache = (type: CacheType = 'localStorage') => {
  7. const wsCache: WebStorageCache = new WebStorageCache({
  8. storage: type
  9. })
  10. return {
  11. wsCache
  12. }
  13. }