Skip to content

Commit 1c63a49

Browse files
committed
fix: 优化信息栏显示逻辑,确保消息内容正确转换为字符串
1 parent 4b6cf80 commit 1c63a49

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

app/view/main_window.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,44 +330,45 @@ def prevConfig(self):
330330

331331
def show_info_bar(self, data_dict: dict):
332332
"""显示信息栏"""
333-
duration = max(len(data_dict.get("msg", "")) * 100, 2000)
333+
msg = str(data_dict.get("msg", ""))
334+
duration = max(len(msg) * 100, 2000)
334335
if data_dict["status"] in ["failed", "failed_info"]:
335336
InfoBar.error(
336337
title=self.tr("Error"),
337-
content=data_dict.get("msg", ""),
338+
content=msg,
338339
duration=duration,
339340
parent=self,
340341
)
341342
elif data_dict["status"] == "warning":
342343
InfoBar.warning(
343344
title=self.tr("Warning"),
344-
content=data_dict.get("msg", ""),
345+
content=msg,
345346
duration=duration,
346347
parent=self,
347348
)
348349
elif data_dict["status"] in ["success", "no_need"]:
349350
InfoBar.success(
350351
title=self.tr("Success"),
351-
content=data_dict.get("msg", ""),
352+
content=msg,
352353
duration=duration,
353354
parent=self,
354355
)
355356
elif data_dict["status"] == "info":
356357
InfoBar.info(
357358
title=self.tr("Info"),
358-
content=data_dict.get("msg", ""),
359+
content=msg,
359360
duration=duration,
360361
parent=self,
361362
)
362363
elif data_dict["status"] == "error_sp":
363364
if data_dict["type"] == "advanced":
364365
error_msg = (
365366
self.tr("advanced setting [")
366-
+ data_dict.get("msg", [])[0]
367+
+ str(data_dict.get("msg", [])[0])
367368
+ self.tr("] value [")
368-
+ data_dict.get("msg", [])[1]
369+
+ str(data_dict.get("msg", [])[1])
369370
+ self.tr("] not match regex [")
370-
+ data_dict.get("msg", [])[2]
371+
+ str(data_dict.get("msg", [])[2])
371372
+ "]"
372373
)
373374
InfoBar.error(

0 commit comments

Comments
 (0)