同步技能全量内容:更新主说明、跨平台安装脚本与面板UI审计脚本
This commit is contained in:
@@ -7,7 +7,6 @@ from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
@@ -260,31 +259,6 @@ def audit_page(page: Page, route: str, extra_openers: list[str]) -> dict[str, An
|
||||
return {'route': route, 'issues': issues}
|
||||
|
||||
|
||||
def launch_chromium(playwright):
|
||||
launch_options = {'headless': True}
|
||||
channel = os.environ.get('PANEL_PLAYWRIGHT_CHANNEL')
|
||||
executable_path = os.environ.get('PANEL_PLAYWRIGHT_EXECUTABLE_PATH')
|
||||
if channel:
|
||||
launch_options['channel'] = channel
|
||||
elif executable_path:
|
||||
launch_options['executable_path'] = executable_path
|
||||
else:
|
||||
local_app_data = os.environ.get('LOCALAPPDATA', '')
|
||||
playwright_cache = Path(local_app_data) / 'ms-playwright' if local_app_data else None
|
||||
has_downloaded_chromium = bool(
|
||||
playwright_cache and list(playwright_cache.glob('chromium-*/chrome-win64/chrome.exe'))
|
||||
)
|
||||
if not has_downloaded_chromium:
|
||||
program_files_x86 = os.environ.get('ProgramFiles(x86)', '')
|
||||
program_files = os.environ.get('ProgramFiles', '')
|
||||
edge_candidates = [
|
||||
Path(program_files_x86) / 'Microsoft' / 'Edge' / 'Application' / 'msedge.exe',
|
||||
Path(program_files) / 'Microsoft' / 'Edge' / 'Application' / 'msedge.exe',
|
||||
]
|
||||
if any(edge.exists() for edge in edge_candidates):
|
||||
launch_options['channel'] = 'msedge'
|
||||
return playwright.chromium.launch(**launch_options)
|
||||
|
||||
def csv_list(value: str) -> list[str]:
|
||||
return [item.strip() for item in value.split(',') if item.strip()]
|
||||
|
||||
@@ -313,7 +287,7 @@ def main() -> int:
|
||||
report: dict[str, Any] = {'baseUrl': args.base_url, 'pages': []}
|
||||
|
||||
with sync_playwright() as playwright:
|
||||
browser = launch_chromium(playwright)
|
||||
browser = playwright.chromium.launch(headless=True)
|
||||
page = browser.new_page(viewport={'width': args.viewport_width, 'height': args.viewport_height})
|
||||
|
||||
if not args.skip_login:
|
||||
@@ -348,4 +322,3 @@ def main() -> int:
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user