Windows 环境 Pake 打包网页为 EXE

Pake 是一个将网页快速打包成桌面应用程序的工具,基于 Rust 和 Tauri 框架,打包后的应用体积小、性能好。

安装 Node.js
https://nodejs.org/zh-cn/download

再安装PaKe

npm install -g pake-cli

 

打包报错,容易踩坑 
setup_rust_env.ps1

# setup_rust_env.ps1
# 查找 link.exe 和 lib,写入系统环境变量

# 需要管理员权限
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
if (-not $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
    Write-Host "请以管理员身份运行" -ForegroundColor Red
    exit 1
}

Write-Host "正在查找编译工具..." -ForegroundColor Cyan

# 查找 link.exe
$linkPaths = Get-ChildItem -Path "C:\Program Files\Microsoft Visual Studio" -Filter "link.exe" -Recurse -ErrorAction SilentlyContinue | 
             Select-Object -ExpandProperty FullName

if ($linkPaths.Count -eq 0) {
    Write-Host "错误: 未找到 link.exe" -ForegroundColor Red
    Write-Host "请安装 Visual Studio Build Tools" -ForegroundColor Yellow
    exit 1
}

$selectedLink = $linkPaths | Where-Object { $_ -match 'x64|amd64' } | Select-Object -First 1
if (-not $selectedLink) { $selectedLink = $linkPaths[0] }
$linkDir = $selectedLink | Split-Path -Parent
Write-Host "找到 link.exe: $selectedLink" -ForegroundColor Green

# 查找 kernel32.lib
$kernel32Paths = Get-ChildItem -Path "C:\Program Files (x86)\Windows Kits" -Filter "kernel32.lib" -Recurse -ErrorAction SilentlyContinue | 
                 Select-Object -ExpandProperty FullName

if ($kernel32Paths.Count -eq 0) {
    Write-Host "错误: 未找到 kernel32.lib" -ForegroundColor Red
    Write-Host "请安装 Windows SDK" -ForegroundColor Yellow
    exit 1
}

$kernel32Path = $kernel32Paths | Where-Object { $_ -match '\\x64\\' } | Select-Object -First 1
if (-not $kernel32Path) { $kernel32Path = $kernel32Paths[0] }
$libDir = $kernel32Path | Split-Path -Parent
Write-Host "找到 LIB 目录: $libDir" -ForegroundColor Green

# 写入系统环境变量
Write-Host "`n正在更新系统环境变量..." -ForegroundColor Cyan
$oldPath = [Environment]::GetEnvironmentVariable('PATH', 'Machine')
if (-not ($oldPath -split ';' -contains $linkDir)) {
    $newPath = "$linkDir;$oldPath"
    [Environment]::SetEnvironmentVariable('PATH', $newPath, 'Machine')
    Write-Host "已添加 $linkDir 到系统 PATH" -ForegroundColor Green
}

[Environment]::SetEnvironmentVariable('LIB', $libDir, 'Machine')
Write-Host "已设置 LIB=$libDir" -ForegroundColor Green

# 更新当前进程
$env:PATH = "$linkDir;$env:PATH"
$env:LIB = $libDir

Write-Host "`n配置完成!" -ForegroundColor Green
Write-Host "请重新启动终端或资源管理器使环境变量生效" -ForegroundColor Yellow

  

ChatGPT.bat

@echo off
set "URL=https://chatgpt.com"
set "NAME=ChatGPT"
set "ICON=chatgpt_256.ico"

echo 正在构建应用程序...
call pake "%URL%" --name "%NAME%" --width 1200 --height 800 --icon "%ICON%" --targets exe

echo 构建完成,正在复制文件...
if exist "%USERPROFILE%\AppData\Roaming\npm\node_modules\pake-cli\src-tauri\target\x86_64-pc-windows-msvc\release\pake-%NAME%.exe" (
    copy "%USERPROFILE%\AppData\Roaming\npm\node_modules\pake-cli\src-tauri\target\x86_64-pc-windows-msvc\release\pake-%NAME%.exe" "%NAME%.exe"
    echo 文件复制完成!
) else (
    echo 错误:找不到生成的EXE文件!
    echo 请检查路径: %USERPROFILE%\AppData\Roaming\npm\node_modules\pake-cli\src-tauri\target\x86_64-pc-windows-msvc\release\pake-%NAME%.exe
)

pause

  

DeepSeeK.bat

@echo off
set "URL=https://chat.deepseek.com"
set "NAME=DeepSeek"
set "ICON=deepseek_256.ico"

echo 正在构建应用程序...
call pake "%URL%" --name "%NAME%" --width 1200 --height 800 --icon "%ICON%" --targets exe

echo 构建完成,正在复制文件...
if exist "%USERPROFILE%\AppData\Roaming\npm\node_modules\pake-cli\src-tauri\target\x86_64-pc-windows-msvc\release\pake-%NAME%.exe" (
    copy "%USERPROFILE%\AppData\Roaming\npm\node_modules\pake-cli\src-tauri\target\x86_64-pc-windows-msvc\release\pake-%NAME%.exe" "%NAME%.exe"
    echo 文件复制完成!
) else (
    echo 错误:找不到生成的EXE文件!
    echo 请检查路径: %USERPROFILE%\AppData\Roaming\npm\node_modules\pake-cli\src-tauri\target\x86_64-pc-windows-msvc\release\pake-%NAME%.exe
)

pause

  

 

 

 

posted @ 2026-01-14 10:56  懒人境界  阅读(0)  评论(0)    收藏  举报