From d9eb8f21f12defeeb37804d40e454681bd31d364 Mon Sep 17 00:00:00 2001 From: raoyongjun <2641346316@qq.com> Date: Wed, 8 May 2024 16:23:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/home/main.ts | 12 +++++++++++- src/views/home/content/Content.vue | 9 ++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/api/home/main.ts b/src/api/home/main.ts index b9d8ce1..60134e3 100644 --- a/src/api/home/main.ts +++ b/src/api/home/main.ts @@ -1,10 +1,14 @@ +import { pickBy } from 'lodash-es' +import axios from 'axios' import { ContentTypeEnum } from '@/enums/httpEnum' import { notEmpty } from '@/utils' import { formatToDate2 } from '@/utils/dateUtil' import { http } from '@/utils/http/axios' -import { pickBy } from 'lodash-es' import type { CheckParam, PageParam, QueryPictureParam, UploadParam } from '/#/api' +const CancelToken = axios.CancelToken +window.cancle = {} + /** * 头部信息 * @returns @@ -224,6 +228,9 @@ export async function queryPageListByCheckNo(params: any): Promise { method: 'get', params: notEmptyParams, headers: { 'Content-Type': ContentTypeEnum.FORM_DATA }, + cancelToken: new CancelToken((c) => { + window.cancle.queryPageListByCheckNo = c + }), }) const { data: { records, pages, total, current } } = res @@ -260,6 +267,9 @@ export async function getPictureList(params: any): Promise { method: 'get', params: notEmptyParams, headers: { 'Content-Type': ContentTypeEnum.FORM_DATA }, + cancelToken: new CancelToken((c) => { + window.cancle.getPictureList = c + }), }) const { data: { records, pages, total, current } } = res diff --git a/src/views/home/content/Content.vue b/src/views/home/content/Content.vue index 8d91603..60f6c4b 100644 --- a/src/views/home/content/Content.vue +++ b/src/views/home/content/Content.vue @@ -299,8 +299,12 @@ async function featchList(userSearchId?: string) { params.izsimilarity = params.izsimilarity.join('-') // rao end - + console.log('window.cancle.queryPageListByCheckNo', window.cancle.queryPageListByCheckNo) + console.log('window.cancle.getPictureList', window.cancle.getPictureList) if (checkTaskStatus.value === 2 && isRefresh) { + // 取消上次的请求 + window.cancle.queryPageListByCheckNo && window.cancle.queryPageListByCheckNo() + window.cancle.getPictureList && window.cancle.getPictureList() result = await queryPageListByCheckNo({ ...pagination, ...contentParams, @@ -311,6 +315,9 @@ async function featchList(userSearchId?: string) { }) } else { + // 取消上次的请求 + window.cancle.queryPageListByCheckNo && window.cancle.queryPageListByCheckNo() + window.cancle.getPictureList && window.cancle.getPictureList() result = await getPictureList({ ...pagination, ...contentParams,