mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
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
This commit is contained in:
parent
7a884734dd
commit
18ab00bce1
@ -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],
|
||||
);
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user