mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-09-28 16:20:56 +08:00
feat(bot): 支持macOS系统浏览器检测 (#2107)
- 使用platform模块替代os模块进行系统检测 - 添加macOS系统下的Chrome和Edge浏览器路径检测 - 改进日志信息为中文提示 - 优化跨平台浏览器通道选择逻辑
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user