品牌标识与握手诊断
- 向导开场:像素字符画 Logo(❯_ 提示符,青绿+光标绿)+ 版本/平台/配置信息 + 横线 - 运行面板头部加 ❯_ 标识;连接中状态改为 ◐◓◑◒ 旋转动画 - SSH banner 错误改为可读诊断文案;握手超时 12→25s;重连日志带尝试次数
This commit is contained in:
@@ -69,6 +69,32 @@ def warn(s: str) -> str: return _c(s, AMBER)
|
||||
def bold(s: str) -> str: return _c(s, TEXT, bold=True)
|
||||
|
||||
|
||||
# ---------- 品牌标识:像素字符画 "❯_"(终端提示符) ----------
|
||||
|
||||
_LOGO_ROWS = [
|
||||
"█.........",
|
||||
"██........",
|
||||
"█.█.......",
|
||||
"██........",
|
||||
"█...██████",
|
||||
]
|
||||
_CURSOR_FROM = 4 # 第 4 列起是"光标下划线",用绿色
|
||||
|
||||
|
||||
def logo_lines() -> list:
|
||||
"""5 行着色 logo;无色模式输出单色块画。"""
|
||||
out = []
|
||||
for row in _LOGO_ROWS:
|
||||
line = ""
|
||||
for i, ch in enumerate(row):
|
||||
if ch == "█":
|
||||
line += _c("█", GREEN if i >= _CURSOR_FROM else ACCENT)
|
||||
else:
|
||||
line += " "
|
||||
out.append(line)
|
||||
return out
|
||||
|
||||
|
||||
# ---------- 显示宽度(CJK 全角按 2 列) ----------
|
||||
|
||||
_WIDE = ((0x1100, 0x115F), (0x2E80, 0x303E), (0x3041, 0x33FF), (0x3400, 0x4DBF),
|
||||
@@ -225,6 +251,9 @@ _STATUS_STYLE = {
|
||||
}
|
||||
|
||||
|
||||
_SPIN = "◐◓◑◒" # 连接中旋转帧,按时间取模
|
||||
|
||||
|
||||
class Dashboard:
|
||||
"""运行时面板:隧道状态 + 滚动日志,原地刷新。非 tty 时为空操作。"""
|
||||
|
||||
@@ -256,16 +285,20 @@ class Dashboard:
|
||||
if not self._on:
|
||||
return
|
||||
lines = []
|
||||
head = " ssh-e2e · 隧道运行中 "
|
||||
head = " ❯_ ssh-e2e · 隧道运行中 "
|
||||
lines.append(accent("─" + head) + faint("─" * max(0, 46 - disp_len(head))))
|
||||
for st in self._stats:
|
||||
rgb, label = _STATUS_STYLE.get(st["status"], (FAINT, "○ 未知"))
|
||||
dot = _c(label.split()[0], rgb)
|
||||
text = " ".join(label.split()[1:])
|
||||
if st["status"] == "connecting":
|
||||
glyph = _SPIN[int(time.time() * 2) % len(_SPIN)]
|
||||
dot, text = _c(glyph, AMBER), "连接中"
|
||||
else:
|
||||
rgb, label = _STATUS_STYLE.get(st["status"], (FAINT, "○ 未知"))
|
||||
dot = _c(label.split()[0], rgb)
|
||||
text = " ".join(label.split()[1:])
|
||||
lines.append(f" {dot} {bold(st['name'])}")
|
||||
m = f"{dim('127.0.0.1:' + str(st['local_port']))} {accent('⇄')} {dim(st['remote'])}"
|
||||
uptime = fmt_up(time.time() - st["started_at"]) if st.get("started_at") else "--:--:--"
|
||||
lines.append(f" {m} {_c(text, rgb)} · {faint(uptime)} · {faint('连接 ' + str(st.get('conns', 0)))}")
|
||||
lines.append(f" {m} {_c(text, AMBER if st['status'] == 'connecting' else _STATUS_STYLE[st['status']][0])} · {faint(uptime)} · {faint('连接 ' + str(st.get('conns', 0)))}")
|
||||
if st.get("error"):
|
||||
lines.append(f" {err(st['error'])}")
|
||||
if self._logs:
|
||||
|
||||
Reference in New Issue
Block a user