From b2278171599c3d692a0b0b136de8e58207dc47da Mon Sep 17 00:00:00 2001 From: winixt Date: Mon, 10 Oct 2022 16:42:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20config=20=E4=B8=8D=E6=98=AF=20json=20?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=AF=BC=E8=87=B4=20dev=20=E9=80=80=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fes-preset-built-in/src/plugins/route/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/fes-preset-built-in/src/plugins/route/index.js b/packages/fes-preset-built-in/src/plugins/route/index.js index 11700a53..01d906fa 100644 --- a/packages/fes-preset-built-in/src/plugins/route/index.js +++ b/packages/fes-preset-built-in/src/plugins/route/index.js @@ -117,7 +117,11 @@ const genRoutes = function (parentRoutes, path, parentRoutePath) { if (ext === '.vue') { const { descriptor } = parse(content); const routeMetaBlock = descriptor.customBlocks.find((b) => b.type === 'config'); - routeMeta = routeMetaBlock?.content ? JSON.parse(routeMetaBlock.content) : {}; + 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; }