mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-10 16:53:35 +08:00
🐛 fix(data-grid): 兼容无 navigator 的服务端渲染
- 通过 globalThis 安全注入浏览器 navigator,避免 Node 20 渲染期抛错 - 补充无 navigator 环境下的 DataGrid 服务端渲染回归测试 - 保持浏览器剪贴板行为不变
This commit is contained in:
@@ -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(
|
||||
<DataGrid
|
||||
data={[]}
|
||||
columnNames={[]}
|
||||
loading={false}
|
||||
tableName="users"
|
||||
dbName="main"
|
||||
connectionId="conn-1"
|
||||
readOnly
|
||||
pagination={{
|
||||
current: 1,
|
||||
pageSize: 100,
|
||||
total: 0,
|
||||
}}
|
||||
onPageChange={() => {}}
|
||||
/>,
|
||||
)).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(
|
||||
<DataGrid
|
||||
|
||||
@@ -3407,7 +3407,7 @@ const DataGrid: React.FC<DataGridProps> = ({
|
||||
isQueryResultExport,
|
||||
mergedDisplayData,
|
||||
modal,
|
||||
navigator,
|
||||
navigator: globalThis.navigator,
|
||||
objectType,
|
||||
pagination,
|
||||
pickDataGridOutputRows,
|
||||
|
||||
Reference in New Issue
Block a user