Skip to content

Commit ce50e3f

Browse files
committed
fix: 修复当 TracebackData.data 为空时,auto_update 不生效的问题
1 parent 2e22356 commit ce50e3f

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

src/MaaDebugger/webpage/traceback_page/__init__.py

+30-30
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class TracebackData:
2020

2121
# display
2222
reverse: bool = True
23-
auto_update: bool = False
23+
auto_update: bool = True
2424

2525

2626
class TracaBackElement(ValueElement):
@@ -57,44 +57,50 @@ def get_data(num: int) -> dict:
5757
return data
5858

5959

60-
def auto_update_page():
60+
def auto_update_list():
6161
if TracebackData.auto_update:
6262
create_traceback_list.refresh()
6363

6464

6565
@ui.refreshable
6666
def create_traceback_list():
67-
for key in sorted(
68-
get_data(TracebackData.max_display), reverse=TracebackData.reverse
69-
):
70-
name, value, _, record_time = TracebackData.data[key]
71-
72-
with (
73-
ui.link(target=f"/traceback/{key}", new_tab=True)
74-
.classes("!no-underline") # Hide the underline
75-
.classes(
76-
"dark: text-black" # In light mode, set the font color to black (it is blue by default due to ui.link)
77-
),
78-
ui.item().classes("w-full"),
67+
if not TracebackData.data:
68+
ui.markdown("### No Tracebacks")
69+
return
70+
71+
with ui.list().props("bordered separator").classes("w-full"):
72+
for key in sorted(
73+
get_data(TracebackData.max_display), reverse=TracebackData.reverse
7974
):
80-
with ui.item_section().props("side"):
81-
ui.item_label(str(key))
82-
with ui.item_section():
83-
ui.item_label(record_time)
84-
with ui.item_section():
85-
ui.item_label(name)
86-
with ui.item_section():
87-
ui.item_label(value)
75+
name, value, _, record_time = TracebackData.data[key]
76+
77+
with (
78+
ui.link(target=f"/traceback/{key}", new_tab=True)
79+
.classes("!no-underline") # Hide the underline
80+
.classes(
81+
"dark: text-black" # In light mode, set the font color to black (it is blue by default due to ui.link)
82+
),
83+
ui.item().classes("w-full"),
84+
):
85+
with ui.item_section().props("side"):
86+
ui.item_label(str(key))
87+
with ui.item_section():
88+
ui.item_label(record_time)
89+
with ui.item_section():
90+
ui.item_label(name)
91+
with ui.item_section():
92+
ui.item_label(value)
8893

8994

9095
@ui.page("/traceback")
9196
def creata_all_traceback_page():
9297
TracaBackElement(value=None).bind_value_from(TracebackData, "id").on_value_change(
93-
auto_update_page
98+
auto_update_list
9499
)
95100

96101
ui.page_title("Tracebacks")
97102
ui.markdown("## Tracebacks")
103+
98104
with ui.row(align_items="center").classes("w-full"):
99105
ui.number("Maximum Results to Show", min=1, precision=0).bind_value(
100106
TracebackData, "max_display"
@@ -103,18 +109,12 @@ def creata_all_traceback_page():
103109
create_traceback_list.refresh
104110
)
105111
ui.switch("Auto Update").bind_value(TracebackData, "auto_update").tooltip(
106-
"When a new exception is recorded, should the page be automatically updated?"
112+
"When a new exception is recorded, should the list be automatically updated"
107113
)
108114
ui.button("Clear Traceback Cache", on_click=clear_traceback_data).props(
109115
"no-caps"
110116
)
111117
ui.separator()
112-
113-
if not TracebackData.data:
114-
ui.markdown("### No Tracebacks")
115-
return
116-
117-
with ui.list().props("bordered separator").classes("w-full"):
118118
create_traceback_list()
119119

120120

0 commit comments

Comments
 (0)