Playwright headless 设置
在 Suan API 设置中添加控制 playwright headless 模式的设置。
This commit is contained in:
@@ -61,6 +61,7 @@ class Config:
|
||||
doc_system["port"] = 8000
|
||||
doc_system["reload"] = True
|
||||
|
||||
doc_schedule["playwright_headless"] = True
|
||||
doc_schedule["jwxt_login_method"] = "sso"
|
||||
doc_schedule["semester_start_date"] = "2026-03-02"
|
||||
doc_schedule["schedule_title_template"] = "芒果酸的第 {title} 周课程表"
|
||||
|
||||
@@ -6,6 +6,8 @@ from playwright.async_api import (
|
||||
async_playwright,
|
||||
)
|
||||
|
||||
from . import config
|
||||
|
||||
|
||||
class PlayContextManager:
|
||||
def __init__(
|
||||
@@ -26,7 +28,7 @@ class PlayContextManager:
|
||||
"""手动启动"""
|
||||
self.playwright = await async_playwright().start() # 不是 __enter__
|
||||
self.browser = await self.playwright.chromium.launch(
|
||||
headless=False,
|
||||
headless=config.get("schedule", "playwright_headless", True),
|
||||
args=[
|
||||
"--disable-blink-features=AutomationControlled",
|
||||
"--no-sandbox",
|
||||
|
||||
@@ -71,6 +71,12 @@ function varTag(code: string, description: string) {
|
||||
</n-collapse-item>
|
||||
<n-collapse-item name="schedule" title="课表设置">
|
||||
<n-flex vertical>
|
||||
<setting-card
|
||||
v-model:boolean-value="CONFIG.data.schedule.playwright_headless"
|
||||
message="在生产环境中应当为 True,请参阅文档。"
|
||||
show-switch
|
||||
title="Playwright Headless 模式"
|
||||
/>
|
||||
<setting-card
|
||||
v-model:selection-value="CONFIG.data.schedule.jwxt_login_method"
|
||||
:selection-options="JwxtLoginMethodOptions"
|
||||
|
||||
@@ -5,6 +5,7 @@ export interface ConfigSystemDto {
|
||||
}
|
||||
|
||||
export interface ConfigScheduleDto {
|
||||
playwright_headless?: true
|
||||
jwxt_login_method?: 'jwxt' | 'sso'
|
||||
semester_start_date?: string
|
||||
schedule_title_template?: string
|
||||
|
||||
Reference in New Issue
Block a user