2026-05-31 09:36:07 +08:00
|
|
|
// @ts-nocheck
|
|
|
|
|
// This file is generated by Umi automatically
|
|
|
|
|
// DO NOT CHANGE IT MANUALLY!
|
2026-06-01 17:07:08 +08:00
|
|
|
import { warning } from '/Users/donghym/Desktop/day/UI/Pika/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/Pika/node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge';
|
2026-05-31 09:36:07 +08:00
|
|
|
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', []);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|