mirror of
https://github.com/baoweise-bot/aimili-vpngate.git
synced 2026-09-09 01:36:52 +08:00
feat: add support for exit, refresh, and newline handling in the menu input loop
This commit is contained in:
+12
@@ -735,17 +735,29 @@ def main():
|
|||||||
try:
|
try:
|
||||||
key = getch()
|
key = getch()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
print()
|
||||||
break
|
break
|
||||||
|
|
||||||
if key == '\x03':
|
if key == '\x03':
|
||||||
|
print()
|
||||||
break
|
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
|
# Reset last_state to force redraw after any key input
|
||||||
last_state = None
|
last_state = None
|
||||||
|
|
||||||
if key in options:
|
if key in options:
|
||||||
name, func = options[key]
|
name, func = options[key]
|
||||||
if func is None:
|
if func is None:
|
||||||
|
print()
|
||||||
break
|
break
|
||||||
print("\033[H\033[J", end="")
|
print("\033[H\033[J", end="")
|
||||||
print(f"正在执行: {name}...\n")
|
print(f"正在执行: {name}...\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user