Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -46,7 +46,7 @@ def update_activity_display(show_all=False):
|
|
| 46 |
data = data[-5:] # 取最近5条记录
|
| 47 |
rows = []
|
| 48 |
for i, record in enumerate(data):
|
| 49 |
-
rows.append([record["活動"], record["時間"], i]) #
|
| 50 |
return rows
|
| 51 |
|
| 52 |
# 主界面
|
|
@@ -83,7 +83,7 @@ def main_interface():
|
|
| 83 |
|
| 84 |
# 记录显示区域
|
| 85 |
gr.Markdown("### 📋 最近活動記錄")
|
| 86 |
-
record_table = gr.Dataframe(headers=["活動", "時間", "刪除"], interactive=False,
|
| 87 |
show_more_btn = gr.Button("顯示更多記錄")
|
| 88 |
show_less_btn = gr.Button("顯示最近5條", visible=False)
|
| 89 |
|
|
@@ -92,7 +92,7 @@ def main_interface():
|
|
| 92 |
records = update_activity_display(show_all=show_all)
|
| 93 |
return records, gr.update(visible=not show_all), gr.update(visible=show_all)
|
| 94 |
|
| 95 |
-
#
|
| 96 |
def delete_record(index):
|
| 97 |
delete_activity(index)
|
| 98 |
return refresh_records()
|
|
@@ -107,11 +107,6 @@ def main_interface():
|
|
| 107 |
show_more_btn.click(lambda: refresh_records(show_all=True), outputs=[record_table, show_more_btn, show_less_btn])
|
| 108 |
show_less_btn.click(lambda: refresh_records(show_all=False), outputs=[record_table, show_more_btn, show_less_btn])
|
| 109 |
|
| 110 |
-
# 删除记录按钮
|
| 111 |
-
def on_delete(index):
|
| 112 |
-
delete_activity(index)
|
| 113 |
-
return refresh_records()
|
| 114 |
-
|
| 115 |
# 初始化加载记录
|
| 116 |
app.load(lambda: refresh_records(), outputs=[record_table, show_more_btn, show_less_btn])
|
| 117 |
|
|
|
|
| 46 |
data = data[-5:] # 取最近5条记录
|
| 47 |
rows = []
|
| 48 |
for i, record in enumerate(data):
|
| 49 |
+
rows.append([record["活動"], record["時間"], i]) # 添加索引用于删除
|
| 50 |
return rows
|
| 51 |
|
| 52 |
# 主界面
|
|
|
|
| 83 |
|
| 84 |
# 记录显示区域
|
| 85 |
gr.Markdown("### 📋 最近活動記錄")
|
| 86 |
+
record_table = gr.Dataframe(headers=["活動", "時間", "刪除"], interactive=False, row_count=5)
|
| 87 |
show_more_btn = gr.Button("顯示更多記錄")
|
| 88 |
show_less_btn = gr.Button("顯示最近5條", visible=False)
|
| 89 |
|
|
|
|
| 92 |
records = update_activity_display(show_all=show_all)
|
| 93 |
return records, gr.update(visible=not show_all), gr.update(visible=show_all)
|
| 94 |
|
| 95 |
+
# 删除记录按钮
|
| 96 |
def delete_record(index):
|
| 97 |
delete_activity(index)
|
| 98 |
return refresh_records()
|
|
|
|
| 107 |
show_more_btn.click(lambda: refresh_records(show_all=True), outputs=[record_table, show_more_btn, show_less_btn])
|
| 108 |
show_less_btn.click(lambda: refresh_records(show_all=False), outputs=[record_table, show_more_btn, show_less_btn])
|
| 109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
# 初始化加载记录
|
| 111 |
app.load(lambda: refresh_records(), outputs=[record_table, show_more_btn, show_less_btn])
|
| 112 |
|