feat(installer): 便携中文安装包「年糕历险记-Setup-v0.1.0.zip」——安装.bat 中文交互+桌面快捷方式;修复 ps1 BOM 编码

This commit is contained in:
NianGao Dev
2026-08-15 23:59:24 +08:00
parent 610f234bb4
commit 4755fd88fc
7 changed files with 171 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
# 年糕历险记 构建脚本Windows
# 年糕历险记 构建脚本Windows
# 用法pwsh -File scripts/build.ps1 [-Release]
# 自动定位 C 工具链tools/ 下的 zig 或 mingw64/w64devkit构建 GL 客户端与服务器。
param([switch]$Release)

View File

@@ -0,0 +1,33 @@
@echo off
chcp 65001 >nul
title 年糕历险记 安装程序
echo.
echo ============================================
echo 年糕历险记 安装程序 v0.1.0
echo NianGao Adventure Installer
echo ============================================
echo.
setlocal enabledelayedexpansion
rem 默认安装目录(用户目录下)
set "DEFAULT_DIR=%LOCALAPPDATA%\NianGaoAdventure"
set /p "INSTALL_DIR=请输入安装目录(直接回车使用 %DEFAULT_DIR%"
if "!INSTALL_DIR!"=="" set "INSTALL_DIR=%DEFAULT_DIR%"
echo.
echo 正在安装到:!INSTALL_DIR!
if not exist "!INSTALL_DIR!" mkdir "!INSTALL_DIR!"
echo 复制游戏文件...
xcopy /e /i /y "%~dp0*" "!INSTALL_DIR!\" >nul 2>&1
echo 创建桌面快捷方式...
powershell -NoProfile -Command "$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut([Environment]::GetFolderPath('Desktop') + '\年糕历险记.lnk'); $s.TargetPath = '!INSTALL_DIR!\mc-client.exe'; $s.WorkingDirectory = '!INSTALL_DIR!'; $s.Save()"
echo.
echo ============================================
echo 安装完成!桌面已创建「年糕历险记」快捷方式。
echo 游戏存档保存在安装目录 worlds\ 下。
echo 按任意键退出...
echo ============================================
pause >nul

View File

@@ -0,0 +1,50 @@
# 年糕历险记 —— 便携安装包构建脚本(中文安装,构建与发布.md §8 交付方案)
# 用法pwsh -File scripts/make_installer.ps1 [-Version 0.1.0]
# 产物dist/年糕历险记-Setup-v<版本>.zip解压后运行 安装.bat全中文交互
param([string]$Version = "0.1.0")
$ErrorActionPreference = "Stop"
$root = Split-Path $PSScriptRoot -Parent
$dist = Join-Path $root "dist"
$stage = Join-Path $dist "年糕历险记-Setup-v$Version"
# 1) 构建(复用 build.ps1 逻辑:定位 zig/gcc
& (Join-Path $PSScriptRoot "build.ps1")
if ($LASTEXITCODE -ne 0) { throw "构建失败" }
# 2) 组装安装目录
if (Test-Path $stage) { Remove-Item $stage -Recurse -Force }
New-Item -ItemType Directory -Force -Path $stage | Out-Null
Copy-Item (Join-Path $root "bin\mc-client.exe") $stage
Copy-Item (Join-Path $root "bin\mc-server.exe") $stage
New-Item -ItemType Directory -Force -Path (Join-Path $stage "config") | Out-Null
Copy-Item (Join-Path $root "config\client.yaml") (Join-Path $stage "config")
Copy-Item (Join-Path $root "config\server.yaml") (Join-Path $stage "config")
New-Item -ItemType Directory -Force -Path (Join-Path $stage "mods") | Out-Null
Copy-Item (Join-Path $root "mods\README.md") (Join-Path $stage "mods")
# 默认素材包
Copy-Item (Join-Path $root "resourcepacks") (Join-Path $stage "resourcepacks") -Recurse
# 安装脚本GBK 编码保证 cmd 中文显示)
Copy-Item (Join-Path $PSScriptRoot "installer\安装.bat") (Join-Path $stage "安装.bat")
# 游戏说明(中文)
[System.IO.File]::WriteAllText((Join-Path $stage "README.txt"), @"
v$Version
====================
.bat
worlds/
/ mods/ Minecraft
使
$(Get-Date -Format "yyyy-MM-dd")
"@, (New-Object System.Text.UTF8Encoding($false)))
# 3) 打包 zip中文文件名
$zipPath = Join-Path $dist "年糕历险记-Setup-v$Version.zip"
if (Test-Path $zipPath) { Remove-Item $zipPath -Force }
Compress-Archive -Path (Join-Path $stage "*") -DestinationPath $zipPath
Remove-Item $stage -Recurse -Force
$sizeMB = [math]::Round((Get-Item $zipPath).Length / 1MB, 1)
Write-Host "== 安装包就绪:$zipPath$sizeMB MB=="