diff --git a/apps/playground/src/helpers/mail-files.ts b/apps/playground/src/helpers/mail-files.ts
index 0b9271d..01cc915 100644
--- a/apps/playground/src/helpers/mail-files.ts
+++ b/apps/playground/src/helpers/mail-files.ts
@@ -2,7 +2,7 @@ const packageJson = {
name: 'demo',
private: true,
dependencies: {
- '@music163/tango-mail': '0.1.1',
+ '@music163/tango-mail': '0.2.4',
'@music163/tango-boot': '0.2.5',
react: '17.0.2',
'react-dom': '17.0.2',
@@ -44,7 +44,7 @@ const tangoConfigJson = {
},
'@music163/tango-mail': {
description: 'TangoMail 基础物料',
- version: '0.1.1',
+ version: '0.2.4',
library: 'TangoMail',
type: 'baseDependency',
resources: ['https://unpkg.com/@music163/tango-mail@{{version}}/dist/index.js'],
@@ -116,7 +116,6 @@ const WelcomeEmail = () => (
Best,
-
The Koala team
diff --git a/packages/core/src/helpers/ast/parse.ts b/packages/core/src/helpers/ast/parse.ts
index 5955b64..02ec0ad 100644
--- a/packages/core/src/helpers/ast/parse.ts
+++ b/packages/core/src/helpers/ast/parse.ts
@@ -222,15 +222,16 @@ export function value2jsxAttributeValueNode(value: any) {
return ret;
}
-// TODO: 待校验
export function value2jsxChildrenValueNode(value: any) {
let ret: t.JSXElement | t.JSXFragment | t.JSXExpressionContainer | t.JSXSpreadChild | t.JSXText;
switch (typeof value) {
case 'string':
- if (isValidExpressionCode(value)) {
+ if (isWrappedCode(value)) {
+ // 代码模式
const innerString = getVariableContent(value);
ret = t.jsxExpressionContainer(code2expression(innerString));
} else {
+ // 普通的文本
ret = t.jsxText(value);
}
break;
diff --git a/packages/core/src/helpers/ast/traverse.ts b/packages/core/src/helpers/ast/traverse.ts
index 37c010f..8eaadc3 100644
--- a/packages/core/src/helpers/ast/traverse.ts
+++ b/packages/core/src/helpers/ast/traverse.ts
@@ -391,8 +391,10 @@ export function updateJSXElementAttribute(node: t.JSXElement, attrName: string,
isExist = true;
// @ts-ignore
if (t.isJSXAttribute(jsxAttributeNode)) {
+ // 更新 jsx 属性值 的模式
jsxAttributeNode.value = value2jsxAttributeValueNode(attrValue);
} else if (name === 'children') {
+ // 更新 jsx children 的情况 children
node.children = value2jsxChildrenValueNode(attrValue);
}
}