From 18ab00bce191960476ab9f2be035d98a79c678cb Mon Sep 17 00:00:00 2001 From: Zeke Zhang <958414905@qq.com> Date: Wed, 19 Mar 2025 16:22:43 +0800 Subject: [PATCH] fix: remove deprecated menuSchemaUid usage and simplify path generation (#6483) * fix: remove deprecated menuSchemaUid usage and simplify path generation * fix: remove deprecated menuSchemaUid from route schema creation --- .../src/client/routesTableSchema.tsx | 27 ++++++++----------- .../plugin-client/src/client/utils.tsx | 2 +- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-client/src/client/routesTableSchema.tsx b/packages/plugins/@nocobase/plugin-client/src/client/routesTableSchema.tsx index 05e7bc6de9..c9e190c2f0 100644 --- a/packages/plugins/@nocobase/plugin-client/src/client/routesTableSchema.tsx +++ b/packages/plugins/@nocobase/plugin-client/src/client/routesTableSchema.tsx @@ -398,8 +398,9 @@ export const createRoutesTableSchema = (collectionName: string, basename: string await form.submit(); field.data = field.data || {}; field.data.loading = true; - const { pageSchemaUid, tabSchemaUid, menuSchemaUid, tabSchemaName } = - await createRouteSchema(form.values); + const { pageSchemaUid, tabSchemaUid, tabSchemaName } = await createRouteSchema( + form.values, + ); let options; if (form.values.href || !_.isEmpty(form.values.params)) { @@ -427,10 +428,7 @@ export const createRoutesTableSchema = (collectionName: string, basename: string const res = await createRoute({ ..._.omit(form.values, ['href', 'params', 'url']), schemaUid: - NocoBaseDesktopRouteType.page === form.values.type - ? pageSchemaUid - : menuSchemaUid, - menuSchemaUid, + NocoBaseDesktopRouteType.page === form.values.type ? pageSchemaUid : undefined, options, ...childrenObj, }); @@ -578,9 +576,7 @@ export const createRoutesTableSchema = (collectionName: string, basename: string } if (recordData.type === NocoBaseDesktopRouteType.page) { - const path = `${basenameOfCurrentRouter.slice(0, -1)}${basename}/${ - isMobile ? recordData.schemaUid : recordData.menuSchemaUid - }`; + const path = `${basenameOfCurrentRouter.slice(0, -1)}${basename}/${recordData.schemaUid}`; // 在点击 Access 按钮时,会用到 recordData._path = path; @@ -596,7 +592,7 @@ export const createRoutesTableSchema = (collectionName: string, basename: string recordData.parentId, data.data, isMobile, - )}/tabs/${recordData.tabSchemaName || recordData.schemaUid}`; + )}/tabs/${recordData.schemaUid}`; recordData._path = path; return ( @@ -877,8 +873,9 @@ export const createRoutesTableSchema = (collectionName: string, basename: string }); } else { let options; - const { pageSchemaUid, tabSchemaUid, menuSchemaUid, tabSchemaName } = - await createRouteSchema(form.values); + const { pageSchemaUid, tabSchemaUid, tabSchemaName } = await createRouteSchema( + form.values, + ); if (form.values.href || !_.isEmpty(form.values.params)) { options = { @@ -893,8 +890,7 @@ export const createRoutesTableSchema = (collectionName: string, basename: string schemaUid: NocoBaseDesktopRouteType.page === form.values.type ? pageSchemaUid - : menuSchemaUid, - menuSchemaUid, + : undefined, options, }); @@ -1253,7 +1249,6 @@ function useCreateRouteSchema(isMobile: boolean) { const createRouteSchema = useCallback( async ({ type }: { type: NocoBaseDesktopRouteType }) => { - const menuSchemaUid = isMobile ? undefined : uid(); const pageSchemaUid = uid(); const tabSchemaName = uid(); const tabSchemaUid = type === NocoBaseDesktopRouteType.page ? uid() : undefined; @@ -1284,7 +1279,7 @@ function useCreateRouteSchema(isMobile: boolean) { await insertPageSchema(typeToSchema[type]); } - return { menuSchemaUid, pageSchemaUid, tabSchemaUid, tabSchemaName }; + return { pageSchemaUid, tabSchemaUid, tabSchemaName }; }, [isMobile, resource, insertPageSchema], ); diff --git a/packages/plugins/@nocobase/plugin-client/src/client/utils.tsx b/packages/plugins/@nocobase/plugin-client/src/client/utils.tsx index ff62e76cba..4eec50f835 100644 --- a/packages/plugins/@nocobase/plugin-client/src/client/utils.tsx +++ b/packages/plugins/@nocobase/plugin-client/src/client/utils.tsx @@ -13,7 +13,7 @@ export function getSchemaUidByRouteId(routeId: number, treeArray: any[], isMobil for (const node of treeArray) { if (node.id === routeId) { if (node.type === NocoBaseDesktopRouteType.page) { - return isMobile ? node.schemaUid : node.menuSchemaUid; + return node.schemaUid; } return node.schemaUid; }