diff --git a/apps/web-antdv-next/src/api/qqbot/index.spec.ts b/apps/web-antdv-next/src/api/qqbot/index.spec.ts new file mode 100644 index 0000000..9e2f9c1 --- /dev/null +++ b/apps/web-antdv-next/src/api/qqbot/index.spec.ts @@ -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', + }, + }, + ); + }); +}); diff --git a/apps/web-antdv-next/src/api/qqbot/index.ts b/apps/web-antdv-next/src/api/qqbot/index.ts index 85febbc..4fca431 100644 --- a/apps/web-antdv-next/src/api/qqbot/index.ts +++ b/apps/web-antdv-next/src/api/qqbot/index.ts @@ -284,6 +284,13 @@ export namespace QqbotApi { triggerMode: PluginTriggerMode; } + export interface PluginOperationQuery extends Recordable { + 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>( + '/qqbot/plugin/operation/page', + { params }, + ); +} + export function getQqbotPluginHealth( pluginKey?: string, triggerMode?: QqbotApi.PluginTriggerMode, diff --git a/apps/web-antdv-next/src/views/qqbot/plugin/list.tsx b/apps/web-antdv-next/src/views/qqbot/plugin/list.tsx index 3a62796..aeaf038 100644 --- a/apps/web-antdv-next/src/views/qqbot/plugin/list.tsx +++ b/apps/web-antdv-next/src/views/qqbot/plugin/list.tsx @@ -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 = { - list: async (params) => - await getQqbotPluginOperationList(params.pluginKey, params.triggerMode), + list: async (params) => await getQqbotPluginOperationPage(params), }; const buttons: Array> = [ {