build(windows): 可执行文件改为 YuChuan.exe,嵌入新图标,修正版本资源

- windows/CMakeLists.txt: BINARY_NAME rust_flutter_ui -> YuChuan
  (CMake 的 target 名不支持非 ASCII,写「雨传」会直接报
   Cannot specify compile definitions for target 雨传 which is not built,
   所以构建名用 ASCII,发布时由 package_release.ps1 改名为「雨传.exe」)
- windows/runner/CMakeLists.txt: 加 /utf-8 —— main.cpp 是无 BOM 的 UTF-8,
  不指定的话 MSVC 按系统代码页(GBK)读,中文字面量会变乱码
- windows/runner/main.cpp: 原生窗口标题 YuChuan -> 雨传 YuChuan
- windows/runner/Runner.rc: 版本资源补齐/修正
  FileDescription -> 雨传 YuChuan - 局域网聊天 / 传文件工具
  ProductName/InternalName/OriginalFilename -> 雨传
  LegalCopyright 去掉模板残留的 com.example
- scripts: 同步 exe 名;新增 package_release.ps1(便携版 zip + 安卓包)

说明:图标是编译期嵌进二进制的,改图标必须重新构建(本机无 rcedit/
ResourceHacker 之类可直接改 exe 资源的工具)。
This commit is contained in:
WT810787899 committed 2026-10-15 21:02:41 +08:00
1 parent bdb21d5fca
commit 2dd286f64a
9 files changed
+111 -9

No files matched your search

+3
View File
@@ -90,3 +90,6 @@ icon.psd
/修bug.md
/核验.MD
/scripts/verify_offline_send.md
# 发布产物(可重新生成,不进仓库)
/dist/
+2
View File
@@ -38,6 +38,8 @@ cargo build --manifest-path rust_builder\Cargo.toml --target x86_64-pc-windows-m
if errorlevel 1 goto :err
echo [3/3] Flutter build...
REM Kill a running instance so MSVC can overwrite the exe (otherwise LINK : fatal error LNK1104)
chcp 65001 >nul 2>&1
taskkill /f /im 雨传.exe >nul 2>&1
taskkill /f /im rust_flutter_ui.exe >nul 2>&1
call "%FLUTTER_BIN%" build windows 2>&1
if errorlevel 1 goto :err
+1 -1
View File
@@ -20,4 +20,4 @@ Start-Sleep -Seconds 1
& flutter build windows
if ($LASTEXITCODE -ne 0) { throw 'flutter build windows failed' }
Write-Host "OK: $root\build\windows\x64\runner\Release\rust_flutter_ui.exe"
Write-Host "OK: $root\build\windows\x64\runner\Release\雨传.exe"
+87
View File
@@ -0,0 +1,87 @@
# 打包发布产物:Windows 便携版 zip + 安卓安装包。
#
# 用法:
# .\scripts\package_release.ps1 # 版本取 pubspec.yaml
# .\scripts\package_release.ps1 -Version 1.0.1
#
# 前置:先跑过构建
# .\scripts\build_windows.ps1 # 产出 build\windows\x64\runner\Release\
# .\scripts\build_apk.ps1 # 产出 build\app\outputs\flutter-apk\app-release.apk
#
# 为什么在这里把 exe 改名成「雨传.exe」:
# CMake 的 target 名不支持非 ASCII(写 "雨传" 会直接报
# `Cannot specify compile definitions for target "雨传" which is not built`),
# 所以构建产物是 ASCII 的 YuChuan.exe,发布时再改成中文名。
# 改名不影响运行:runner 是按自身所在目录去找 data\ 和各个 dll 的。
param(
[string]$Version = "",
[string]$DistDir = "dist"
)
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $PSScriptRoot
Set-Location $root
# ---- 版本号:默认读 pubspec.yaml 的 version(去掉 +build 后缀)----
if (-not $Version) {
$line = Select-String -Path "pubspec.yaml" -Pattern '^version:\s*(\S+)' | Select-Object -First 1
if (-not $line) { throw "pubspec.yaml 里读不到 version" }
$Version = ($line.Matches[0].Groups[1].Value -split '\+')[0]
}
Write-Host "版本:$Version"
$stageName = "雨传"
$exeAscii = "YuChuan.exe"
$exeCjk = "雨传.exe"
# ---- 校验前置产物 ----
$winRel = "build\windows\x64\runner\Release"
if (-not (Test-Path "$winRel\$exeAscii")) {
throw "找不到 $winRel\$exeAscii —— 先跑 .\scripts\build_windows.ps1"
}
$apkSrc = "build\app\outputs\flutter-apk\app-release.apk"
if (-not (Test-Path $apkSrc)) {
throw "找不到 $apkSrc —— 先跑 .\scripts\build_apk.ps1"
}
# ---- 暂存 Windows 便携版 ----
New-Item -ItemType Directory -Force -Path $DistDir | Out-Null
$stage = Join-Path $DistDir $stageName
if (Test-Path $stage) { Remove-Item -Recurse -Force $stage }
New-Item -ItemType Directory -Force -Path $stage | Out-Null
Copy-Item -Recurse -Force "$winRel\*" $stage
# exe 改中文名
Move-Item -Force (Join-Path $stage $exeAscii) (Join-Path $stage $exeCjk)
# 附一份使用说明,便携版解压后一眼能看到
$readme = @"
雨传 YuChuan $Version · Windows 便携版
直接双击「$exeCjk」运行,无需安装。
整个文件夹可以放到任意位置(U 盘也行),删掉即卸载。
同一局域网内打开手机端雨传,两端会自动互相发现,配对一次即可互传文件。
"@
Set-Content -Path (Join-Path $stage "使用说明.txt") -Value $readme -Encoding UTF8
# ---- 打 zip ----
$zip = Join-Path $DistDir "雨传-$Version-windows-portable.zip"
if (Test-Path $zip) { Remove-Item -Force $zip }
Compress-Archive -Path $stage -DestinationPath $zip -CompressionLevel Optimal
# ---- 安卓安装包 ----
$apkDst = Join-Path $DistDir "雨传-$Version-android.apk"
Copy-Item -Force $apkSrc $apkDst
# ---- 汇报 ----
Write-Host ""
Write-Host "产物:"
foreach ($f in @($zip, $apkDst)) {
$i = Get-Item $f
Write-Host (" {0} {1:N2} MB" -f $i.Name, ($i.Length / 1MB))
}
Write-Host ""
Write-Host "zip 内含顶层目录:$stageName\"
Get-ChildItem $stage | ForEach-Object { Write-Host " $($_.Name)" }
+1 -1
View File
@@ -5,7 +5,7 @@
param([int]$WaitSeconds = 20)
$ErrorActionPreference = 'Continue'
$root = Split-Path $PSScriptRoot -Parent
$exe = "$root\build\windows\x64\runner\Release\rust_flutter_ui.exe"
$exe = "$root\build\windows\x64\runner\Release\雨传.exe"
if (-not (Test-Path $exe)) { throw '先构建:.\scripts\build_windows.ps1' }
$temp = $env:TEMP
+6 -1
View File
@@ -4,7 +4,12 @@ project(rust_flutter_ui LANGUAGES CXX)
# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
set(BINARY_NAME "rust_flutter_ui")
#
# 必须是 ASCII:CMake 的 target 名不支持非 ASCII,写成 "雨传" 会直接报
# `Cannot specify compile definitions for target "雨传" which is not built`。
# 发布版里那个「雨传.exe」是由打包脚本重命名得到的(见 scripts/build_windows.ps1),
# 这样 `flutter run -d windows` 也仍然能按 ASCII 名找到可执行文件。
set(BINARY_NAME "YuChuan")
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
+5
View File
@@ -30,6 +30,11 @@ target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTT
# Disable Windows macros that collide with C++ standard library functions.
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
# 源码里有中文字面量(窗口标题、资源字符串),强制 MSVC 按 UTF-8 读源码。
# 不加这个,MSVC 会按系统代码页(本机 GBK)解释,中文会变成乱码,
# 而且 main.cpp 是无 BOM 的 UTF-8,靠 BOM 识别并不可靠。
target_compile_options(${BINARY_NAME} PRIVATE "/utf-8")
# Add dependency libraries and include directories. Add any application-specific
# dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
+5 -5
View File
@@ -90,12 +90,12 @@ BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "YuChuan" "\0"
VALUE "FileDescription", "YuChuan - LAN Chat" "\0"
VALUE "FileDescription", "雨传 YuChuan - 局域网聊天 / 传文件工具" "\0"
VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "rust_flutter_ui" "\0"
VALUE "LegalCopyright", "Copyright (C) 2026 com.example. All rights reserved." "\0"
VALUE "OriginalFilename", "rust_flutter_ui.exe" "\0"
VALUE "ProductName", "YuChuan" "\0"
VALUE "InternalName", "雨传" "\0"
VALUE "LegalCopyright", "Copyright (C) 2026 WT810787899" "\0"
VALUE "OriginalFilename", "雨传.exe" "\0"
VALUE "ProductName", "雨传 YuChuan" "\0"
VALUE "ProductVersion", VERSION_AS_STRING "\0"
END
END
+1 -1
View File
@@ -27,7 +27,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
FlutterWindow window(project);
Win32Window::Point origin(10, 10);
Win32Window::Size size(1280, 720);
if (!window.Create(L"YuChuan", origin, size)) {
if (!window.Create(L"雨传 YuChuan", origin, size)) {
return EXIT_FAILURE;
}
window.SetQuitOnClose(true);