From 1c7184b6bc43251d3a6e6c47f0c5091232c47596 Mon Sep 17 00:00:00 2001 From: iven Date: Mon, 27 Apr 2026 09:57:41 +0800 Subject: [PATCH] =?UTF-8?q?perf(web):=20PluginCRUDPage=20columns=20?= =?UTF-8?q?=E5=8C=85=E8=A3=B9=20useMemo=20=E9=81=BF=E5=85=8D=E9=87=8D?= =?UTF-8?q?=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit columns 依赖 fields/resolvedLabels/labelMeta,搜索输入时不再重建列定义。 --- apps/web/src/pages/PluginCRUDPage.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/web/src/pages/PluginCRUDPage.tsx b/apps/web/src/pages/PluginCRUDPage.tsx index ec0f3f2..fa897a1 100644 --- a/apps/web/src/pages/PluginCRUDPage.tsx +++ b/apps/web/src/pages/PluginCRUDPage.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState, useCallback } from 'react'; +import { useEffect, useState, useCallback, useMemo } from 'react'; import { useParams } from 'react-router-dom'; import { Table, @@ -305,8 +305,8 @@ export default function PluginCRUDPage({ } }; - // 动态生成列 - const columns = [ + // 动态生成列(memo 化避免输入搜索时重建) + const columns = useMemo(() => [ ...fields.slice(0, 5).map((f) => ({ title: f.display_name || f.name, dataIndex: f.name, @@ -315,7 +315,6 @@ export default function PluginCRUDPage({ sorter: f.sortable ? true : undefined, render: (val: unknown) => { if (typeof val === 'boolean') return val ? : ; - // 引用字段 → 显示解析后的标签 if (f.ref_entity) { const uuid = String(val ?? ''); if (!uuid || uuid === '-') return '-'; @@ -366,7 +365,7 @@ export default function PluginCRUDPage({ ), }, - ]; + ], [fields, resolvedLabels, labelMeta, hasDetailPage, handleDelete]); // 动态生成表单字段 const renderFormField = (field: PluginFieldSchema) => {