修改航点航线预览API以支持AbortSignal;优化任务选择处理逻辑,避免重复请求。
This commit is contained in:
parent
e015679b95
commit
bbb7c868f2
@ -8,6 +8,6 @@ export const queryFlightRoutes = (params: any) => to<any>(
|
|||||||
|
|
||||||
|
|
||||||
/**获取航点航线预览参数*/
|
/**获取航点航线预览参数*/
|
||||||
export const queryWaypointRoutePreview= (params: any) => to<any>(
|
export const queryWaypointRoutePreview= (params: any,signal?: AbortSignal) => to<any>(
|
||||||
http.get('/api/waypoint-route-preview', { params })
|
http.get('/api/waypoint-route-preview', { params,signal})
|
||||||
)
|
)
|
||||||
|
|||||||
@ -83,20 +83,21 @@ const loadMoreFlightRoutes = async () => {
|
|||||||
await getFlightRoutes(true);
|
await getFlightRoutes(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 处理任务点击事件
|
// 处理任务点击事件
|
||||||
|
let abortController = new AbortController()
|
||||||
|
const currentTaskId = ref<string>("")
|
||||||
const handleSelectTask = async (task: any) => {
|
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({
|
const [error, res] = await queryWaypointRoutePreview({
|
||||||
airwayId: task.id
|
airwayId: task.id
|
||||||
});
|
}, abortController.signal);
|
||||||
if (error) return console.log("获取航点航线预览参数失败==>>", error);
|
if (error) return console.log("获取航点航线预览参数失败==>>", error);
|
||||||
console.log("获取航点航线预览参数成功==>>", res)
|
console.log("获取航点航线预览参数成功==>>", res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user