Skip to content

Commit 48bc8d7

Browse files
LeoYuanliujuping
authored andcommitted
fix: compatible with {} in template literals
1 parent 122f0b3 commit 48bc8d7

File tree

68 files changed

+85
-84
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+85
-84
lines changed

docs/docs/guide/expand/runtime/codeGeneration.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ sidebar_position: 1
2323
## 如何使用
2424
### 1) 通过命令行快速体验
2525

26-
欢迎使用命令行工具快速体验:`npx @alilc/lowcode-code-generator -i example-schema.json -o generated -s icejs`
26+
欢迎使用命令行工具快速体验:`npx @alilc/lowcode-code-generator -i example-schema.json -o generated -s icejs3`
2727

28-
--其中 example-schema.json 可以从[这里下载](https://unpkg.com/@alilc/lowcode-code-generator@beta/example-schema.json)
28+
--其中 example-schema.json 可以从[这里下载](https://alifd.alicdn.com/npm/@alilc/lowcode-code-generator@latest/example-schema.json)
2929

3030
### 2) 通过设计器插件快速体验
3131

@@ -112,7 +112,7 @@ await CodeGenerator.init();
112112

113113
```javascript
114114
const result = await CodeGenerator.generateCode({
115-
solution: 'icejs', // 出码方案 (目前内置有 icejs 和 rax )
115+
solution: 'icejs', // 出码方案 (目前内置有 icejs、icejs3 和 rax )
116116
schema, // 编排搭建出来的 schema
117117
});
118118

@@ -124,6 +124,7 @@ console.log(result); // 出码结果 (默认是递归结构描述的,可以传
124124
### 5)自定义出码
125125
前端框架灵活多变,默认内置的出码方案很难满足所有人的需求,好在此代码生成器支持非常灵活的插件机制 -- 内置功能大多都是通过插件完成的(在 `src/plugins`下),比如:
126126
![image.png](https://img.alicdn.com/imgextra/i1/O1CN01CEl2Hq1omnH0UCyGF_!!6000000005268-2-tps-457-376.png)
127+
127128
所以您可以通过添加自己的插件或替换掉默认内置的插件来实现您的自定义功能。
128129
为了方便自定义出码方案,出码模块还提供自定义出码方案的脚手架功能,即执行下面脚本即可生成一个自定义出码方案:
129130
```shell

docs/docs/specs/lowcode-spec.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,11 +1370,11 @@ export const recordEvent = function(logkey, gmkey, gokey, reqMethod) {
13701370
"i18n": {
13711371
"zh-CN": {
13721372
"i18n-hello": "你好",
1373-
"i18n-chicken": "我有${count}只鸡"
1373+
"i18n-chicken": "我有{count}只鸡"
13741374
},
13751375
"en-US": {
13761376
"i18n-hello": "Hello",
1377-
"i18n-chicken": "I have ${count} chicken"
1377+
"i18n-chicken": "I have {count} chicken"
13781378
}
13791379
}
13801380
}

modules/code-generator/example-schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"lifeCycles": {
7373
"componentDidMount": {
7474
"type": "JSFunction",
75-
"value": "function() { console.log('componentDidMount'); }"
75+
"value": "function componentDidMount() { console.log('componentDidMount'); }"
7676
}
7777
},
7878
"dataSource": {

modules/code-generator/example-schema.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
lifeCycles: {
7373
componentDidMount: {
7474
type: 'JSFunction',
75-
value: "function() { console.log('componentDidMount'); }",
75+
value: "function componentDidMount() { console.log('componentDidMount'); }",
7676
},
7777
},
7878
dataSource: {

modules/code-generator/src/plugins/project/framework/icejs3/plugins/buildConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default defineConfig(() => ({
103103
importStyle: 'sass',
104104
themePackage: '${getThemeInfo(cfg.themePackage).name}',
105105
}` : `{
106-
importStyle: true,
106+
importStyle: 'sass',
107107
}`}),
108108
locales(),
109109
plugin(),

modules/code-generator/src/plugins/project/framework/icejs3/template/files/src/layouts/BasicLayout/components/Logo/index.style.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ export default function getFile(): [string[], ResultFile] {
1010
display: flex;
1111
align-items: center;
1212
justify-content: center;
13-
color: $color-text1-1;
13+
color: #FF7300;
1414
font-weight: bold;
1515
font-size: 14px;
1616
line-height: 22px;
1717
1818
&:visited, &:link {
19-
color: $color-text1-1;
19+
color: #FF7300;
2020
}
2121
2222
img {

modules/code-generator/src/plugins/project/i18n.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
4141
// 按低代码规范里面的要求进行变量替换
4242
const format = (msg, variables) => (
4343
typeof msg === 'string'
44-
? msg.replace(/\\\$\\{(\\w+)\\}/g, (match, key) => variables?.[key] ?? '')
44+
? msg.replace(/\\\$?\\{(\\w+)\\}/g, (match, key) => variables?.[key] ?? '')
4545
: msg
4646
);
4747

modules/code-generator/tests/fixtures/test-cases/icejs3-app/demo1/expected/demo-project/ice.config.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default defineConfig(() => ({
8181
},
8282
plugins: [
8383
fusion({
84-
importStyle: true,
84+
importStyle: 'sass',
8585
}),
8686
locales(),
8787
plugin(),

modules/code-generator/tests/fixtures/test-cases/icejs3-app/demo1/expected/demo-project/src/i18n.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const isEmptyVariables = (variables) =>
1919
// 按低代码规范里面的要求进行变量替换
2020
const format = (msg, variables) =>
2121
typeof msg === 'string'
22-
? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? '')
22+
? msg.replace(/\$?\{(\w+)\}/g, (match, key) => variables?.[key] ?? '')
2323
: msg;
2424

2525
const i18nFormat = ({ id, defaultMessage, fallback }, variables) => {

modules/code-generator/tests/fixtures/test-cases/icejs3-app/demo1/expected/demo-project/src/layouts/BasicLayout/components/Logo/index.module.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
display: flex;
44
align-items: center;
55
justify-content: center;
6-
color: $color-text1-1;
6+
color: #FF7300;
77
font-weight: bold;
88
font-size: 14px;
99
line-height: 22px;
1010

1111
&:visited, &:link {
12-
color: $color-text1-1;
12+
color: #FF7300;
1313
}
1414

1515
img {

0 commit comments

Comments
 (0)