Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
CI / CI OK (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
37 lines
770 B
TypeScript
37 lines
770 B
TypeScript
import { MOCK_API_DATA } from './table-data';
|
|
|
|
export namespace DemoTableApi {
|
|
export interface PageFetchParams {
|
|
[key: string]: any;
|
|
page: number;
|
|
pageSize: number;
|
|
}
|
|
}
|
|
|
|
export function sleep(time = 1000) {
|
|
return new Promise((resolve) => {
|
|
setTimeout(() => {
|
|
resolve(true);
|
|
}, time);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 获取示例表格数据
|
|
*/
|
|
async function getExampleTableApi(params: DemoTableApi.PageFetchParams) {
|
|
return new Promise<{ items: any; total: number }>((resolve) => {
|
|
const { page, pageSize } = params;
|
|
const items = MOCK_API_DATA.slice((page - 1) * pageSize, page * pageSize);
|
|
|
|
sleep(1000).then(() => {
|
|
resolve({
|
|
total: items.length,
|
|
items,
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
export { getExampleTableApi };
|