Skip to content

Commit 3570654

Browse files
committed
fix: review
1 parent 641be77 commit 3570654

16 files changed

Lines changed: 275 additions & 69 deletions

File tree

.agents/skills/tinyengine-dsl-generator/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ Page file structure (wrapper):
603603
{
604604
"name": "PageName",
605605
"id": "unique-id",
606-
"app": "1",
606+
"app": 1,
607607
"route": "page-route",
608608
"page_content": {
609609
/* actual page DSL with componentName: "Page" */

.agents/skills/tinyengine-dsl-generator/scripts/check_css.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def _check_css(self, css: str) -> bool:
136136
return len(self.errors) == 0
137137

138138
except Exception as e:
139-
self.errors.append(f"Failed to parse CSS: {e}")
139+
self.errors.append(f"CSS check failed unexpectedly: {e}")
140140
return False
141141

142142

@@ -201,7 +201,10 @@ def _check_css(self, css: str) -> bool:
201201
import os
202202
try:
203203
os.unlink(temp_file)
204-
except:
204+
except OSError:
205+
# FileNotFoundError (subclass of OSError) is expected if the temp
206+
# file was never created or already removed; other OS-level
207+
# cleanup failures are non-fatal here.
205208
pass
206209

207210

.agents/skills/tinyengine-dsl-generator/scripts/check_event_bindings.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,17 @@ def _check_node(self, node: Any) -> None:
4343
self._check_node(item)
4444

4545
def _check_event_bindings(self, node: Dict[str, Any]) -> None:
46-
"""检查单个节点的事件绑定"""
46+
"""检查单个节点的事件绑定(含 props 内的事件绑定)"""
4747
component = node.get('componentName', 'unknown')
4848

49+
# 两处都需要校验,避免漏检 props 内的事件。
50+
self._check_event_holder(node, component)
51+
props = node.get('props')
52+
if isinstance(props, dict):
53+
self._check_event_holder(props, component)
54+
55+
def _check_event_holder(self, holder: Dict[str, Any], component: str) -> None:
56+
"""检查某个属性容器(节点本身或其 props)内的事件绑定"""
4957
# 检查所有可能的事件属性
5058
event_keys = [
5159
'onClick', 'onChange', 'onKeyup', 'onKeyDown', 'onKeyPress',
@@ -55,13 +63,13 @@ def _check_event_bindings(self, node: Dict[str, Any]) -> None:
5563
]
5664

5765
for key in event_keys:
58-
if key in node:
59-
value = node[key]
66+
if key in holder:
67+
value = holder[key]
6068
if isinstance(value, dict):
6169
self._check_event_value(component, key, value)
6270

6371
# 也检查以'on'开头的属性
64-
for key, value in node.items():
72+
for key, value in holder.items():
6573
if key.startswith('on') and key not in event_keys:
6674
if isinstance(value, dict):
6775
self._check_event_value(component, key, value)

.agents/skills/tinyengine-dsl-generator/scripts/validate_page.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,13 @@ def check_class_name_usage(file_path: str) -> bool:
9595
try:
9696
with open(file_path, 'r', encoding='utf-8') as f:
9797
data = json.load(f)
98-
except:
99-
return True # JSON 错误会在其他检查中捕获
98+
except (json.JSONDecodeError, OSError):
99+
# JSON 语法错误或文件读取问题(FileNotFoundError 属于 OSError)由其他
100+
# 检查负责报告;此处不掩盖其他意外运行错误。
101+
return True
102+
except Exception as e:
103+
print(f"❌ className 检查异常: {e}")
104+
return False
100105

101106
page_content = data.get('page_content', {})
102107
errors = []

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ pnpm-debug.log*
2828
*.sw?
2929
tmp
3030
temp
31+
__pycache__

mockServer/data/appsSchema/16.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@
863863
"componentName": "Text",
864864
"props": {
865865
"text": "温馨提示:页面左上角切换区域",
866-
"style": "background-color: [object Event]; color: #8a8e99; font-size: 12px;"
866+
"style": "background-color: #f5f5f5; color: #8a8e99; font-size: 12px;"
867867
},
868868
"id": "20923497"
869869
},
@@ -1700,10 +1700,10 @@
17001700
"occupier": {
17011701
"id": 86,
17021702
"username": "开发者",
1703-
"email": "developer@lowcode_com",
1703+
"email": "demo@example.com",
17041704
"provider": null,
17051705
"password": null,
1706-
"confirmationToken": "dfb2c162-351f-4f44-ad5f-899831311129",
1706+
"confirmationToken": null,
17071707
"confirmed": true,
17081708
"blocked": null,
17091709
"role": null,

mockServer/data/pages/CreateVm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
"componentName": "Text",
117117
"props": {
118118
"text": "温馨提示:页面左上角切换区域",
119-
"style": "background-color: [object Event]; color: #8a8e99; font-size: 12px;"
119+
"style": "background-color: #f5f5f5; color: #8a8e99; font-size: 12px;"
120120
},
121121
"id": "20923497"
122122
},

mockServer/scripts/export-db-to-file.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const forceOverwrite = process.argv.includes('--force')
1010
const collectionNamingFields = {
1111
pages: ['name'],
1212
apps: ['name'],
13+
appsSchema: ['id'],
1314
blocks: ['label', 'name'],
1415
blockGroups: ['name'],
1516
blockCategories: ['name']

mockServer/src/services/apps.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default class AppsService {
8585
id: mockId++,
8686
...params
8787
}
88-
this.store.insert(newApp)
88+
await this.store.insert(newApp)
8989

9090
let resultStr = JSON.stringify(defaultAppSchema.data)
9191
resultStr = resultStr.replace(/"lowcode./g, '"lowcode_')
@@ -102,7 +102,19 @@ export default class AppsService {
102102
},
103103
id: newApp.id
104104
}
105-
this.schemaStore.insert(newAppSchema)
105+
// App and schema live in different collections. If the schema write fails,
106+
// best-effort roll back the app insert so we don't leave a one-sided record,
107+
// then rethrow — ErrorRoutesCatch serializes thrown errors into the response.
108+
try {
109+
await this.schemaStore.insert(newAppSchema)
110+
} catch (err) {
111+
try {
112+
await this.store.remove({ id: newApp.id })
113+
} catch {
114+
/* swallow cleanup failure; surface the original error below */
115+
}
116+
throw err
117+
}
106118
return getResponseData(newApp)
107119
}
108120

mockServer/src/services/block.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export default class BlockService {
2222
this.userInfo = {
2323
id: 86,
2424
username: '开发者',
25-
email: 'developer@lowcode.com',
26-
confirmationToken: 'dfb2c162-351f-4f44-ad5f-8998',
25+
email: 'demo@example.com',
26+
confirmationToken: null,
2727
is_admin: true
2828
}
2929

0 commit comments

Comments
 (0)