Spaces:
Sleeping
Sleeping
朱东升
commited on
Commit
·
3af21c3
1
Parent(s):
621bc72
update5
Browse files
app.py
CHANGED
@@ -405,8 +405,34 @@ with gr.Blocks(title="代码评估服务", theme=gr.themes.Soft()) as demo:
|
|
405 |
status_html = gr.HTML(render_queue_status)
|
406 |
refresh_button = gr.Button("刷新状态")
|
407 |
refresh_button.click(fn=refresh_ui, outputs=status_html)
|
408 |
-
#
|
409 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
|
411 |
with gr.Tab("提交新任务"):
|
412 |
with gr.Row():
|
|
|
405 |
status_html = gr.HTML(render_queue_status)
|
406 |
refresh_button = gr.Button("刷新状态")
|
407 |
refresh_button.click(fn=refresh_ui, outputs=status_html)
|
408 |
+
# 使用JavaScript实现自动刷新,代替不兼容的every参数
|
409 |
+
gr.HTML("""
|
410 |
+
<script>
|
411 |
+
// 使用JavaScript实现自动刷新
|
412 |
+
function setupAutoRefresh() {
|
413 |
+
const refreshInterval = 5000; // 5秒
|
414 |
+
|
415 |
+
// 查找刷新按钮并模拟点击
|
416 |
+
function autoRefresh() {
|
417 |
+
// 获取所有按钮元素
|
418 |
+
const buttons = document.querySelectorAll('button');
|
419 |
+
// 查找刷新状态按钮
|
420 |
+
for (const button of buttons) {
|
421 |
+
if (button.textContent === '刷新状态') {
|
422 |
+
button.click();
|
423 |
+
break;
|
424 |
+
}
|
425 |
+
}
|
426 |
+
}
|
427 |
+
|
428 |
+
// 设置定时器
|
429 |
+
setInterval(autoRefresh, refreshInterval);
|
430 |
+
}
|
431 |
+
|
432 |
+
// 页面加载完成后设置自动刷新
|
433 |
+
window.addEventListener('load', setupAutoRefresh);
|
434 |
+
</script>
|
435 |
+
""")
|
436 |
|
437 |
with gr.Tab("提交新任务"):
|
438 |
with gr.Row():
|