feat(请求): 添加请求取消功能并修改示例页面

在 listAll 服务中添加延迟以测试取消功能
在示例页面添加取消按钮并修改请求方法
This commit is contained in:
feige996
2025-09-23 18:24:40 +08:00
parent fee5f23d37
commit 7b37bccd98
2 changed files with 14 additions and 9 deletions

View File

@@ -4,6 +4,7 @@ import request from '@/http/vue-query';
import { CustomRequestOptions } from '@/http/types';
import * as API from './types';
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
/** 用户列表 GET /user/listAll */
export async function listAllUsingGet({
@@ -11,6 +12,7 @@ export async function listAllUsingGet({
}: {
options?: CustomRequestOptions;
}) {
await sleep(2000); // 方便测试 cancel 功能
return request<API.UserItem[]>('/user/listAll', {
method: 'GET',
...(options || {}),