fix: pack i18n
This commit is contained in:
@@ -56,4 +56,6 @@ save:
|
||||
|
||||
frontend:
|
||||
water_speed: low
|
||||
cloud_freq: low
|
||||
cloud_freq: low
|
||||
system:
|
||||
language: zh-CN
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# Locate repository root directory
|
||||
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
@@ -61,7 +61,7 @@ if (Test-Path $WebDir) {
|
||||
# Entry and app name
|
||||
# CHANGED: Use server main.py instead of run.py
|
||||
$EntryPy = Join-Path $RepoRoot "src\server\main.py"
|
||||
$AppName = "AI修仙模拟器"
|
||||
$AppName = "AI" + [char]0x4fee + [char]0x4ed9 + [char]0x6a21 + [char]0x62df + [char]0x5668
|
||||
|
||||
if (-not (Test-Path $EntryPy)) {
|
||||
Write-Error "Entry script not found: $EntryPy"
|
||||
@@ -83,6 +83,7 @@ $AdditionalHooksPath = $ScriptDir
|
||||
|
||||
# Source path
|
||||
$SrcPath = Join-Path $RepoRoot "src"
|
||||
$I18nLocalesPath = Join-Path $SrcPath "i18n\locales"
|
||||
|
||||
# Assemble PyInstaller arguments
|
||||
$argsList = @(
|
||||
@@ -101,6 +102,7 @@ $argsList = @(
|
||||
|
||||
# Data Files
|
||||
"--add-data", "${AssetsPath};assets", # Game Assets (Images) -> _internal/assets
|
||||
"--add-data", "${I18nLocalesPath};src/i18n/locales", # i18n Locales -> _internal/src/i18n/locales
|
||||
# REMOVED: "--add-data", "${WebDistDir};web_dist", (We will copy this manually to outside)
|
||||
"--add-data", "${StaticPath};static", # Configs -> _internal/static (backup)
|
||||
|
||||
@@ -145,58 +147,70 @@ if (Test-Path $IconPath) {
|
||||
# Call PyInstaller
|
||||
Push-Location $RepoRoot
|
||||
try {
|
||||
$ErrorActionPreference = "Continue" # 允许继续执行即使有错误
|
||||
Write-Host "Executing PyInstaller..."
|
||||
& pyinstaller @argsList
|
||||
$ErrorActionPreference = "Stop" # 恢复错误停止设置
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "PyInstaller execution failed with exit code $LASTEXITCODE. Please check the error logs above."
|
||||
}
|
||||
$BuildSuccess = $true
|
||||
} catch {
|
||||
Write-Error "Build failed: $_"
|
||||
exit 1
|
||||
} finally {
|
||||
Pop-Location
|
||||
|
||||
# 在 finally 块中执行后续操作,确保一定会执行
|
||||
Write-Host "`n=== Post-build processing ===" -ForegroundColor Green
|
||||
|
||||
$ExeDir = Join-Path $DistDir $AppName
|
||||
|
||||
# Copy static to exe directory (Config needs to be next to exe for CWD access)
|
||||
if (Test-Path $ExeDir) {
|
||||
# NOTE: We DO NOT copy 'assets' to root anymore. They are inside _internal via --add-data.
|
||||
if ($BuildSuccess) {
|
||||
Write-Host "`n=== Post-build processing ===" -ForegroundColor Green
|
||||
|
||||
if (Test-Path $StaticPath) {
|
||||
Copy-Item -Path $StaticPath -Destination $ExeDir -Recurse -Force
|
||||
# 删除 local_config.yml
|
||||
$LocalConfigPath = Join-Path $ExeDir "static\local_config.yml"
|
||||
if (Test-Path $LocalConfigPath) {
|
||||
Remove-Item -Path $LocalConfigPath -Force
|
||||
Write-Host "✓ Copied static to exe directory (excluded local_config.yml)" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "✓ Copied static to exe directory" -ForegroundColor Green
|
||||
$ExeDir = Join-Path $DistDir $AppName
|
||||
|
||||
# Copy static to exe directory (Config needs to be next to exe for CWD access)
|
||||
if (Test-Path $ExeDir) {
|
||||
# NOTE: We DO NOT copy 'assets' to root anymore. They are inside _internal via --add-data.
|
||||
|
||||
if (Test-Path $StaticPath) {
|
||||
Copy-Item -Path $StaticPath -Destination $ExeDir -Recurse -Force
|
||||
# 删除 local_config.yml
|
||||
$LocalConfigPath = Join-Path $ExeDir "static\local_config.yml"
|
||||
if (Test-Path $LocalConfigPath) {
|
||||
Remove-Item -Path $LocalConfigPath -Force
|
||||
Write-Host "✓ Copied static to exe directory (excluded local_config.yml)" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "✓ Copied static to exe directory" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# 清理 _internal 中的 local_config.yml (防止敏感信息泄露)
|
||||
$InternalLocalConfigPath = Join-Path $ExeDir "_internal\static\local_config.yml"
|
||||
if (Test-Path $InternalLocalConfigPath) {
|
||||
Remove-Item -Path $InternalLocalConfigPath -Force
|
||||
Write-Host "✓ Removed sensitive local_config.yml from _internal" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Copy Web Dist to exe directory (Manual copy instead of PyInstaller bundle)
|
||||
if (Test-Path $WebDistDir) {
|
||||
$DestWeb = Join-Path $ExeDir "web_static"
|
||||
Copy-Item -Path $WebDistDir -Destination $DestWeb -Recurse -Force
|
||||
Write-Host "✓ Copied web_dist to web_static in exe directory" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
# Clean up build and spec directories (delete entire directories)
|
||||
$BuildDirRoot = Join-Path $RepoRoot "tmp\build"
|
||||
if (Test-Path $BuildDirRoot) {
|
||||
Remove-Item -Path $BuildDirRoot -Recurse -Force
|
||||
Write-Host "✓ Deleted entire build directory: $BuildDirRoot" -ForegroundColor Green
|
||||
}
|
||||
# 清理 _internal 中的 local_config.yml (防止敏感信息泄露)
|
||||
$InternalLocalConfigPath = Join-Path $ExeDir "_internal\static\local_config.yml"
|
||||
if (Test-Path $InternalLocalConfigPath) {
|
||||
Remove-Item -Path $InternalLocalConfigPath -Force
|
||||
Write-Host "✓ Removed sensitive local_config.yml from _internal" -ForegroundColor Green
|
||||
}
|
||||
|
||||
Write-Host "`n=== Package completed ===" -ForegroundColor Cyan
|
||||
Write-Host "Distribution directory: " (Resolve-Path $DistDir).Path
|
||||
if (Test-Path $ExeDir) {
|
||||
Write-Host "Executable directory: " (Resolve-Path $ExeDir).Path
|
||||
# Copy Web Dist to exe directory (Manual copy instead of PyInstaller bundle)
|
||||
if (Test-Path $WebDistDir) {
|
||||
$DestWeb = Join-Path $ExeDir "web_static"
|
||||
Copy-Item -Path $WebDistDir -Destination $DestWeb -Recurse -Force
|
||||
Write-Host "✓ Copied web_dist to web_static in exe directory" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Clean up build and spec directories (delete entire directories)
|
||||
$BuildDirRoot = Join-Path $RepoRoot "tmp\build"
|
||||
if (Test-Path $BuildDirRoot) {
|
||||
Remove-Item -Path $BuildDirRoot -Recurse -Force
|
||||
Write-Host "✓ Deleted entire build directory: $BuildDirRoot" -ForegroundColor Green
|
||||
}
|
||||
|
||||
Write-Host "`n=== Package completed ===" -ForegroundColor Cyan
|
||||
Write-Host "Distribution directory: " (Resolve-Path $DistDir).Path
|
||||
if (Test-Path $ExeDir) {
|
||||
Write-Host "Executable directory: " (Resolve-Path $ExeDir).Path
|
||||
}
|
||||
} else {
|
||||
Write-Error "Build finished but executable directory not found at $ExeDir"
|
||||
}
|
||||
} else {
|
||||
Write-Warning "Build failed. Keeping build directory for debugging."
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user