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 contextlib
|
||||||
import os
|
import platform
|
||||||
|
|
||||||
import nonebot
|
import nonebot
|
||||||
|
|
||||||
htmlrender_browser_channel = None
|
htmlrender_browser_channel = None
|
||||||
|
system = platform.system()
|
||||||
|
|
||||||
if os.name == "nt":
|
if system == "Windows":
|
||||||
import winreg
|
import winreg
|
||||||
|
|
||||||
paths = {
|
paths = {
|
||||||
@@ -18,10 +19,22 @@ if os.name == "nt":
|
|||||||
htmlrender_browser_channel = name
|
htmlrender_browser_channel = name
|
||||||
break
|
break
|
||||||
|
|
||||||
if htmlrender_browser_channel:
|
elif system == "Darwin": # macOS
|
||||||
nonebot.logger.info(
|
from pathlib import Path
|
||||||
f"Using {htmlrender_browser_channel} as htmlrender browser channel."
|
|
||||||
)
|
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
|
# from nonebot.adapters.discord import Adapter as DiscordAdapter
|
||||||
|
|||||||
Reference in New Issue
Block a user