chore: 分发包改用 WebView2 在线安装器

This commit is contained in:
Nixevol
2026-10-25 05:49:44 +08:00
parent f53498f6e6
commit 2286bc597d
3 changed files with 16 additions and 11 deletions
+3 -3
View File
@@ -6,7 +6,7 @@ Windows 桌面程序,用来登录 RaptDrama、黄豆短剧和 DramaBox,浏
1. 解压 `dist/VideosDownTools-windows-x64.zip`。
2. 进入 `VideosDownTools`,运行 `VideosDownTools.exe`。
3. 压缩包里已经带有 Python、adb、ffmpeg 和 WebView2 离线安装包。本机如果还没有 WebView2,程序启动时会静默安装。
3. 压缩包里已经带有 Python、adb、ffmpeg 和大约 2 MB 的 WebView2 在线安装器。本机如果还没有 WebView2,程序启动时会用它联网静默安装。
程序会在自己的目录里写入:
@@ -44,8 +44,8 @@ python scripts\package.py
- `dist/cache` 里的 Windows 嵌入式 Python,以及 `server/requirements.txt` 里的依赖
- `vendor/platform-tools` 里的 adb,拷到压缩包的 `tools/platform-tools`
- `tools/ffmpeg/ffmpeg.exe`
- `vendor/webview2/MicrosoftEdgeWebView2RuntimeInstallerX64.exe`
- `vendor/webview2/MicrosoftEdgeWebview2Setup.exe`。本机还没有这个文件时,打包会从微软下载这份在线安装器。同目录里的离线安装包不会打进压缩包。
adb 和 WebView2 打包时不再下载。完成后得到 `dist/VideosDownTools-windows-x64.zip`。
adb 打包时不再下载。完成后得到 `dist/VideosDownTools-windows-x64.zip`。
打包脚本是 Python,公共步骤和平台相关的运行时是分开的。目前只接好了 Windows。macOS 和 Linux 以后把对应文件放进 `vendor` 即可。
+8 -3
View File
@@ -4,7 +4,7 @@
python scripts/package.py
Windows 会编译界面和桌面程序,并拷贝本地已有的 Python 缓存、adb、ffmpeg 和 WebView2 离线安装包。
Windows 会编译界面和桌面程序,并拷贝本地已有的 Python 缓存、adb、ffmpeg 和 WebView2 在线安装器。
macOS、Linux 以后可以在对应函数里补上自己的运行时,其余步骤可以复用。
"""
@@ -31,7 +31,8 @@ PYTHON_EMBED_URL = (
)
GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py"
FFMPEG_URL = "https://github.com/eugeneware/ffmpeg-static/releases/download/b6.1.1/ffmpeg-win32-x64.gz"
WEBVIEW_INSTALLER = "MicrosoftEdgeWebView2RuntimeInstallerX64.exe"
WEBVIEW_INSTALLER = "MicrosoftEdgeWebview2Setup.exe"
WEBVIEW_BOOTSTRAP_URL = "https://go.microsoft.com/fwlink/p/?LinkId=2124703"
def log(message: str) -> None:
@@ -166,7 +167,11 @@ def bundle_webview(stage: Path) -> None:
return
source = ROOT / "vendor" / "webview2" / WEBVIEW_INSTALLER
if not source.is_file():
raise SystemExit(f"vendor/webview2 里没有 {WEBVIEW_INSTALLER}")
download(WEBVIEW_BOOTSTRAP_URL, source)
data = source.read_bytes()[:2]
size = source.stat().st_size
if data != b"MZ" or not 200_000 <= size <= 20_000_000:
raise SystemExit(f"{WEBVIEW_INSTALLER} 不是 WebView2 在线安装器")
dest = stage / "vendor" / "webview2"
dest.mkdir(parents=True, exist_ok=True)
shutil.copy2(source, dest / source.name)
+5 -5
View File
@@ -54,11 +54,11 @@ fn prepare_webview_runtime(root: &Path) {
if webview_runtime_installed() {
return;
}
let installer = root
.join("vendor")
.join("webview2")
.join("MicrosoftEdgeWebView2RuntimeInstallerX64.exe");
if installer.is_file() {
let installer = ["MicrosoftEdgeWebview2Setup.exe", "MicrosoftEdgeWebView2RuntimeInstallerX64.exe"]
.into_iter()
.map(|name| root.join("vendor").join("webview2").join(name))
.find(|path| path.is_file());
if let Some(installer) = installer {
let _ = Command::new(installer).args(["/silent", "/install"]).status();
}
}