更正文件命名错误及调整配置项 (#496)

* 🔧 自动更新依赖文件

* 调整playwright默认安装的浏览器内核

新增安装playwright时需要下载的浏览器内核,默认为firefox

* 添加有关playwright的说明

* 修复文件错名及优化配置项

* 使用配置模型及修复部分错误导致的显示异常

1. 使用小派蒙配置模型
2. 修复图片生成时丢失html样式

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
nicklly 2024-01-22 10:46:57 +08:00 committed by GitHub
parent a01db7f3a0
commit aa021de6cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 1317 additions and 1028 deletions

View File

@ -50,6 +50,7 @@ class ConfigModel(BaseModel):
admin_theme: Literal['default', 'antd', 'ang', 'dark'] = Field('default', alias='Web端主题') admin_theme: Literal['default', 'antd', 'ang', 'dark'] = Field('default', alias='Web端主题')
command_alias_enable: bool = Field(True, alias='启用命令别名') command_alias_enable: bool = Field(True, alias='启用命令别名')
browser_type: Literal['chromium', 'firefox', 'webkit'] = Field('firefox', alias='浏览器内核')
# 早报60s # 早报60s
morning_news: str = Field('https://api.vvhan.com/api/60s', alias='早报60s') morning_news: str = Field('https://api.vvhan.com/api/60s', alias='早报60s')

View File

@ -1,9 +1,7 @@
from os import getcwd
import jinja2 import jinja2
from .event import * from .event import *
from datetime import datetime, timedelta from datetime import datetime, timedelta
from LittlePaimon.utils.brower import get_new_page from LittlePaimon.utils.browser import get_new_page
body = [] body = []
weeks = [] weeks = []
@ -48,10 +46,10 @@ async def generate_day_schedule(server='cn'):
'online': f'{datetime.strftime(event["start"], "%m-%d")} ~ {datetime.strftime(event["end"], "%m-%d")}', 'online': f'{datetime.strftime(event["start"], "%m-%d")} ~ {datetime.strftime(event["end"], "%m-%d")}',
'color': event['color'], 'banner': event['banner']}) 'color': event['color'], 'banner': event['banner']})
content = await template.render_async(body=body, css_path=template_path, week=weeks) content = await template.render_async(body=body, week=weeks)
async with get_new_page(viewport={'width': 600, 'height': 10}) as page: async with get_new_page(viewport={'width': 600, 'height': 10}) as page:
await page.goto(f'file://{getcwd()}') await page.goto(f'file://{template_path}/calendar.html')
await page.set_content(content, wait_until='networkidle') await page.set_content(content, wait_until='networkidle')
await page.wait_for_timeout(0.2) await page.wait_for_timeout(0.2)
return await page.screenshot(full_page=True) return await page.screenshot(full_page=True)

View File

@ -4,9 +4,9 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>原神日历</title> <title>原神日历</title>
<link rel="stylesheet" href="{{ css_path }}/iview.css" /> <link rel="stylesheet" href="iview.css" />
<link rel="stylesheet" href="{{ css_path }}/index.css" /> <link rel="stylesheet" href="index.css" />
<link rel="stylesheet" href="{{ css_path }}/normalize.css"> <link rel="stylesheet" href="normalize.css">
</head> </head>
<body> <body>

View File

@ -4,7 +4,7 @@ from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment
from nonebot.plugin import PluginMetadata from nonebot.plugin import PluginMetadata
from LittlePaimon.utils import logger from LittlePaimon.utils import logger
from LittlePaimon.utils.brower import screenshot from LittlePaimon.utils.browser import screenshot
__plugin_meta__ = PluginMetadata( __plugin_meta__ = PluginMetadata(
name='米游社', name='米游社',

View File

@ -6,7 +6,7 @@ from nonebot.rule import Rule
from LittlePaimon import SUPERUSERS from LittlePaimon import SUPERUSERS
from LittlePaimon.config import config from LittlePaimon.config import config
from LittlePaimon.utils.brower import screenshot from LittlePaimon.utils.browser import screenshot
async def permission_check(event: MessageEvent) -> bool: async def permission_check(event: MessageEvent) -> bool:

View File

@ -6,9 +6,11 @@ from playwright.async_api import Page, Browser, Playwright, async_playwright, Er
from . import DRIVER from . import DRIVER
from .logger import logger from .logger import logger
from LittlePaimon.config import config as bot_config
_playwright: Optional[Playwright] = None _playwright: Optional[Playwright] = None
_browser: Optional[Browser] = None _browser: Optional[Browser] = None
_browser_type = bot_config.browser_type
async def init(**kwargs) -> Browser: async def init(**kwargs) -> Browser:
@ -27,7 +29,13 @@ async def init(**kwargs) -> Browser:
async def launch_browser(**kwargs) -> Browser: async def launch_browser(**kwargs) -> Browser:
assert _playwright is not None, "Playwright is not initialized" assert _playwright is not None, "Playwright is not initialized"
return await _playwright.chromium.launch(**kwargs)
if _browser_type == 'firefox':
return await _playwright.firefox.launch(**kwargs)
elif _browser_type == 'chromium':
return await _playwright.chromium.launch(**kwargs)
elif _browser_type == 'webkit':
return await _playwright.webkit.launch(**kwargs)
async def get_browser(**kwargs) -> Browser: async def get_browser(**kwargs) -> Browser:
@ -40,8 +48,8 @@ async def install_browser():
from playwright.__main__ import main from playwright.__main__ import main
logger.info('Playwright', '正在安装 chromium') logger.info('Playwright', f'正在安装 {_browser_type}')
sys.argv = ["", "install", "chromium"] sys.argv = ["", "install", f"{_browser_type}"]
with suppress(SystemExit): with suppress(SystemExit):
logger.info('Playwright', '正在安装依赖') logger.info('Playwright', '正在安装依赖')
os.system("playwright install-deps") os.system("playwright install-deps")

View File

@ -39,6 +39,26 @@ cookie_web_form = Form(
value='${CookieWeb地址}', value='${CookieWeb地址}',
labelRemark=Remark(shape='circle', content='只是设置对用户显示的CookieWeb地址要填写实际的地址') labelRemark=Remark(shape='circle', content='只是设置对用户显示的CookieWeb地址要填写实际的地址')
), ),
Select(
label='浏览器内核',
name='浏览器内核',
value='${浏览器内核}',
labelRemark=Remark(shape='circle', content='用于生成原神日历的浏览器内核'),
options=[
{
'label': '火狐FireFox',
'value': 'firefox'
},
{
'label': '谷歌Chormium',
'value': 'chromium'
},
{
'label': 'WebKit',
'value': 'webkit'
}
]
),
Switch( Switch(
label='是否启用Web端', label='是否启用Web端',
name='启用Web端', name='启用Web端',

View File

@ -65,6 +65,10 @@
<img src="https://s1.ax1x.com/2023/02/05/pS6fAG6.jpg" alt="map"> <img src="https://s1.ax1x.com/2023/02/05/pS6fAG6.jpg" alt="map">
</details> </details>
## | Playwright相关问题
因部分系统不适用于chromium谷歌浏览器故将默认内核改为FireFox
如需切换,可更改 config/paimon_config_default.yml 的默认值
## | 常见问题&致谢 ## | 常见问题&致谢
详见[常见问题](https://docs.paimon.cherishmoon.fun/question.html)和[致谢](https://docs.paimon.cherishmoon.fun/thanks.html)。 详见[常见问题](https://docs.paimon.cherishmoon.fun/question.html)和[致谢](https://docs.paimon.cherishmoon.fun/thanks.html)。

View File

@ -20,4 +20,9 @@ CookieWeb地址: http://127.0.0.1:13579/LittlePaimon/cookie
实时便签检查开关: true # 是否开启实时便签检查 实时便签检查开关: true # 是否开启实时便签检查
实时便签检查间隔: 16 # 实时便签检查间隔,单位分钟 实时便签检查间隔: 16 # 实时便签检查间隔,单位分钟
实时便签停止检查开始时间: 0 实时便签停止检查开始时间: 0
实时便签停止检查结束时间: 6 # 处于这个时间段的时候停止检查 实时便签停止检查结束时间: 6 # 处于这个时间段的时候停止检查
# 浏览器内核设置
# 可选 chromium, firefox, webkit
# 默认使用firefox
browser_type: ''

2183
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -2,88 +2,88 @@
aiosqlite==0.17.0 ; python_version >= "3.8" and python_version < "4.0" aiosqlite==0.17.0 ; python_version >= "3.8" and python_version < "4.0"
amis-python==1.0.8.post2 ; python_version >= "3.8" and python_version < "4.0" amis-python==1.0.8.post2 ; python_version >= "3.8" and python_version < "4.0"
anyio==3.7.1 ; python_version >= "3.8" and python_version < "4.0" anyio==4.2.0 ; python_version >= "3.8" and python_version < "4.0"
apscheduler==3.10.4 ; python_version >= "3.8" and python_version < "4.0" apscheduler==3.10.4 ; python_version >= "3.8" and python_version < "4.0"
backports-zoneinfo==0.2.1 ; python_version >= "3.8" and python_version < "3.9" backports-zoneinfo==0.2.1 ; python_version >= "3.8" and python_version < "3.9"
beautifulsoup4==4.12.2 ; python_version >= "3.8" and python_version < "4.0" beautifulsoup4==4.12.3 ; python_version >= "3.8" and python_version < "4.0"
certifi==2023.7.22 ; python_version >= "3.8" and python_version < "4.0" certifi==2023.11.17 ; python_version >= "3.8" and python_version < "4.0"
click==8.1.7 ; python_version >= "3.8" and python_version < "4.0" click==8.1.7 ; python_version >= "3.8" and python_version < "4.0"
colorama==0.4.6 ; python_version >= "3.8" and python_version < "4.0" and (platform_system == "Windows" or sys_platform == "win32") colorama==0.4.6 ; python_version >= "3.8" and python_version < "4.0" and (platform_system == "Windows" or sys_platform == "win32")
contourpy==1.1.0 ; python_version >= "3.8" and python_version < "4.0" contourpy==1.1.1 ; python_version >= "3.8" and python_version < "4.0"
cycler==0.11.0 ; python_version >= "3.8" and python_version < "4.0" cycler==0.12.1 ; python_version >= "3.8" and python_version < "4.0"
ecdsa==0.18.0 ; python_version >= "3.8" and python_version < "4.0" ecdsa==0.18.0 ; python_version >= "3.8" and python_version < "4.0"
exceptiongroup==1.1.3 ; python_version >= "3.8" and python_version < "3.11" exceptiongroup==1.2.0 ; python_version >= "3.8" and python_version < "3.11"
expandvars==0.9.0 ; python_version >= "3.8" and python_version < "4.0" expandvars==0.9.0 ; python_version >= "3.8" and python_version < "4.0"
fastapi==0.101.1 ; python_version >= "3.8" and python_version < "4.0" fastapi==0.109.0 ; python_version >= "3.8" and python_version < "4.0"
fonttools==4.42.1 ; python_version >= "3.8" and python_version < "4.0" fonttools==4.47.2 ; python_version >= "3.8" and python_version < "4.0"
gitdb==4.0.10 ; python_version >= "3.8" and python_version < "4.0" gitdb==4.0.11 ; python_version >= "3.8" and python_version < "4.0"
gitpython==3.1.32 ; python_version >= "3.8" and python_version < "4.0" gitpython==3.1.41 ; python_version >= "3.8" and python_version < "4.0"
greenlet==2.0.2 ; python_version >= "3.8" and python_version < "4.0" greenlet==3.0.3 ; python_version >= "3.8" and python_version < "4.0"
h11==0.14.0 ; python_version >= "3.8" and python_version < "4.0" h11==0.14.0 ; python_version >= "3.8" and python_version < "4.0"
httpcore==0.16.3 ; python_version >= "3.8" and python_version < "4.0" httpcore==0.16.3 ; python_version >= "3.8" and python_version < "4.0"
httptools==0.6.0 ; python_version >= "3.8" and python_version < "4.0" httptools==0.6.1 ; python_version >= "3.8" and python_version < "4.0"
httpx==0.23.3 ; python_version >= "3.8" and python_version < "4.0" httpx==0.23.3 ; python_version >= "3.8" and python_version < "4.0"
idna==3.4 ; python_version >= "3.8" and python_version < "4.0" idna==3.6 ; python_version >= "3.8" and python_version < "4.0"
importlib-resources==6.0.1 ; python_version >= "3.8" and python_version < "3.10" importlib-resources==6.1.1 ; python_version >= "3.8" and python_version < "3.10"
iso8601==1.1.0 ; python_version >= "3.8" and python_version < "4.0" iso8601==1.1.0 ; python_version >= "3.8" and python_version < "4.0"
jieba==0.42.1 ; python_version >= "3.8" and python_version < "4.0" jieba==0.42.1 ; python_version >= "3.8" and python_version < "4.0"
jinja2==3.1.2 ; python_version >= "3.8" and python_version < "4.0" jinja2==3.1.3 ; python_version >= "3.8" and python_version < "4.0"
joblib==1.3.2 ; python_version >= "3.8" and python_version < "4.0" joblib==1.3.2 ; python_version >= "3.8" and python_version < "4.0"
kiwisolver==1.4.4 ; python_version >= "3.8" and python_version < "4.0" kiwisolver==1.4.5 ; python_version >= "3.8" and python_version < "4.0"
loguru==0.7.0 ; python_version >= "3.8" and python_version < "4.0" loguru==0.7.2 ; python_version >= "3.8" and python_version < "4.0"
lxml==4.9.3 ; python_version >= "3.8" and python_version < "4.0" lxml==4.9.4 ; python_version >= "3.8" and python_version < "4.0"
markupsafe==2.1.3 ; python_version >= "3.8" and python_version < "4.0" markupsafe==2.1.4 ; python_version >= "3.8" and python_version < "4.0"
matplotlib==3.7.2 ; python_version >= "3.8" and python_version < "4.0" matplotlib==3.7.4 ; python_version >= "3.8" and python_version < "4.0"
msgpack==1.0.5 ; python_version >= "3.8" and python_version < "4.0" msgpack==1.0.7 ; python_version >= "3.8" and python_version < "4.0"
multidict==6.0.4 ; python_version >= "3.8" and python_version < "4.0" multidict==6.0.4 ; python_version >= "3.8" and python_version < "4.0"
nonebot-adapter-onebot==2.2.4 ; python_version >= "3.8" and python_version < "4.0" nonebot-adapter-onebot==2.3.1 ; python_version >= "3.8" and python_version < "4.0"
nonebot-plugin-apscheduler==0.2.0 ; python_version >= "3.8" and python_version < "4.0" nonebot-plugin-apscheduler==0.2.0 ; python_version >= "3.8" and python_version < "4.0"
nonebot2==2.0.1 ; python_version >= "3.8" and python_version < "4.0" nonebot2==2.1.3 ; python_version >= "3.8" and python_version < "4.0"
nonebot2[fastapi]==2.0.1 ; python_version >= "3.8" and python_version < "4.0" nonebot2[fastapi]==2.1.3 ; python_version >= "3.8" and python_version < "4.0"
numpy==1.24.4 ; python_version >= "3.8" and python_version < "4.0" numpy==1.24.4 ; python_version >= "3.8" and python_version < "4.0"
packaging==23.1 ; python_version >= "3.8" and python_version < "4.0" packaging==23.2 ; python_version >= "3.8" and python_version < "4.0"
pillow==9.5.0 ; python_version >= "3.8" and python_version < "4.0" pillow==9.5.0 ; python_version >= "3.8" and python_version < "4.0"
playwright==1.37.0 ; python_version >= "3.8" and python_version < "4.0" playwright==1.41.0 ; python_version >= "3.8" and python_version < "4.0"
psutil==5.9.5 ; python_version >= "3.8" and python_version < "4.0" psutil==5.9.8 ; python_version >= "3.8" and python_version < "4.0"
pyasn1==0.5.0 ; python_version >= "3.8" and python_version < "4.0" pyasn1==0.5.1 ; python_version >= "3.8" and python_version < "4.0"
pydantic==1.10.12 ; python_version >= "3.8" and python_version < "4.0" pydantic==1.10.14 ; python_version >= "3.8" and python_version < "4.0"
pydantic[dotenv]==1.10.12 ; python_version >= "3.8" and python_version < "4.0" pydantic[dotenv]==1.10.14 ; python_version >= "3.8" and python_version < "4.0"
pyee==9.0.4 ; python_version >= "3.8" and python_version < "4.0" pyee==11.0.1 ; python_version >= "3.8" and python_version < "4.0"
pygtrie==2.5.0 ; python_version >= "3.8" and python_version < "4.0" pygtrie==2.5.0 ; python_version >= "3.8" and python_version < "4.0"
pyparsing==3.0.9 ; python_version >= "3.8" and python_version < "4.0" pyparsing==3.1.1 ; python_version >= "3.8" and python_version < "4.0"
pypika-tortoise==0.1.6 ; python_version >= "3.8" and python_version < "4.0" pypika-tortoise==0.1.6 ; python_version >= "3.8" and python_version < "4.0"
pypinyin==0.47.1 ; python_version >= "3.8" and python_version < "4" pypinyin==0.47.1 ; python_version >= "3.8" and python_version < "4"
pypng==0.20220715.0 ; python_version >= "3.8" and python_version < "4.0" pypng==0.20220715.0 ; python_version >= "3.8" and python_version < "4.0"
python-dateutil==2.8.2 ; python_version >= "3.8" and python_version < "4.0" python-dateutil==2.8.2 ; python_version >= "3.8" and python_version < "4.0"
python-dotenv==1.0.0 ; python_version >= "3.8" and python_version < "4.0" python-dotenv==1.0.0 ; python_version >= "3.8" and python_version < "4.0"
python-jose==3.3.0 ; python_version >= "3.8" and python_version < "4.0" python-jose==3.3.0 ; python_version >= "3.8" and python_version < "4.0"
pytz==2023.3 ; python_version >= "3.8" and python_version < "4.0" pytz==2023.3.post1 ; python_version >= "3.8" and python_version < "4.0"
pyyaml==6.0.1 ; python_version >= "3.8" and python_version < "4.0" pyyaml==6.0.1 ; python_version >= "3.8" and python_version < "4.0"
qrcode==7.4.2 ; python_version >= "3.8" and python_version < "4.0" qrcode==7.4.2 ; python_version >= "3.8" and python_version < "4.0"
rfc3986[idna2008]==1.5.0 ; python_version >= "3.8" and python_version < "4.0" rfc3986[idna2008]==1.5.0 ; python_version >= "3.8" and python_version < "4.0"
rsa==4.9 ; python_version >= "3.8" and python_version < "4" rsa==4.9 ; python_version >= "3.8" and python_version < "4"
ruamel-yaml-clib==0.2.7 ; platform_python_implementation == "CPython" and python_version < "3.12" and python_version >= "3.8" ruamel-yaml-clib==0.2.8 ; platform_python_implementation == "CPython" and python_version < "3.13" and python_version >= "3.8"
ruamel-yaml==0.17.32 ; python_version >= "3.8" and python_version < "4.0" ruamel-yaml==0.17.40 ; python_version >= "3.8" and python_version < "4.0"
scikit-learn==1.3.0 ; python_version >= "3.8" and python_version < "4.0" scikit-learn==1.3.2 ; python_version >= "3.8" and python_version < "4.0"
scipy==1.9.3 ; python_version >= "3.8" and python_version < "4.0" scipy==1.9.3 ; python_version >= "3.8" and python_version < "4.0"
shapely==1.8.5.post1 ; python_version >= "3.8" and python_version < "4.0" shapely==1.8.5.post1 ; python_version >= "3.8" and python_version < "4.0"
six==1.16.0 ; python_version >= "3.8" and python_version < "4.0" six==1.16.0 ; python_version >= "3.8" and python_version < "4.0"
smmap==5.0.0 ; python_version >= "3.8" and python_version < "4.0" smmap==5.0.1 ; python_version >= "3.8" and python_version < "4.0"
sniffio==1.3.0 ; python_version >= "3.8" and python_version < "4.0" sniffio==1.3.0 ; python_version >= "3.8" and python_version < "4.0"
soupsieve==2.4.1 ; python_version >= "3.8" and python_version < "4.0" soupsieve==2.5 ; python_version >= "3.8" and python_version < "4.0"
starlette==0.27.0 ; python_version >= "3.8" and python_version < "4.0" starlette==0.35.1 ; python_version >= "3.8" and python_version < "4.0"
threadpoolctl==3.2.0 ; python_version >= "3.8" and python_version < "4.0" threadpoolctl==3.2.0 ; python_version >= "3.8" and python_version < "4.0"
tomli==2.0.1 ; python_version >= "3.8" and python_version < "3.11" tomli==2.0.1 ; python_version >= "3.8" and python_version < "3.11"
tortoise-orm==0.19.3 ; python_version >= "3.8" and python_version < "4.0" tortoise-orm==0.19.3 ; python_version >= "3.8" and python_version < "4.0"
tqdm==4.66.1 ; python_version >= "3.8" and python_version < "4.0" tqdm==4.66.1 ; python_version >= "3.8" and python_version < "4.0"
typing-extensions==4.7.1 ; python_version >= "3.8" and python_version < "4.0" typing-extensions==4.9.0 ; python_version >= "3.8" and python_version < "4.0"
tzdata==2023.3 ; python_version >= "3.8" and python_version < "4.0" and platform_system == "Windows" tzdata==2023.4 ; python_version >= "3.8" and python_version < "4.0" and platform_system == "Windows"
tzlocal==5.0.1 ; python_version >= "3.8" and python_version < "4.0" tzlocal==5.2 ; python_version >= "3.8" and python_version < "4.0"
ujson==5.8.0 ; python_version >= "3.8" and python_version < "4.0" ujson==5.9.0 ; python_version >= "3.8" and python_version < "4.0"
uvicorn[standard]==0.23.2 ; python_version >= "3.8" and python_version < "4.0" uvicorn[standard]==0.26.0 ; python_version >= "3.8" and python_version < "4.0"
uvloop==0.17.0 ; (sys_platform != "win32" and sys_platform != "cygwin") and platform_python_implementation != "PyPy" and python_version >= "3.8" and python_version < "4.0" uvloop==0.19.0 ; (sys_platform != "win32" and sys_platform != "cygwin") and platform_python_implementation != "PyPy" and python_version >= "3.8" and python_version < "4.0"
watchfiles==0.19.0 ; python_version >= "3.8" and python_version < "4.0" watchfiles==0.21.0 ; python_version >= "3.8" and python_version < "4.0"
websockets==11.0.3 ; python_version >= "3.8" and python_version < "4.0" websockets==12.0 ; python_version >= "3.8" and python_version < "4.0"
win32-setctime==1.1.0 ; python_version >= "3.8" and python_version < "4.0" and sys_platform == "win32" win32-setctime==1.1.0 ; python_version >= "3.8" and python_version < "4.0" and sys_platform == "win32"
yarl==1.9.2 ; python_version >= "3.8" and python_version < "4.0" yarl==1.9.4 ; python_version >= "3.8" and python_version < "4.0"
zipp==3.16.2 ; python_version >= "3.8" and python_version < "3.10" zipp==3.17.0 ; python_version >= "3.8" and python_version < "3.10"