refactor(screen): 移除缓存过期检查逻辑并优化代码结构
- 移除了 mainScreen.vue 和 regionScreen.vue 中的缓存过期时间检查逻辑 - 简化了缓存数据的读取流程,直接返回缓存数据 - 调整了 regionScreen.vue 中风险预警详情数据的赋值缩进 - 优化了维保任务和巡检任务API调用的参数格式 - 统一了代码中的空行和缩进格式
This commit is contained in:
@@ -231,15 +231,8 @@ const getCachedRegionOption = (): any[] | null => {
|
||||
const cached = sessionStorage.getItem(CACHE_KEY)
|
||||
if (cached) {
|
||||
const cacheData: CacheData = JSON.parse(cached)
|
||||
const now = Date.now()
|
||||
// 检查缓存是否在有效期内
|
||||
if (now - cacheData.timestamp < CACHE_DURATION) {
|
||||
console.log('使用缓存的 regionOption 数据')
|
||||
return cacheData.records
|
||||
} else {
|
||||
console.log('缓存已过期,清除缓存')
|
||||
sessionStorage.removeItem(CACHE_KEY)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('读取缓存失败:', error)
|
||||
|
||||
@@ -237,15 +237,8 @@ const getCachedRegionOption = (): any[] | null => {
|
||||
const cached = sessionStorage.getItem(CACHE_KEY)
|
||||
if (cached) {
|
||||
const cacheData: CacheData = JSON.parse(cached)
|
||||
const now = Date.now()
|
||||
// 检查缓存是否在有效期内
|
||||
if (now - cacheData.timestamp < CACHE_DURATION) {
|
||||
console.log('使用缓存的 regionOption 数据')
|
||||
return cacheData.records
|
||||
} else {
|
||||
console.log('缓存已过期,清除缓存')
|
||||
sessionStorage.removeItem(CACHE_KEY)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('读取缓存失败:', error)
|
||||
@@ -643,11 +636,19 @@ const handleRiskTabChange = async (tab: TabType) => {
|
||||
|
||||
// 同时获取维保任务和巡检任务的数据
|
||||
const [maintenanceResponse, inspectionResponse] = await Promise.all([
|
||||
getWorkOrderStatistics({workOrderType, taskType: '维保任务', campus_id: query.campus_id}).catch(error => {
|
||||
getWorkOrderStatistics({
|
||||
workOrderType,
|
||||
taskType: '维保任务',
|
||||
campus_id: query.campus_id
|
||||
}).catch(error => {
|
||||
console.error('获取维保任务数据失败:', error)
|
||||
return {records: []}
|
||||
}),
|
||||
getWorkOrderStatistics({workOrderType, taskType: '巡检任务', campus_id: query.campus_id}).catch(error => {
|
||||
getWorkOrderStatistics({
|
||||
workOrderType,
|
||||
taskType: '巡检任务',
|
||||
campus_id: query.campus_id
|
||||
}).catch(error => {
|
||||
console.error('获取巡检任务数据失败:', error)
|
||||
return {records: []}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user