From b8878c3c24b473c4d930880f10f24866f9a55871 Mon Sep 17 00:00:00 2001 From: winixt Date: Mon, 10 Oct 2022 16:23:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20defineRouteMeta=20parse=20=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= 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 | 4 +++- packages/fes-template-vite/src/pages/index.vue | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) 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 86d7b0fc..11700a53 100644 --- a/packages/fes-preset-built-in/src/plugins/route/index.js +++ b/packages/fes-preset-built-in/src/plugins/route/index.js @@ -71,7 +71,9 @@ function getRouteMeta(content) { )[0]; if (defineRouteExpression) { const argument = generator(defineRouteExpression.expression.arguments[0]); - return JSON.parse(argument.code.replace(/'/g, '"').replace(/(\S+):/g, (global, m1) => `"${m1}":`)); + // eslint-disable-next-line no-eval + const fn = eval(`() => (${argument.code})`); + return fn(); } } catch (err) {} return null; diff --git a/packages/fes-template-vite/src/pages/index.vue b/packages/fes-template-vite/src/pages/index.vue index 30e02cd0..2e1a6646 100644 --- a/packages/fes-template-vite/src/pages/index.vue +++ b/packages/fes-template-vite/src/pages/index.vue @@ -6,10 +6,14 @@ -