From d1cfe7828355e5c1c7e2b138f3787d4a910454af Mon Sep 17 00:00:00 2001 From: shizhong <124974919@qq.com> Date: Thu, 7 Mar 2024 14:09:08 +0800 Subject: [PATCH] BUG --- src/config/axios/index.ts | 14 ++++++++++- src/store/modules/dict.ts | 32 +++++++++++++----------- src/views/Login/components/LoginForm.vue | 4 ++- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/config/axios/index.ts b/src/config/axios/index.ts index 79e558da..7bd18843 100644 --- a/src/config/axios/index.ts +++ b/src/config/axios/index.ts @@ -21,10 +21,16 @@ const request = (option: any) => { export default { get: async (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 (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 (option: any) => { const res = await request({ method: 'DELETE', ...option }) + if (res == null) { + return null; + } return res.data as unknown as T }, put: async (option: any) => { const res = await request({ method: 'PUT', ...option }) + if (res == null) { + return null; + } return res.data as unknown as T }, download: async (option: any) => { diff --git a/src/store/modules/dict.ts b/src/store/modules/dict.ts index 341d3b77..c3a4496c 100644 --- a/src/store/modules/dict.ts +++ b/src/store/modules/dict.ts @@ -46,21 +46,23 @@ export const useDictStore = defineStore('dict', { } else { const res = await listSimpleDictDataApi() // 设置数据 - const dictDataMap = new Map() - 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(); + 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 秒 过期 diff --git a/src/views/Login/components/LoginForm.vue b/src/views/Login/components/LoginForm.vue index 34968bd2..66a639b9 100644 --- a/src/views/Login/components/LoginForm.vue +++ b/src/views/Login/components/LoginForm.vue @@ -277,7 +277,9 @@ const handleLogin = async (params) => { } } finally { loginLoading.value = false - loading.value.close() + if (loading.value != null) { + loading.value.close(); + } } }