fix: 对齐QQBot插件分页页面
This commit is contained in:
parent
9f20988fbd
commit
c08aa84696
49
apps/web-antdv-next/src/api/qqbot/index.spec.ts
Normal file
49
apps/web-antdv-next/src/api/qqbot/index.spec.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
import { getQqbotPluginOperationPage } from './index';
|
||||
|
||||
vi.mock('#/api/request', () => ({
|
||||
requestClient: {
|
||||
get: vi.fn(),
|
||||
getBaseUrl: vi.fn(() => ''),
|
||||
},
|
||||
}));
|
||||
|
||||
describe('qqbot plugin API wrappers', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('uses the paged plugin operation endpoint for KtTable', async () => {
|
||||
const pageResult = {
|
||||
list: [],
|
||||
pageNo: 2,
|
||||
pageSize: 1,
|
||||
total: 3,
|
||||
};
|
||||
vi.mocked(requestClient.get).mockResolvedValueOnce(pageResult);
|
||||
|
||||
await expect(
|
||||
getQqbotPluginOperationPage({
|
||||
pageNo: 2,
|
||||
pageSize: 1,
|
||||
pluginKey: 'bangdream',
|
||||
triggerMode: 'command',
|
||||
}),
|
||||
).resolves.toBe(pageResult);
|
||||
|
||||
expect(requestClient.get).toHaveBeenCalledWith(
|
||||
'/qqbot/plugin/operation/page',
|
||||
{
|
||||
params: {
|
||||
pageNo: 2,
|
||||
pageSize: 1,
|
||||
pluginKey: 'bangdream',
|
||||
triggerMode: 'command',
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
@ -284,6 +284,13 @@ export namespace QqbotApi {
|
||||
triggerMode: PluginTriggerMode;
|
||||
}
|
||||
|
||||
export interface PluginOperationQuery extends Recordable<any> {
|
||||
pageNo?: number;
|
||||
pageSize?: number;
|
||||
pluginKey?: string;
|
||||
triggerMode?: PluginTriggerMode;
|
||||
}
|
||||
|
||||
export interface PluginHealth {
|
||||
checkedAt: string;
|
||||
message?: string;
|
||||
@ -605,6 +612,15 @@ export function getQqbotPluginOperationList(
|
||||
);
|
||||
}
|
||||
|
||||
export function getQqbotPluginOperationPage(
|
||||
params: QqbotApi.PluginOperationQuery,
|
||||
) {
|
||||
return requestClient.get<QqbotApi.PageResult<QqbotApi.PluginOperation>>(
|
||||
'/qqbot/plugin/operation/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
export function getQqbotPluginHealth(
|
||||
pluginKey?: string,
|
||||
triggerMode?: QqbotApi.PluginTriggerMode,
|
||||
|
||||
@ -14,7 +14,7 @@ import { Drawer, message, Modal, Tag } from 'antdv-next';
|
||||
import {
|
||||
getQqbotPluginHealth,
|
||||
getQqbotPluginList,
|
||||
getQqbotPluginOperationList,
|
||||
getQqbotPluginOperationPage,
|
||||
} from '#/api/qqbot';
|
||||
import {
|
||||
disableQqbotPluginInstallation,
|
||||
@ -129,8 +129,7 @@ export default defineComponent({
|
||||
},
|
||||
];
|
||||
const api: KtTableApi<QqbotApi.PluginOperation> = {
|
||||
list: async (params) =>
|
||||
await getQqbotPluginOperationList(params.pluginKey, params.triggerMode),
|
||||
list: async (params) => await getQqbotPluginOperationPage(params),
|
||||
};
|
||||
const buttons: Array<KtTableButton<QqbotApi.PluginOperation>> = [
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user