Spaces:
Sleeping
Sleeping
朱东升
commited on
Commit
·
741b8a0
1
Parent(s):
1bac4cd
update10
Browse files
app.py
CHANGED
@@ -391,13 +391,6 @@ def refresh_ui():
|
|
391 |
"""定期刷新UI函数"""
|
392 |
return render_queue_status()
|
393 |
|
394 |
-
def check_for_updates():
|
395 |
-
"""检查是否有UI更新请求"""
|
396 |
-
if update_event.is_set():
|
397 |
-
update_event.clear()
|
398 |
-
return render_queue_status()
|
399 |
-
return gr.update()
|
400 |
-
|
401 |
def submit_json_data(json_data):
|
402 |
"""提交JSON数据处理接口"""
|
403 |
try:
|
@@ -429,14 +422,16 @@ with gr.Blocks(title="代码评估服务", theme=gr.themes.Soft()) as demo:
|
|
429 |
|
430 |
# 使用正确的轮询方式替代
|
431 |
dummy_input = gr.Textbox(value="", visible=False)
|
432 |
-
dummy_input.change(fn=check_for_updates, inputs=dummy_input, outputs=status_html, every=1)
|
433 |
|
434 |
-
# JavaScript
|
|
|
|
|
|
|
435 |
gr.HTML("""
|
436 |
<script>
|
437 |
-
// 使用JavaScript
|
438 |
function setupAutoRefresh() {
|
439 |
-
const refreshInterval =
|
440 |
|
441 |
// 查找刷新按钮并模拟点击
|
442 |
function autoRefresh() {
|
|
|
391 |
"""定期刷新UI函数"""
|
392 |
return render_queue_status()
|
393 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
394 |
def submit_json_data(json_data):
|
395 |
"""提交JSON数据处理接口"""
|
396 |
try:
|
|
|
422 |
|
423 |
# 使用正确的轮询方式替代
|
424 |
dummy_input = gr.Textbox(value="", visible=False)
|
|
|
425 |
|
426 |
+
# We'll rely on the JavaScript solution below for auto-refresh
|
427 |
+
# The refresh button still works for manual refresh
|
428 |
+
|
429 |
+
# JavaScript-based auto-refresh solution
|
430 |
gr.HTML("""
|
431 |
<script>
|
432 |
+
// 使用JavaScript作为自动刷新机制
|
433 |
function setupAutoRefresh() {
|
434 |
+
const refreshInterval = 2000; // 2秒刷新一次
|
435 |
|
436 |
// 查找刷新按钮并模拟点击
|
437 |
function autoRefresh() {
|