feat(请求): 添加请求取消功能并修改示例页面
在 listAll 服务中添加延迟以测试取消功能 在示例页面添加取消按钮并修改请求方法
This commit is contained in:
@@ -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 || {}),
|
||||
|
||||
Reference in New Issue
Block a user