From 838d7417641e780be17b1119ad56f7a9f20fd717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=A4=9A=E7=9B=8A?= Date: Wed, 9 Mar 2022 19:56:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=81=BF=E5=85=8D=20table/nav=20?= =?UTF-8?q?=E9=87=8C=E6=95=B0=E6=8D=AE=20id=20=E4=B8=8D=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E9=A1=B5=E9=9D=A2=E6=8A=A5=E9=94=99=EF=BC=8C?= =?UTF-8?q?=E5=B0=86=E4=B9=8B=E5=89=8D=E7=9A=84=20id=20=E6=8D=A2=E6=88=90?= =?UTF-8?q?=E6=9B=B4=E4=B8=8D=E5=AE=B9=E6=98=93=E5=86=B2=E7=AA=81=E7=9A=84?= =?UTF-8?q?=20=5F=5Fid=20=E5=AD=97=E6=AE=B5=20(#3731)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __tests__/mockData/rows.ts | 20 ++++++------- __tests__/renderers/CRUD.test.tsx | 2 +- __tests__/renderers/Nav.test.tsx | 8 +++--- __tests__/renderers/Table.test.tsx | 46 +++++++++++++++--------------- src/renderers/Nav.tsx | 2 +- src/store/table.ts | 4 +-- 6 files changed, 41 insertions(+), 41 deletions(-) diff --git a/__tests__/mockData/rows.ts b/__tests__/mockData/rows.ts index b95611b11..9d6d1beeb 100644 --- a/__tests__/mockData/rows.ts +++ b/__tests__/mockData/rows.ts @@ -5,7 +5,7 @@ export default [ platform: 'Win 95+', version: '4', grade: 'A', - id: 1 + __id: 1 }, { engine: 'Trident', @@ -13,7 +13,7 @@ export default [ platform: 'Win 95+', version: '4', grade: 'B', - id: 2 + __id: 2 }, { engine: 'Trident', @@ -21,7 +21,7 @@ export default [ platform: 'Win 95+', version: '4', grade: 'C', - id: 3 + __id: 3 }, { engine: 'Trident', @@ -29,7 +29,7 @@ export default [ platform: 'Win 98', version: '3', grade: 'A', - id: 4 + __id: 4 }, { engine: 'Trident', @@ -37,7 +37,7 @@ export default [ platform: 'Win 98', version: '4', grade: 'A', - id: 5 + __id: 5 }, { engine: 'Gecko', @@ -45,7 +45,7 @@ export default [ platform: 'Win 98+ / OSX.2+', version: '4', grade: 'A', - id: 6 + __id: 6 }, { engine: 'Gecko', @@ -53,7 +53,7 @@ export default [ platform: 'Win 98+ / OSX.2+', version: '5', grade: 'A', - id: 7 + __id: 7 }, { engine: 'Gecko', @@ -61,7 +61,7 @@ export default [ platform: 'Win 98+ / OSX.2+', version: '5', grade: 'B', - id: 8 + __id: 8 }, { engine: 'Gecko', @@ -69,7 +69,7 @@ export default [ platform: 'Win 98+ / OSX.2+', version: '5', grade: 'C', - id: 9 + __id: 9 }, { engine: 'Gecko', @@ -77,6 +77,6 @@ export default [ platform: 'Win 98+ / OSX.2+', version: '5', grade: 'D', - id: 10 + __id: 10 } ]; diff --git a/__tests__/renderers/CRUD.test.tsx b/__tests__/renderers/CRUD.test.tsx index b055fff4f..da7696424 100644 --- a/__tests__/renderers/CRUD.test.tsx +++ b/__tests__/renderers/CRUD.test.tsx @@ -16,7 +16,7 @@ test('Renderer:crud', async () => { syncLocation: false, columns: [ { - name: 'id', + name: '__id', label: 'ID' }, { diff --git a/__tests__/renderers/Nav.test.tsx b/__tests__/renderers/Nav.test.tsx index df18274e7..60436d462 100644 --- a/__tests__/renderers/Nav.test.tsx +++ b/__tests__/renderers/Nav.test.tsx @@ -20,28 +20,28 @@ test('Renderer:nav', () => { }, links: [ { - id: 0, + __id: 0, label: 'Nav 1', to: '/docs/index', icon: 'https://suda.cdn.bcebos.com/images%2F2021-01%2Fdiamond.svg', active: true }, { - id: 1, + __id: 1, label: 'Nav 2', to: '/docs/api', customText: 'HOT', customLevel: 'danger' }, { - id: 2, + __id: 2, label: 'Nav 3', to: '/docs/renderers', customText: 'SUC', customLevel: 'success' }, { - id: 3, + __id: 3, label: '外部地址', to: 'http://www.baidu.com/', target: '_blank' diff --git a/__tests__/renderers/Table.test.tsx b/__tests__/renderers/Table.test.tsx index 078f29b23..da8706999 100644 --- a/__tests__/renderers/Table.test.tsx +++ b/__tests__/renderers/Table.test.tsx @@ -138,7 +138,7 @@ test('Renderer:table children', () => { platform: 'Win 95+', version: '4', grade: 'X', - id: 1, + __id: 1, children: [ { engine: 'Trident', @@ -146,7 +146,7 @@ test('Renderer:table children', () => { platform: 'Win 95+', version: '4', grade: 'X', - id: 1001 + __id: 1001 }, { engine: 'Trident', @@ -154,7 +154,7 @@ test('Renderer:table children', () => { platform: 'Win 95+', version: '5', grade: 'C', - id: 1002 + __id: 1002 } ] }, @@ -164,7 +164,7 @@ test('Renderer:table children', () => { platform: 'Win 95+', version: '5', grade: 'C', - id: 2, + __id: 2, children: [ { engine: 'Trident', @@ -172,7 +172,7 @@ test('Renderer:table children', () => { platform: 'Win 95+', version: '4', grade: 'X', - id: 2001 + __id: 2001 }, { engine: 'Trident', @@ -180,7 +180,7 @@ test('Renderer:table children', () => { platform: 'Win 95+', version: '5', grade: 'C', - id: 2002 + __id: 2002 } ] }, @@ -190,7 +190,7 @@ test('Renderer:table children', () => { platform: 'Win 95+', version: '5.5', grade: 'A', - id: 3, + __id: 3, children: [ { engine: 'Trident', @@ -198,7 +198,7 @@ test('Renderer:table children', () => { platform: 'Win 95+', version: '4', grade: 'X', - id: 3001 + __id: 3001 }, { engine: 'Trident', @@ -206,7 +206,7 @@ test('Renderer:table children', () => { platform: 'Win 95+', version: '5', grade: 'C', - id: 3002 + __id: 3002 } ] }, @@ -216,7 +216,7 @@ test('Renderer:table children', () => { platform: 'Win 98+', version: '6', grade: 'A', - id: 4, + __id: 4, children: [ { engine: 'Trident', @@ -224,7 +224,7 @@ test('Renderer:table children', () => { platform: 'Win 95+', version: '4', grade: 'X', - id: 4001 + __id: 4001 }, { engine: 'Trident', @@ -232,7 +232,7 @@ test('Renderer:table children', () => { platform: 'Win 95+', version: '5', grade: 'C', - id: 4002 + __id: 4002 } ] }, @@ -242,7 +242,7 @@ test('Renderer:table children', () => { platform: 'Win XP SP2+', version: '7', grade: 'A', - id: 5, + __id: 5, children: [ { engine: 'Trident', @@ -250,7 +250,7 @@ test('Renderer:table children', () => { platform: 'Win 95+', version: '4', grade: 'X', - id: 5001 + __id: 5001 }, { engine: 'Trident', @@ -258,7 +258,7 @@ test('Renderer:table children', () => { platform: 'Win 95+', version: '5', grade: 'C', - id: 5002 + __id: 5002 } ] } @@ -288,7 +288,7 @@ test('Renderer:table children', () => { label: 'Browser' }, { - name: 'id', + name: '__id', label: 'ID' }, { @@ -398,7 +398,7 @@ test('Renderer:table list', () => { data: { items: [ { - id: '91264', + __id: '91264', text: '衡 阎', progress: 22, type: 4, @@ -439,12 +439,12 @@ test('Renderer:table list', () => { image: 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg', json: { - id: 1, + __id: 1, text: 'text' } }, { - id: '34202', + __id: '34202', text: '吉 卢汉市', progress: 85, type: 1, @@ -509,12 +509,12 @@ test('Renderer:table list', () => { image: 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg', json: { - id: 1, + __id: 1, text: 'text' } }, { - id: '37701', + __id: '37701', text: '立辉安市', progress: 72, type: 2, @@ -571,7 +571,7 @@ test('Renderer:table list', () => { image: 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg', json: { - id: 1, + __id: 1, text: 'text' } } @@ -581,7 +581,7 @@ test('Renderer:table list', () => { syncLocation: false, columns: [ { - name: 'id', + name: '__id', label: 'ID', type: 'text' }, diff --git a/src/renderers/Nav.tsx b/src/renderers/Nav.tsx index 2acbaca9a..4f4290112 100644 --- a/src/renderers/Nav.tsx +++ b/src/renderers/Nav.tsx @@ -523,7 +523,7 @@ const ConditionBuilderWithRemoteOptions = withRemoteConfig({ env && env.isCurrentUrl(filter(link.to as string, data)) )), - __id: link.id ?? link.__id ?? guid() + __id: link.__id ?? guid() }; item.unfolded = diff --git a/src/store/table.ts b/src/store/table.ts index e702bc0ab..44ed47862 100644 --- a/src/store/table.ts +++ b/src/store/table.ts @@ -899,7 +899,7 @@ export const TableStore = iRendererStore : { item }; - const id = item.id ?? guid(); + const id = item.__id ?? guid(); return { // id: String(item && (item as any)[self.primaryField] || `${pindex}-${depth}-${key}`), @@ -941,7 +941,7 @@ export const TableStore = iRendererStore let arr: Array = rows.map((item, index) => { let id = String( - getEntryId ? getEntryId(item, index) : item.id ?? guid() + getEntryId ? getEntryId(item, index) : item.__id ?? guid() ); return { // id: getEntryId ? getEntryId(item, key) : String(item && (item as any)[self.primaryField] || `${key}-1-${key}`),