From 4c390d209b45d516fbe2f7552d26048687c83972 Mon Sep 17 00:00:00 2001
From: chenyao <1219716595@qq.com>
Date: Wed, 05 Aug 2026 14:29:25 +0800
Subject: [PATCH] feat:tab切换太快的时候内容不对应
---
uniapps/work-app/src/pages/work/index.vue | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/uniapps/work-app/src/pages/work/index.vue b/uniapps/work-app/src/pages/work/index.vue
index 345df74..4b42810 100644
--- a/uniapps/work-app/src/pages/work/index.vue
+++ b/uniapps/work-app/src/pages/work/index.vue
@@ -128,6 +128,7 @@
keyword: '',
eventStatus: '',
})
+let requestSeq = 0 // 请求序列号,用于丢弃快速切换tab时的过期响应
const mockGeojson =
'[{"score":0.89990234375,"bbox":{"x_cen":195.5,"y_cen":326.5,"width":117.0,"height":265.0},"class_name":"car","algorithmId":"e71116098eeb1d60cfebd04d30653b151"},{"score":0.89306640625,"bbox":{"x_cen":1194.5,"y_cen":559.5,"width":115.0,"height":261.0},"class_name":"car","algorithmId":"e71116098eeb1d60cfebd04d30653b151"},{"score":0.88720703125,"bbox":{"x_cen":179.0,"y_cen":955.5,"width":124.0,"height":249.0},"class_name":"car","algorithmId":"e71116098eeb1d60cfebd04d30653b151"},{"score":0.88330078125,"bbox":{"x_cen":1198.5,"y_cen":260.5,"width":115.0,"height":285.0},"class_name":"car","algorithmId":"e71116098eeb1d60cfebd04d30653b151"},{"score":0.84716796875,"bbox":{"x_cen":204.5,"y_cen":71.5,"width":115.0,"height":143.0},"class_name":"car","algorithmId":"e71116098eeb1d60cfebd04d30653b151"},{"score":0.83203125,"bbox":{"x_cen":186.0,"y_cen":657.5,"width":114.0,"height":269.0},"class_name":"car","algorithmId":"e71116098eeb1d60cfebd04d30653b151"},{"score":0.78662109375,"bbox":{"x_cen":1205.5,"y_cen":49.5,"width":117.0,"height":99.0},"class_name":"car","algorithmId":"e71116098eeb1d60cfebd04d30653b151"}]'
const canvasSize = ref({
@@ -233,8 +234,10 @@
}
const getDataList = () => {
- if (loading.value || !hasMore.value) return
+ if (!hasMore.value) return
+ // 每次请求自增序列号,响应回来时校验是否过期
+ const seq = ++requestSeq
loading.value = true
const params = {
current: listParams.value.current,
@@ -245,6 +248,8 @@
}
getGdList(params)
.then(async res => {
+ // 已有新请求发出,丢弃过期响应
+ if (seq !== requestSeq) return
const resData = res.data.data
const response = resData.records
const list = []
@@ -257,6 +262,8 @@
list.push({ ...item, aiImg })
}
}
+ // 画图为异步耗时操作,完成后再次校验是否过期
+ if (seq !== requestSeq) return
// 根据当前页码决定是替换还是追加数据
if (listParams.value.current === 1) {
dataList.value = list
@@ -271,7 +278,8 @@
}
})
.finally(() => {
- loading.value = false
+ // 仅在最新一次请求结束时关闭loading,避免过早关闭
+ if (seq === requestSeq) loading.value = false
})
}
const getstatusCountData = () => {
--
Gitblit v1.9.3