pull/420/head
shizhong 2024-03-07 14:09:08 +08:00
parent 2438f65d9e
commit d1cfe78283
3 changed files with 33 additions and 17 deletions

View File

@ -21,10 +21,16 @@ const request = (option: any) => {
export default {
get: async <T = any>(option: any) => {
const res = await request({ method: 'GET', ...option })
return res.data as unknown as T
if (res == null) {
return null;
}
return res.data as unknown as T;
},
post: async <T = any>(option: any) => {
const res = await request({ method: 'POST', ...option })
if (res == null) {
return null;
}
return res.data as unknown as T
},
postOriginal: async (option: any) => {
@ -33,10 +39,16 @@ export default {
},
delete: async <T = any>(option: any) => {
const res = await request({ method: 'DELETE', ...option })
if (res == null) {
return null;
}
return res.data as unknown as T
},
put: async <T = any>(option: any) => {
const res = await request({ method: 'PUT', ...option })
if (res == null) {
return null;
}
return res.data as unknown as T
},
download: async <T = any>(option: any) => {

View File

@ -46,21 +46,23 @@ export const useDictStore = defineStore('dict', {
} else {
const res = await listSimpleDictDataApi()
// 设置数据
const dictDataMap = new Map<string, any>()
res.forEach((dictData: DictDataVO) => {
// 获得 dictType 层级
const enumValueObj = dictDataMap[dictData.dictType]
if (!enumValueObj) {
dictDataMap[dictData.dictType] = []
}
// 处理 dictValue 层级
dictDataMap[dictData.dictType].push({
value: dictData.value,
label: dictData.label,
colorType: dictData.colorType,
cssClass: dictData.cssClass
})
})
const dictDataMap = new Map<string, any>();
if (res != null) {
res.forEach((dictData: DictDataVO) => {
// 获得 dictType 层级
const enumValueObj = dictDataMap[dictData.dictType]
if (!enumValueObj) {
dictDataMap[dictData.dictType] = []
}
// 处理 dictValue 层级
dictDataMap[dictData.dictType].push({
value: dictData.value,
label: dictData.label,
colorType: dictData.colorType,
cssClass: dictData.cssClass
})
});
}
this.dictMap = dictDataMap
this.isSetDict = true
wsCache.set(CACHE_KEY.DICT_CACHE, dictDataMap, { exp: 60 }) // 60 秒 过期

View File

@ -277,7 +277,9 @@ const handleLogin = async (params) => {
}
} finally {
loginLoading.value = false
loading.value.close()
if (loading.value != null) {
loading.value.close();
}
}
}