fix: monitor_web 用 webbrowser.open 替代 cmd.exe 实现跨平台开浏览器 (#70)

之前 main() 启动 HTTP server 后用 `os.system('cmd.exe /c start <url>')`
自动开浏览器, 这条命令在非 Windows 平台 cmd.exe 不存在, os.system 返回
非零退出码 (不抛异常, 外层 except 抓不到), 调用静默失败 → 自动开浏览器
功能在 Linux / macOS 完全失效; 同时 shell 会把 `cmd.exe: command not found`
写到终端 stderr 干扰用户.

改用 Python 标准库 webbrowser.open(), 跨平台自动选默认浏览器, 无新增依赖.
This commit is contained in:
Belugary
2026-05-05 22:47:39 +08:00
committed by GitHub
parent e8de1249a4
commit ec921dd897

View File

@@ -2096,7 +2096,8 @@ def main():
print("Ctrl+C 停止\n", flush=True) print("Ctrl+C 停止\n", flush=True)
try: try:
os.system(f'cmd.exe /c start http://localhost:{PORT}') import webbrowser
webbrowser.open(f'http://localhost:{PORT}')
except Exception: except Exception:
pass pass