From e404fa3ac077164df73fbbc0de3fcd770968296f Mon Sep 17 00:00:00 2001 From: Syngnat Date: Sun, 19 Jul 2026 00:22:02 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(data-grid):=20=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E6=97=A0=20navigator=20=E7=9A=84=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=AB=AF=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 通过 globalThis 安全注入浏览器 navigator,避免 Node 20 渲染期抛错 - 补充无 navigator 环境下的 DataGrid 服务端渲染回归测试 - 保持浏览器剪贴板行为不变 --- .../src/components/DataGrid.layout.test.tsx | 31 +++++++++++++++++++ frontend/src/components/DataGrid.tsx | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/DataGrid.layout.test.tsx b/frontend/src/components/DataGrid.layout.test.tsx index e044f5df..be72534d 100644 --- a/frontend/src/components/DataGrid.layout.test.tsx +++ b/frontend/src/components/DataGrid.layout.test.tsx @@ -149,6 +149,37 @@ const zhObjectDesignLabel = zhCnCatalog['data_grid.secondary.object_design']; const enUndoCellChangeLabel = enUsCatalog['data_grid.context_menu.undo_cell_change']; describe('DataGrid layout', () => { + it('renders without navigator in server-side environments', () => { + const navigatorDescriptor = Object.getOwnPropertyDescriptor(globalThis, 'navigator'); + Reflect.deleteProperty(globalThis, 'navigator'); + + try { + expect(() => renderDataGridWithI18n( + {}} + />, + )).not.toThrow(); + } finally { + if (navigatorDescriptor) { + Object.defineProperty(globalThis, 'navigator', navigatorDescriptor); + } else { + Reflect.deleteProperty(globalThis, 'navigator'); + } + } + }); + it('renders a secondary action strip for view switching and auxiliary actions', () => { const markup = renderDataGridWithI18n( = ({ isQueryResultExport, mergedDisplayData, modal, - navigator, + navigator: globalThis.navigator, objectType, pagination, pickDataGridOutputRows,