zhengnaiwen_citu пре 1 година
родитељ
комит
7eb731cc8a
1 измењених фајлова са 0 додато и 42 уклоњено
  1. 0 42
      src/store/dictionaries.js

+ 0 - 42
src/store/dictionaries.js

@@ -1,42 +0,0 @@
-/**
- * 获取字典信息 配置api过期自动读取
- */
-import { defineStore } from 'pinia'
-import { ref } from 'vue' 
-
-const DICT_CITY_API = {
-  DICT_CITY: Promise.resolve()
-}
-
-export const useDictionariesStore = defineStore('dictionaries', 
-  () => {
-
-    const DICT_CITY = ref({})
-
-    const setDict = (type, val, cacheTime) => {
-      [type].value = {
-        data: val,
-        expire: Date.now() + cacheTime
-      }
-    }
-
-    const getDict = (type) => {
-      return new Promise((resolve) => {
-        if ([type].value.expire && (Date.now() <= [type].value.expire)) {
-          return resolve([type].value.data)
-        }
-        DICT_CITY_API.DICT_CITY({ type }).then(({data}) => {
-          setDict(type, data, Date.now())
-          resolve(data)
-        })
-      })
-    }
-
-    return {
-      getDict
-    }
-  },
-  {
-    persist: true, // ref() 持久化响应
-  }
-)