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

View File

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

View File

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