feat: add support for exit, refresh, and newline handling in the menu input loop

This commit is contained in:
baoweise
2026-05-28 23:11:16 +08:00
parent 93c1b831e0
commit 883c7c18ee
+12
View File
@@ -735,17 +735,29 @@ def main():
try:
key = getch()
except KeyboardInterrupt:
print()
break
if key == '\x03':
print()
break
# '0' 键默认退出终端,并打印换行符以保持 Shell 提示符整洁
if key == '0':
print()
break
# 回车键 (\r 或 \n) 用于手动刷新当前菜单与连接状态
if key in ('\r', '\n', '\x0a', '\x0d'):
pass
# Reset last_state to force redraw after any key input
last_state = None
if key in options:
name, func = options[key]
if func is None:
print()
break
print("\033[H\033[J", end="")
print(f"正在执行: {name}...\n")