feat:组件框架
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
// @ts-nocheck
|
||||
// This file is generated by Umi automatically
|
||||
// DO NOT CHANGE IT MANUALLY!
|
||||
import { warning } from '/Users/donghym/Desktop/day/UI/Nova/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.2.6_react@19.2.6__react@19.2.6/node_modules/rc-util';
|
||||
import deepmerge from '/Users/donghym/Desktop/day/UI/Nova/node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge';
|
||||
import { getRouteMetaById } from './exports';
|
||||
|
||||
// Proxy do not warning since `Object.keys` will get nothing to loop
|
||||
function wrapEmpty(meta, fieldName, defaultValue) {
|
||||
Object.defineProperty(meta, fieldName, {
|
||||
get: () => {
|
||||
warning(false, `'${fieldName}' return empty in latest version, please use \`useRouteMeta\` instead.`);
|
||||
return defaultValue;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export const patchRoutes = ({ routes }) => {
|
||||
Object.values(routes).forEach((route) => {
|
||||
const routeMeta = getRouteMetaById(route.id, { syncOnly: true });
|
||||
|
||||
if (routeMeta) {
|
||||
if (process.env.NODE_ENV === 'production' && (route.meta?.frontmatter?.debug || routeMeta.frontmatter?.debug)) {
|
||||
// hide route in production which set hide frontmatter
|
||||
delete routes[route.id];
|
||||
} else {
|
||||
// merge meta to route object
|
||||
route.meta = deepmerge(route.meta, routeMeta);
|
||||
|
||||
wrapEmpty(route.meta, 'toc', []);
|
||||
wrapEmpty(route.meta, 'texts', []);
|
||||
|
||||
route.meta.tabs?.forEach((tab) => {
|
||||
wrapEmpty(tab, 'toc', []);
|
||||
wrapEmpty(tab, 'texts', []);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user