github.com/e154/smart-home@v0.17.2-0.20240311175135-e530a6e5cd45/static_source/admin/src/hooks/web/useCache.ts (about)

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