From 6d0ea29efbd26c626ce7b6c334ee92d06b4afbca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=B2=A9?= Date: Wed, 10 Sep 2025 09:20:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 10 ++-- src/pages/examination/index.vue | 99 ++++++++++++++++++++++++++------- 2 files changed, 85 insertions(+), 24 deletions(-) diff --git a/.env.development b/.env.development index 7e53d83f..d8e448ab 100644 --- a/.env.development +++ b/.env.development @@ -6,7 +6,7 @@ ENV = 'development' # app入口 -VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' +VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' #VITE_APP_BASE_API_Url = 'http://25.16.122.65:7001' #VITE_APP_BASE_API_Url = 'http://25.16.122.91:9786' #VITE_APP_BASE_API_Url = 'http://25.18.122.66:9786' @@ -16,20 +16,20 @@ VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' # VITE_APP_BASE_H5_API_Url = 'http://25.16.122.65:7001' # VITE_APP_BASE_H5_API_Url = 'http://25.18.122.21:9786' -#VITE_APP_BASE_H5_API_Url = 'https://aitstest.jlbank.com.cn:7001' +VITE_APP_BASE_H5_API_Url = 'https://aitstest.jlbank.com.cn:7002' # dev -VITE_APP_BASE_H5_API_Url = 'http://25.18.122.65:7001' +# VITE_APP_BASE_H5_API_Url = 'http://25.18.122.65:7001' # sit -#VITE_APP_BASE_H5_API_Url = 'http://25.18.122.91:9786' +# VITE_APP_BASE_H5_API_Url = 'http://25.18.122.91:9786' # UAT # VITE_APP_BASE_H5_API_Url = 'http://25.18.122.78:9786' # 任东 # VITE_APP_BASE_H5_API_Url_TRAAPP = 'http://25.64.16.130:9601' -VITE_APP_BASE_H5_API_Url_TRASTUDY = 'http://25.64.16.130:9602' +# VITE_APP_BASE_H5_API_Url_TRASTUDY = 'http://25.64.16.130:9602' # VITE_APP_BASE_H5_API_Url_TRAEXAM = 'http://25.64.16.140:9604' # 张建成 diff --git a/src/pages/examination/index.vue b/src/pages/examination/index.vue index f9f996ee..27ef6b08 100644 --- a/src/pages/examination/index.vue +++ b/src/pages/examination/index.vue @@ -351,9 +351,10 @@ const qnsId = topic.value.qnsId; console.log('asdsadas', answerCacheList.value); const newCache = { ...answerCacheList.value }; - if(topic.value.qnsTyp === 'ES') { // 问答题特殊处理 - if('anserResult' in my_answer && my_answer.anserResult !== '') { - newCache[qnsId] = {...my_answer, voicePath:''}; + if (topic.value.qnsTyp === 'ES') { + // 问答题特殊处理 + if ('anserResult' in my_answer && my_answer.anserResult !== '') { + newCache[qnsId] = { ...my_answer, voicePath: '' }; } else { delete newCache[qnsId]; } @@ -385,24 +386,84 @@ // 设置缓存的键的名称 const suffix = mode === 'PAPERS' ? paperData.examId : paperData.crsId; examinationAnswerCacheKey = 'examinationAnswerCache' + suffix; - answerCacheList.value = common.getValue(examinationAnswerCacheKey) ?? {}; - console.log('刚进入', answerCacheList.value); + answerCacheList.value = common.getValue(examinationAnswerCacheKey); + if (typeof answerCacheList.value !== 'object') { + answerCacheList.value = {}; + } + topicList.push( ...examination.qnsInfoVos.map((res) => { - const es_status = - paperData.isCacheExam === 'N' - ? '' - : res.qnsId in answerCacheList.value - ? 'ossKey' in answerCacheList.value[res.qnsId] - ? '02' - : '01' - : ''; - const my_answer = - paperData.isCacheExam === 'N' - ? [] - : res.qnsId in answerCacheList.value - ? answerCacheList.value[res.qnsId] - : []; + // const es_status = + // paperData.isCacheExam === 'N' + // ? '' + // : res.qnsId in answerCacheList.value + // ? 'ossKey' in answerCacheList.value[res.qnsId] + // ? '02' + // : '01' + // : ''; + const es_status = (() => { + try { + // 基础数据校验 + if (!paperData || typeof paperData !== 'object') return ''; + if (paperData.isCacheExam === 'N') return ''; + + // 缓存列表校验 + if (!answerCacheList?.value || typeof answerCacheList.value !== 'object') return ''; + + // 问题ID校验 + if (!res || !res.qnsId || typeof res.qnsId !== 'string') return ''; + + // 检查缓存中是否存在该问题 + if (!(res.qnsId in answerCacheList.value)) return ''; + + const cachedAnswer = answerCacheList.value[res.qnsId]; + if (!cachedAnswer || typeof cachedAnswer !== 'object') return '01'; + + // 最终判断 + return 'ossKey' in cachedAnswer ? '02' : '01'; + } catch (error) { + // 捕获所有意外错误,如变量未定义、类型异常等 + console.error('获取es_status出错:', error); + return ''; // 错误情况下的默认值,可根据业务调整 + } + })(); + // const my_answer = + // paperData.isCacheExam === 'N' + // ? [] + // : res.qnsId in answerCacheList.value + // ? answerCacheList.value[res.qnsId] + // : []; + const my_answer = (() => { + try { + // 基础数据校验 + if (!paperData || typeof paperData !== 'object') { + return []; + } + // 如果不需要缓存,直接返回空数组 + if (paperData.isCacheExam === 'N') { + return []; + } + // 校验缓存列表是否存在且为对象类型 + if (!answerCacheList?.value || typeof answerCacheList.value !== 'object') { + return []; + } + // 校验问题ID是否有效 + if (!res || typeof res.qnsId === 'undefined') { + return []; + } + // 检查缓存中是否存在该问题的答案 + if (res.qnsId in answerCacheList.value) { + const cachedAnswer = answerCacheList.value[res.qnsId]; + // 确保返回值是数组类型(根据原逻辑推测应该返回数组) + return Array.isArray(cachedAnswer) ? cachedAnswer : []; + } + // 缓存中不存在时返回空数组 + return []; + } catch (error) { + console.error('获取my_answer出错:', error); + return []; // 任何异常都返回空数组,保证程序稳定性 + } + })(); return { ...res, mark: false,