Skip to content

Commit 5390d0c

Browse files
committed
调整String对象的toString方式;添加不合理字段内容的背景颜色提醒;基本测试通过
1 parent 920c9be commit 5390d0c

File tree

3 files changed

+14
-96
lines changed

3 files changed

+14
-96
lines changed

formater.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,24 @@ def change_text(com_box, current_text):
7575
com_box.setCurrentText('List<%s>' % current_text)
7676

7777

78+
def change_background_color(com_box, current_text):
79+
if current_text == '':
80+
com_box.setStyleSheet("background-color:rgb(220,20,60)")
81+
elif current_text == 'Object':
82+
com_box.setStyleSheet("background-color:rgb(255,246,143)")
83+
else:
84+
com_box.setStyleSheet("")
85+
86+
7887
# 生成字段类型下拉框
7988
def get_type_combobox(line):
8089
com_box = QtWidgets.QComboBox()
8190
com_box.setEditable(True)
8291
obj_type = int(line[-1]) if line[-1].isdigit() else 0
8392
global last_list_com_box
8493

94+
com_box.currentTextChanged.connect(partial(change_background_color, com_box))
95+
8596
if last_list_com_box is not None:
8697
com_box.currentTextChanged.connect(partial(change_text, last_list_com_box))
8798
last_list_com_box = None
@@ -102,6 +113,8 @@ def get_type_combobox(line):
102113
# 将该list字段的编辑框临时保存,用于与下一个字段的类型绑定
103114
last_list_com_box = com_box
104115

116+
# 为text至不合法的输入框设置颜色
117+
change_background_color(com_box, com_box.currentText())
105118
return com_box
106119

107120

template.dart

Lines changed: 0 additions & 95 deletions
This file was deleted.

tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def add_param_to_code(code, param):
120120
tcode = check_level_type(t)
121121

122122
if tcode == 2:
123-
code = code.replace(': $%s' % n, ': ${%s != null?\'\"$%s\"\':\'null\'}' % (n, n))
123+
code = code.replace(': $%s' % n, ': ${%s != null?\'${JSON.encode(%s)}\':\'null\'}' % (n, n))
124124

125125
# dict类型处理,只需要修改construction中的输出方式
126126
elif tcode == 4:

0 commit comments

Comments
 (0)