first commit

This commit is contained in:
2024-04-08 21:34:02 +08:00
commit a41a7f32ab
223 changed files with 44629 additions and 0 deletions

23
src/hooks/app/useDict.ts Normal file
View File

@@ -0,0 +1,23 @@
import { ref, toRefs } from 'vue'
import { listCommonDict } from '@/apis'
import { useDictStore } from '@/stores'
export function useDict(...codes: Array<string>) {
const res = ref<any>({})
return (() => {
const dictStore = useDictStore()
codes.forEach((code) => {
res.value[code] = []
const dict = dictStore.getDict(code)
if (dict) {
res.value[code] = dict
} else {
listCommonDict(code).then((resp) => {
res.value[code] = resp.data
dictStore.setDict(code, res.value[code])
})
}
})
return toRefs(res.value)
})()
}