feat(bot): 支持macOS系统浏览器检测 (#2107)

- 使用platform模块替代os模块进行系统检测
- 添加macOS系统下的Chrome和Edge浏览器路径检测
- 改进日志信息为中文提示
- 优化跨平台浏览器通道选择逻辑
This commit is contained in:
molanp
2026-02-25 10:48:44 +08:00
committed by GitHub
parent d9f8305540
commit 51f4773e14
+19 -6
View File
@@ -1,11 +1,12 @@
import contextlib
import os
import platform
import nonebot
htmlrender_browser_channel = None
system = platform.system()
if os.name == "nt":
if system == "Windows":
import winreg
paths = {
@@ -18,10 +19,22 @@ if os.name == "nt":
htmlrender_browser_channel = name
break
if htmlrender_browser_channel:
nonebot.logger.info(
f"Using {htmlrender_browser_channel} as htmlrender browser channel."
)
elif system == "Darwin": # macOS
from pathlib import Path
mac_paths = {
"chrome": "/Applications/Google Chrome.app",
"msedge": "/Applications/Microsoft Edge.app",
}
for name, path in mac_paths.items():
if Path(path).exists():
htmlrender_browser_channel = name
break
if htmlrender_browser_channel:
nonebot.logger.info(
f"使用 {htmlrender_browser_channel} 作为 htmlrender 驱动启动..."
)
# from nonebot.adapters.discord import Adapter as DiscordAdapter