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();
|
await form.submit();
|
||||||
field.data = field.data || {};
|
field.data = field.data || {};
|
||||||
field.data.loading = true;
|
field.data.loading = true;
|
||||||
const { pageSchemaUid, tabSchemaUid, menuSchemaUid, tabSchemaName } =
|
const { pageSchemaUid, tabSchemaUid, tabSchemaName } = await createRouteSchema(
|
||||||
await createRouteSchema(form.values);
|
form.values,
|
||||||
|
);
|
||||||
let options;
|
let options;
|
||||||
|
|
||||||
if (form.values.href || !_.isEmpty(form.values.params)) {
|
if (form.values.href || !_.isEmpty(form.values.params)) {
|
||||||
@ -427,10 +428,7 @@ export const createRoutesTableSchema = (collectionName: string, basename: string
|
|||||||
const res = await createRoute({
|
const res = await createRoute({
|
||||||
..._.omit(form.values, ['href', 'params', 'url']),
|
..._.omit(form.values, ['href', 'params', 'url']),
|
||||||
schemaUid:
|
schemaUid:
|
||||||
NocoBaseDesktopRouteType.page === form.values.type
|
NocoBaseDesktopRouteType.page === form.values.type ? pageSchemaUid : undefined,
|
||||||
? pageSchemaUid
|
|
||||||
: menuSchemaUid,
|
|
||||||
menuSchemaUid,
|
|
||||||
options,
|
options,
|
||||||
...childrenObj,
|
...childrenObj,
|
||||||
});
|
});
|
||||||
@ -578,9 +576,7 @@ export const createRoutesTableSchema = (collectionName: string, basename: string
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (recordData.type === NocoBaseDesktopRouteType.page) {
|
if (recordData.type === NocoBaseDesktopRouteType.page) {
|
||||||
const path = `${basenameOfCurrentRouter.slice(0, -1)}${basename}/${
|
const path = `${basenameOfCurrentRouter.slice(0, -1)}${basename}/${recordData.schemaUid}`;
|
||||||
isMobile ? recordData.schemaUid : recordData.menuSchemaUid
|
|
||||||
}`;
|
|
||||||
// 在点击 Access 按钮时,会用到
|
// 在点击 Access 按钮时,会用到
|
||||||
recordData._path = path;
|
recordData._path = path;
|
||||||
|
|
||||||
@ -596,7 +592,7 @@ export const createRoutesTableSchema = (collectionName: string, basename: string
|
|||||||
recordData.parentId,
|
recordData.parentId,
|
||||||
data.data,
|
data.data,
|
||||||
isMobile,
|
isMobile,
|
||||||
)}/tabs/${recordData.tabSchemaName || recordData.schemaUid}`;
|
)}/tabs/${recordData.schemaUid}`;
|
||||||
recordData._path = path;
|
recordData._path = path;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -877,8 +873,9 @@ export const createRoutesTableSchema = (collectionName: string, basename: string
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let options;
|
let options;
|
||||||
const { pageSchemaUid, tabSchemaUid, menuSchemaUid, tabSchemaName } =
|
const { pageSchemaUid, tabSchemaUid, tabSchemaName } = await createRouteSchema(
|
||||||
await createRouteSchema(form.values);
|
form.values,
|
||||||
|
);
|
||||||
|
|
||||||
if (form.values.href || !_.isEmpty(form.values.params)) {
|
if (form.values.href || !_.isEmpty(form.values.params)) {
|
||||||
options = {
|
options = {
|
||||||
@ -893,8 +890,7 @@ export const createRoutesTableSchema = (collectionName: string, basename: string
|
|||||||
schemaUid:
|
schemaUid:
|
||||||
NocoBaseDesktopRouteType.page === form.values.type
|
NocoBaseDesktopRouteType.page === form.values.type
|
||||||
? pageSchemaUid
|
? pageSchemaUid
|
||||||
: menuSchemaUid,
|
: undefined,
|
||||||
menuSchemaUid,
|
|
||||||
options,
|
options,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1253,7 +1249,6 @@ function useCreateRouteSchema(isMobile: boolean) {
|
|||||||
|
|
||||||
const createRouteSchema = useCallback(
|
const createRouteSchema = useCallback(
|
||||||
async ({ type }: { type: NocoBaseDesktopRouteType }) => {
|
async ({ type }: { type: NocoBaseDesktopRouteType }) => {
|
||||||
const menuSchemaUid = isMobile ? undefined : uid();
|
|
||||||
const pageSchemaUid = uid();
|
const pageSchemaUid = uid();
|
||||||
const tabSchemaName = uid();
|
const tabSchemaName = uid();
|
||||||
const tabSchemaUid = type === NocoBaseDesktopRouteType.page ? uid() : undefined;
|
const tabSchemaUid = type === NocoBaseDesktopRouteType.page ? uid() : undefined;
|
||||||
@ -1284,7 +1279,7 @@ function useCreateRouteSchema(isMobile: boolean) {
|
|||||||
await insertPageSchema(typeToSchema[type]);
|
await insertPageSchema(typeToSchema[type]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return { menuSchemaUid, pageSchemaUid, tabSchemaUid, tabSchemaName };
|
return { pageSchemaUid, tabSchemaUid, tabSchemaName };
|
||||||
},
|
},
|
||||||
[isMobile, resource, insertPageSchema],
|
[isMobile, resource, insertPageSchema],
|
||||||
);
|
);
|
||||||
|
@ -13,7 +13,7 @@ export function getSchemaUidByRouteId(routeId: number, treeArray: any[], isMobil
|
|||||||
for (const node of treeArray) {
|
for (const node of treeArray) {
|
||||||
if (node.id === routeId) {
|
if (node.id === routeId) {
|
||||||
if (node.type === NocoBaseDesktopRouteType.page) {
|
if (node.type === NocoBaseDesktopRouteType.page) {
|
||||||
return isMobile ? node.schemaUid : node.menuSchemaUid;
|
return node.schemaUid;
|
||||||
}
|
}
|
||||||
return node.schemaUid;
|
return node.schemaUid;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user