From d9c50f78b5229d38994b3eb8458c3911f9b4a67e Mon Sep 17 00:00:00 2001 From: Rbqwow <55343783+Rbqwow@users.noreply.github.com> Date: Thu, 19 Feb 2026 20:11:23 +0800 Subject: [PATCH 1/9] =?UTF-8?q?build:=20=E6=B7=BB=E5=8A=A0=20fixed-webview?= =?UTF-8?q?=20=E6=9E=84=E5=BB=BA=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 37 +++++++++++++++++++++++++++++++++++++ src-tauri/src/main.rs | 14 +++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0544dc1..f3f0e9e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -126,6 +126,43 @@ jobs: name: MXU-win-${{ matrix.arch }} path: "install" + - name: Copy WebView2 Runtime for fixed-webview variant + if: matrix.arch == 'x86_64' + shell: pwsh + run: | + # 优先使用 WebView2 Runtime,其次使用 Edge 安装目录 + $wv2Base = "C:\Program Files (x86)\Microsoft\EdgeWebView\Application" + if (-not (Test-Path $wv2Base)) { + $wv2Base = "C:\Program Files (x86)\Microsoft\Edge\Application" + } + if (-not (Test-Path $wv2Base)) { + Write-Error "Neither WebView2 Runtime nor Edge found" + exit 1 + } + $versionDir = Get-ChildItem $wv2Base -Directory | + Where-Object { $_.Name -match '^\d+\.\d+' } | + Sort-Object { [version]($_.Name -replace '-.*$','') } -Descending | + Select-Object -First 1 + if (-not $versionDir) { + Write-Error "No WebView2 version directory found in $wv2Base" + exit 1 + } + $dest = "install\webview2_runtime" + New-Item -ItemType Directory -Force -Path $dest | Out-Null + Copy-Item -Path "$($versionDir.FullName)\*" -Destination $dest -Recurse + # 删除不需要的 Installer 子目录以减小体积 + if (Test-Path "$dest\Installer") { + Remove-Item -Path "$dest\Installer" -Recurse -Force + } + Write-Host "Copied WebView2 runtime $($versionDir.Name) from $wv2Base" + + - name: Upload fixed-webview artifacts + if: matrix.arch == 'x86_64' + uses: actions/upload-artifact@v4 + with: + name: MXU-win-${{ matrix.arch }}-fixed-webview + path: "install" + linux: needs: meta runs-on: ubuntu-latest diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 10cdf91..07bc545 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -15,10 +15,22 @@ fn main() { // 确保目录存在 let _ = std::fs::create_dir_all(&webview_data_dir); std::env::set_var("WEBVIEW2_USER_DATA_FOLDER", &webview_data_dir); + + // 检测内置的 WebView2 固定版本运行时 + let webview2_runtime_dir = exe_dir.join("webview2_runtime"); + if webview2_runtime_dir.exists() { + std::env::set_var( + "WEBVIEW2_BROWSER_EXECUTABLE_FOLDER", + &webview2_runtime_dir, + ); + } } } - if !webview2::ensure_webview2() { + // 未内置 WebView2 运行时时,检测系统是否已安装,未安装则自动下载安装 + if std::env::var_os("WEBVIEW2_BROWSER_EXECUTABLE_FOLDER").is_none() + && !webview2::ensure_webview2() + { std::process::exit(1); } From cd8b51cc92403b6d88c5ff93f6df31f19182b0b6 Mon Sep 17 00:00:00 2001 From: Rbqwow <55343783+Rbqwow@users.noreply.github.com> Date: Thu, 19 Feb 2026 20:19:48 +0800 Subject: [PATCH 2/9] build: review --- .github/workflows/build.yml | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f3f0e9e..87f3bd8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -130,23 +130,33 @@ jobs: if: matrix.arch == 'x86_64' shell: pwsh run: | - # 优先使用 WebView2 Runtime,其次使用 Edge 安装目录 - $wv2Base = "C:\Program Files (x86)\Microsoft\EdgeWebView\Application" - if (-not (Test-Path $wv2Base)) { - $wv2Base = "C:\Program Files (x86)\Microsoft\Edge\Application" + # 搜索所有可能的 WebView2/Edge 安装路径(x86 + 64-bit) + $candidateBases = @( + "C:\Program Files (x86)\Microsoft\EdgeWebView\Application", + "C:\Program Files\Microsoft\EdgeWebView\Application", + "C:\Program Files (x86)\Microsoft\Edge\Application", + "C:\Program Files\Microsoft\Edge\Application" + ) + + # 从所有存在的路径中收集版本目录,选取最新版本 + $allVersionDirs = @() + foreach ($base in $candidateBases) { + if (Test-Path $base) { + $dirs = Get-ChildItem $base -Directory | + Where-Object { $_.Name -match '^\d+\.\d+' } + if ($dirs) { $allVersionDirs += $dirs } + } } - if (-not (Test-Path $wv2Base)) { - Write-Error "Neither WebView2 Runtime nor Edge found" + + if ($allVersionDirs.Count -eq 0) { + Write-Error "No WebView2/Edge runtime found in any of the probed paths" exit 1 } - $versionDir = Get-ChildItem $wv2Base -Directory | - Where-Object { $_.Name -match '^\d+\.\d+' } | + + $versionDir = $allVersionDirs | Sort-Object { [version]($_.Name -replace '-.*$','') } -Descending | Select-Object -First 1 - if (-not $versionDir) { - Write-Error "No WebView2 version directory found in $wv2Base" - exit 1 - } + $dest = "install\webview2_runtime" New-Item -ItemType Directory -Force -Path $dest | Out-Null Copy-Item -Path "$($versionDir.FullName)\*" -Destination $dest -Recurse @@ -154,7 +164,7 @@ jobs: if (Test-Path "$dest\Installer") { Remove-Item -Path "$dest\Installer" -Recurse -Force } - Write-Host "Copied WebView2 runtime $($versionDir.Name) from $wv2Base" + Write-Host "Copied WebView2 runtime $($versionDir.Name) from $($versionDir.Parent.FullName)" - name: Upload fixed-webview artifacts if: matrix.arch == 'x86_64' From 22d64c93d1f43bbd9f068a87f0065d7d6b8f2a0e Mon Sep 17 00:00:00 2001 From: Rbqwow <55343783+Rbqwow@users.noreply.github.com> Date: Thu, 19 Feb 2026 21:01:12 +0800 Subject: [PATCH 3/9] =?UTF-8?q?build:=20=E4=B8=8B=E8=BD=BD=E5=BE=AE?= =?UTF-8?q?=E8=BD=AF=E7=9A=84=E8=BF=90=E8=A1=8C=E6=97=B6=E8=80=8C=E4=B8=8D?= =?UTF-8?q?=E6=98=AF=E4=BB=8Erunner=E5=A4=8D=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 解决没有arm64的问题 --- .github/workflows/build.yml | 53 +++++++++++++++---------------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 87f3bd8..ef6620e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -126,48 +126,37 @@ jobs: name: MXU-win-${{ matrix.arch }} path: "install" - - name: Copy WebView2 Runtime for fixed-webview variant - if: matrix.arch == 'x86_64' + - name: Download WebView2 Fixed Version Runtime shell: pwsh run: | - # 搜索所有可能的 WebView2/Edge 安装路径(x86 + 64-bit) - $candidateBases = @( - "C:\Program Files (x86)\Microsoft\EdgeWebView\Application", - "C:\Program Files\Microsoft\EdgeWebView\Application", - "C:\Program Files (x86)\Microsoft\Edge\Application", - "C:\Program Files\Microsoft\Edge\Application" - ) - - # 从所有存在的路径中收集版本目录,选取最新版本 - $allVersionDirs = @() - foreach ($base in $candidateBases) { - if (Test-Path $base) { - $dirs = Get-ChildItem $base -Directory | - Where-Object { $_.Name -match '^\d+\.\d+' } - if ($dirs) { $allVersionDirs += $dirs } - } - } + $archMap = @{ 'x86_64' = 'x64'; 'aarch64' = 'arm64' } + $arch = $archMap['${{ matrix.arch }}'] + $version = '133.0.3065.92' + $cabName = "Microsoft.WebView2.FixedVersionRuntime.$version.$arch.cab" + $uri = "https://github.com/westinyang/WebView2RuntimeArchive/releases/download/$version/$cabName" - if ($allVersionDirs.Count -eq 0) { - Write-Error "No WebView2/Edge runtime found in any of the probed paths" - exit 1 - } + Write-Host "Downloading $cabName ..." + Invoke-WebRequest -Uri $uri -OutFile $cabName - $versionDir = $allVersionDirs | - Sort-Object { [version]($_.Name -replace '-.*$','') } -Descending | - Select-Object -First 1 + $tempDir = "temp_wv2" + New-Item -ItemType Directory -Force -Path $tempDir | Out-Null + expand.exe $cabName -F:* $tempDir $dest = "install\webview2_runtime" New-Item -ItemType Directory -Force -Path $dest | Out-Null - Copy-Item -Path "$($versionDir.FullName)\*" -Destination $dest -Recurse - # 删除不需要的 Installer 子目录以减小体积 - if (Test-Path "$dest\Installer") { - Remove-Item -Path "$dest\Installer" -Recurse -Force + + # cab 解压后文件在版本子目录中,将其内容移动到 webview2_runtime/ + $versionDir = Get-ChildItem $tempDir -Directory | Where-Object { $_.Name -like "Microsoft.WebView2*" } | Select-Object -First 1 + if ($versionDir) { + Copy-Item -Path "$($versionDir.FullName)\*" -Destination $dest -Recurse -Force + } else { + Copy-Item -Path "$tempDir\*" -Destination $dest -Recurse -Force } - Write-Host "Copied WebView2 runtime $($versionDir.Name) from $($versionDir.Parent.FullName)" + + Remove-Item $cabName, $tempDir -Recurse -Force + Write-Host "WebView2 Fixed Version Runtime $version ($arch) ready at $dest" - name: Upload fixed-webview artifacts - if: matrix.arch == 'x86_64' uses: actions/upload-artifact@v4 with: name: MXU-win-${{ matrix.arch }}-fixed-webview From 7758244942b87e9578650d5185e77442758cbca5 Mon Sep 17 00:00:00 2001 From: Rbqwow <55343783+Rbqwow@users.noreply.github.com> Date: Thu, 19 Feb 2026 21:07:22 +0800 Subject: [PATCH 4/9] build: review 2 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ef6620e..cbb0c02 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -148,7 +148,7 @@ jobs: # cab 解压后文件在版本子目录中,将其内容移动到 webview2_runtime/ $versionDir = Get-ChildItem $tempDir -Directory | Where-Object { $_.Name -like "Microsoft.WebView2*" } | Select-Object -First 1 if ($versionDir) { - Copy-Item -Path "$($versionDir.FullName)\*" -Destination $dest -Recurse -Force + Copy-Item -Path "$($versionDir.FullName)\*" -Destination $dest -Recurse -Force -ErrorAction Stop } else { Copy-Item -Path "$tempDir\*" -Destination $dest -Recurse -Force } From 8a3dbce802dedf44bb21d278ba3b35557d1aff34 Mon Sep 17 00:00:00 2001 From: Rbqwow <55343783+Rbqwow@users.noreply.github.com> Date: Thu, 19 Feb 2026 21:11:18 +0800 Subject: [PATCH 5/9] build: review Update .github/workflows/build.yml Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cbb0c02..cdf9df2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -130,7 +130,11 @@ jobs: shell: pwsh run: | $archMap = @{ 'x86_64' = 'x64'; 'aarch64' = 'arm64' } - $arch = $archMap['${{ matrix.arch }}'] + $matrixArch = '${{ matrix.arch }}' + if (-not $archMap.ContainsKey($matrixArch)) { + throw "Unsupported architecture: $matrixArch" + } + $arch = $archMap[$matrixArch] $version = '133.0.3065.92' $cabName = "Microsoft.WebView2.FixedVersionRuntime.$version.$arch.cab" $uri = "https://github.com/westinyang/WebView2RuntimeArchive/releases/download/$version/$cabName" From f094c0bb9ed6c06377c5a4272e49c78d92b0713e Mon Sep 17 00:00:00 2001 From: Rbqwow <55343783+Rbqwow@users.noreply.github.com> Date: Thu, 19 Feb 2026 21:13:21 +0800 Subject: [PATCH 6/9] build: review 3 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cdf9df2..a86a148 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -154,7 +154,7 @@ jobs: if ($versionDir) { Copy-Item -Path "$($versionDir.FullName)\*" -Destination $dest -Recurse -Force -ErrorAction Stop } else { - Copy-Item -Path "$tempDir\*" -Destination $dest -Recurse -Force + Copy-Item -Path "$tempDir\*" -Destination $dest -Recurse -Force -ErrorAction Stop } Remove-Item $cabName, $tempDir -Recurse -Force From 1bab2a709681397ee15e58672dff1c55776bb026 Mon Sep 17 00:00:00 2001 From: Rbqwow <55343783+Rbqwow@users.noreply.github.com> Date: Thu, 19 Feb 2026 21:24:30 +0800 Subject: [PATCH 7/9] =?UTF-8?q?build:=20=E4=BB=8E=E5=BE=AE=E8=BD=AF?= =?UTF-8?q?=E5=A4=84=E4=B8=8B=E8=BD=BDwebview=E8=80=8C=E9=9D=9E=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E6=96=B9=E5=AD=98=E5=82=A8=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a86a148..729fea3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -129,17 +129,22 @@ jobs: - name: Download WebView2 Fixed Version Runtime shell: pwsh run: | + # 从微软官方 CDN 下载 WebView2 Fixed Version Runtime + # 更新版本时需同步更新 $version 和 $guidMap 中的 GUID + # GUID 可在 https://developer.microsoft.com/en-us/microsoft-edge/webview2/ 页面从 Fixed Version 的下载链接中获取 + # 或前往 Scoop 存储库查看 https://github.com/ScoopInstaller/Extras/blob/master/bucket/webview2.json + $version = '145.0.3800.65' $archMap = @{ 'x86_64' = 'x64'; 'aarch64' = 'arm64' } - $matrixArch = '${{ matrix.arch }}' - if (-not $archMap.ContainsKey($matrixArch)) { - throw "Unsupported architecture: $matrixArch" + $guidMap = @{ + 'x64' = 'c411606c-d282-4304-8420-8ae6b1dd3e9a' + 'arm64' = '2d2cf37b-d24c-4c72-b5bc-e8061e7a7583' } - $arch = $archMap[$matrixArch] - $version = '133.0.3065.92' + $arch = $archMap['${{ matrix.arch }}'] + $guid = $guidMap[$arch] $cabName = "Microsoft.WebView2.FixedVersionRuntime.$version.$arch.cab" - $uri = "https://github.com/westinyang/WebView2RuntimeArchive/releases/download/$version/$cabName" + $uri = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/$guid/$cabName" - Write-Host "Downloading $cabName ..." + Write-Host "Downloading $cabName from Microsoft CDN ..." Invoke-WebRequest -Uri $uri -OutFile $cabName $tempDir = "temp_wv2" From 34610f8d7fed3de5e50f74154408209ed33b40f2 Mon Sep 17 00:00:00 2001 From: Rbqwow <55343783+Rbqwow@users.noreply.github.com> Date: Thu, 19 Feb 2026 21:45:29 +0800 Subject: [PATCH 8/9] build: review 4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 讲真我感觉用不上加 但这就是vibe coding的魅力 --- .github/workflows/build.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 729fea3..a3bc20c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -145,17 +145,23 @@ jobs: $uri = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/$guid/$cabName" Write-Host "Downloading $cabName from Microsoft CDN ..." - Invoke-WebRequest -Uri $uri -OutFile $cabName + Invoke-WebRequest -Uri $uri -OutFile $cabName -ErrorAction Stop $tempDir = "temp_wv2" New-Item -ItemType Directory -Force -Path $tempDir | Out-Null expand.exe $cabName -F:* $tempDir + if ($LASTEXITCODE -ne 0) { + throw "Failed to extract $cabName with exit code $LASTEXITCODE" + } $dest = "install\webview2_runtime" New-Item -ItemType Directory -Force -Path $dest | Out-Null # cab 解压后文件在版本子目录中,将其内容移动到 webview2_runtime/ $versionDir = Get-ChildItem $tempDir -Directory | Where-Object { $_.Name -like "Microsoft.WebView2*" } | Select-Object -First 1 + if (-not $versionDir -and (Get-ChildItem $tempDir).Count -eq 0) { + throw "No files found after extracting $cabName" + } if ($versionDir) { Copy-Item -Path "$($versionDir.FullName)\*" -Destination $dest -Recurse -Force -ErrorAction Stop } else { From 2d644dcd8d1fe57878a37b213678661d42ddb0f1 Mon Sep 17 00:00:00 2001 From: Rbqwow <55343783+Rbqwow@users.noreply.github.com> Date: Thu, 19 Feb 2026 21:57:53 +0800 Subject: [PATCH 9/9] build: review Update src-tauri/src/main.rs Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- src-tauri/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 07bc545..acc441b 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -18,7 +18,7 @@ fn main() { // 检测内置的 WebView2 固定版本运行时 let webview2_runtime_dir = exe_dir.join("webview2_runtime"); - if webview2_runtime_dir.exists() { + if webview2_runtime_dir.is_dir() { std::env::set_var( "WEBVIEW2_BROWSER_EXECUTABLE_FOLDER", &webview2_runtime_dir,