fix: config 不是 json 格式导致 dev 退出

This commit is contained in:
winixt 2022-10-10 16:39:48 +08:00
parent f6c884eca0
commit 9137ffc61c

View File

@ -125,7 +125,11 @@ const genRoutes = function (parentRoutes, path, parentRoutePath) {
const routeMetaBlock = descriptor.customBlocks.find(
b => b.type === 'config'
);
try {
routeMeta = routeMetaBlock?.content ? JSON.parse(routeMetaBlock.content) : {};
} catch (e) {
console.warn(`config: ${routeMetaBlock.content} 必须为 json 格式`);
}
if (descriptor.script) {
routeMeta = getRouteMeta(descriptor.script.content) || routeMeta;
}