clash_local.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. from nicegui import ui
  2. # 全局变量声明
  3. output_text = None
  4. def handle_check_now_node():
  5. """处理 'check now node' 按钮点击事件"""
  6. global output_text
  7. print("Check Now Node button clicked")
  8. # 模拟检测结果
  9. results = [
  10. "Node 1: OK",
  11. "Node 2: Failed",
  12. "Node 3: OK",
  13. "Node 4: OK",
  14. "Node 5: Failed",
  15. "Node 6: OK",
  16. "Node 7: OK",
  17. "Node 8: Failed",
  18. "Node 9: OK",
  19. "Node 10: OK"
  20. ]
  21. # 更新文本框内容
  22. if output_text is not None:
  23. output_text.value = "\n".join(results)
  24. else:
  25. print("Error: output_text is not initialized")
  26. def handle_switch_node():
  27. """处理 'switch ip' 按钮点击事件"""
  28. print("Switch IP button clicked")
  29. @ui.page('/clash_local')
  30. def run_clash_local():
  31. ui.button('返回主页', on_click=lambda: ui.navigate.to('/', new_tab=False))
  32. with ui.row().classes("mx-auto"):
  33. ui.button("Check Now Node", on_click=handle_check_now_node).classes("mt-1")
  34. ui.button("Switch Node", on_click=handle_switch_node).classes("mt-1")
  35. ui.label("Filter Node").classes("text-lg font-bold text-blue-500 mt-4")
  36. filter_input = ui.input(value="JP").classes("w-96")
  37. with ui.row().classes("w-4/5 mx-auto"):
  38. with ui.column().classes("w-4/5 mx-auto"):
  39. ui.label("Output").classes("text-lg font-bold text-blue-500 mt-8 mb-4")
  40. ui.textarea().classes("w-full h-96 text-sm overflow-auto")