From a8520e20ba5f31fb853fd4a4b05c34e612d95de4 Mon Sep 17 00:00:00 2001 From: chenjiale Date: Wed, 24 Dec 2025 13:54:30 +0800 Subject: [PATCH] =?UTF-8?q?```=20feat(alert):=20=E4=B8=BA=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E5=8D=A1=E7=89=87=E5=88=97=E8=A1=A8=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E5=92=8C=E6=97=A0=E9=99=90=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 PageResult 泛型接口用于分页数据结构 - 添加 ModelCardQueryParams 接口支持分页参数 - 修改 modelCardListApi 返回类型为 PageResult - 实现无限滚动加载功能,使用 IntersectionObserver 监听滚动 - 添加加载状态显示(加载中、没有更多、暂无数据) - 优化模型列表加载逻辑,支持追加加载模式 - 添加页面生命周期钩子处理 --- src/api/alert/model/model/models.ts | 13 +++ src/api/alert/model/models.ts | 6 +- src/views/model/list/ModelCard.vue | 134 ++++++++++++++++++++++++---- 3 files changed, 135 insertions(+), 18 deletions(-) diff --git a/src/api/alert/model/model/models.ts b/src/api/alert/model/model/models.ts index 0a2dcca..1fbe97e 100644 --- a/src/api/alert/model/model/models.ts +++ b/src/api/alert/model/model/models.ts @@ -7,6 +7,14 @@ export interface ModelCardItem { createTime: string } +export interface PageResult { + total: number + current: number + size: number + records: T[] + pages: number +} + interface MovingWindows { windowLength: number samplingInterval: number @@ -32,3 +40,8 @@ export interface ModelQueryParams { visible?: number | null trash?: number | null } + +export interface ModelCardQueryParams extends ModelQueryParams { + pageNo?: number + pageSize?: number +} diff --git a/src/api/alert/model/models.ts b/src/api/alert/model/models.ts index ce101ed..c0c9041 100644 --- a/src/api/alert/model/models.ts +++ b/src/api/alert/model/models.ts @@ -1,4 +1,4 @@ -import type { ModelCardItem, ModelInfo, ModelQueryParams } from './model/models' +import type { ModelCardItem, ModelCardQueryParams, ModelInfo, PageResult } from './model/models' import { defHttp } from '@/utils/http/axios' enum Api { @@ -17,8 +17,8 @@ enum Api { VERSION_LIST = '/alert/model/version/', VERSION_NEW = '/alert/model/version/new/', } -export function modelCardListApi(params?: ModelQueryParams) { - return defHttp.get({ url: Api.MODEL_CARD_LIST, params }) +export function modelCardListApi(params?: ModelCardQueryParams) { + return defHttp.get>({ url: Api.MODEL_CARD_LIST, params }) } export const modelInfoApi = (idOrPath: any) => defHttp.get({ url: `${Api.MODEL_INFO}/${idOrPath}` }) diff --git a/src/views/model/list/ModelCard.vue b/src/views/model/list/ModelCard.vue index 29ce180..16aa61c 100644 --- a/src/views/model/list/ModelCard.vue +++ b/src/views/model/list/ModelCard.vue @@ -1,11 +1,11 @@