fix: defineRouteMeta parse 异常

This commit is contained in:
winixt 2022-10-10 16:25:07 +08:00
parent ec1cf5b427
commit f6c884eca0

View File

@ -77,7 +77,9 @@ function getRouteMeta(content) {
const defineRouteExpression = ast.program.body.filter(expression => expression.type === 'ExpressionStatement' && expression.expression.type === 'CallExpression' && expression.expression.callee.name === 'defineRouteMeta')[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();
}
return null;
} catch (error) {