修改航点航线预览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>(
|
||||
http.get('/api/waypoint-route-preview', { params })
|
||||
export const queryWaypointRoutePreview= (params: any,signal?: AbortSignal) => to<any>(
|
||||
http.get('/api/waypoint-route-preview', { params,signal})
|
||||
)
|
||||
|
||||
@ -83,20 +83,21 @@ const loadMoreFlightRoutes = async () => {
|
||||
await getFlightRoutes(true);
|
||||
};
|
||||
|
||||
|
||||
// 处理任务点击事件
|
||||
let abortController = new AbortController()
|
||||
const currentTaskId = ref<string>("")
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user