From bbb7c868f2279668760932527ac58bb158e5b4b6 Mon Sep 17 00:00:00 2001 From: MR-ZC <1475796375@qq.com> Date: Sun, 23 Mar 2025 17:59:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=88=AA=E7=82=B9=E8=88=AA?= =?UTF-8?q?=E7=BA=BF=E9=A2=84=E8=A7=88API=E4=BB=A5=E6=94=AF=E6=8C=81AbortS?= =?UTF-8?q?ignal=EF=BC=9B=E4=BC=98=E5=8C=96=E4=BB=BB=E5=8A=A1=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E9=87=8D=E5=A4=8D=E8=AF=B7=E6=B1=82=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/task.ts | 4 ++-- src/components/zfControlPlatform/index.vue | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/api/task.ts b/src/api/task.ts index 2f07414..7c70167 100644 --- a/src/api/task.ts +++ b/src/api/task.ts @@ -8,6 +8,6 @@ export const queryFlightRoutes = (params: any) => to( /**获取航点航线预览参数*/ -export const queryWaypointRoutePreview= (params: any) => to( - http.get('/api/waypoint-route-preview', { params }) +export const queryWaypointRoutePreview= (params: any,signal?: AbortSignal) => to( + http.get('/api/waypoint-route-preview', { params,signal}) ) diff --git a/src/components/zfControlPlatform/index.vue b/src/components/zfControlPlatform/index.vue index 298ab07..c1687f1 100644 --- a/src/components/zfControlPlatform/index.vue +++ b/src/components/zfControlPlatform/index.vue @@ -83,20 +83,21 @@ const loadMoreFlightRoutes = async () => { await getFlightRoutes(true); }; - // 处理任务点击事件 +let abortController = new AbortController() +const currentTaskId = ref("") const handleSelectTask = async (task: any) => { - console.log("点击任务==>>", task) + if (currentTaskId.value === task.id) return; + currentTaskId.value = task.id + try{abortController.abort()}catch(e){} + abortController = new AbortController() const [error, res] = await queryWaypointRoutePreview({ airwayId: task.id - }); + }, abortController.signal); if (error) return console.log("获取航点航线预览参数失败==>>", error); console.log("获取航点航线预览参数成功==>>", res) } - - -