You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.7 KiB
57 lines
1.7 KiB
# 前端启动脚本 - 解决中文编码问题 |
|
param( |
|
[switch]$Debug, |
|
[switch]$Watch |
|
) |
|
|
|
# 强制设置控制台编码 |
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 |
|
[Console]::InputEncoding = [System.Text.Encoding]::UTF8 |
|
$OutputEncoding = [System.Text.Encoding]::UTF8 |
|
|
|
# 设置环境变量 |
|
$env:VUE_CLI_BABEL_TRANSPILE_MODULES = "false" |
|
$env:VUE_CLI_MODERN_BUILD = "false" |
|
$env:VUE_CLI_LOG_LEVEL = "info" |
|
$env:VUE_CLI_DEBUG = "true" |
|
$env:LANG = "zh_CN.UTF-8" |
|
$env:LC_ALL = "zh_CN.UTF-8" |
|
$env:NODE_OPTIONS = "--max-old-space-size=4096" |
|
$env:CHROME_BIN = "C:\Program Files\Google\Chrome\Application\chrome.exe" |
|
|
|
# Windows 特定编码设置 |
|
$env:PYTHONIOENCODING = "utf-8" |
|
$env:PYTHONLEGACYWINDOWSSTDIO = "utf-8" |
|
|
|
Write-Host "Starting Frontend Development Environment (UTF-8 Optimized)..." -ForegroundColor Cyan |
|
Write-Host "Encoding: UTF-8" -ForegroundColor Green |
|
Write-Host "Log Level: INFO" -ForegroundColor Green |
|
Write-Host "Hot Reload: Enabled" -ForegroundColor Green |
|
Write-Host "" |
|
|
|
# Select startup mode |
|
$script = if ($Debug) { "npm run dev:debug" } elseif ($Watch) { "npm run dev:watch" } else { "npm run dev" } |
|
|
|
Write-Host "Startup Command: $script" -ForegroundColor Yellow |
|
Write-Host "" |
|
|
|
# Start frontend |
|
try { |
|
Invoke-Expression $script |
|
} catch { |
|
Write-Host "Startup failed: $($_.Exception.Message)" -ForegroundColor Red |
|
Write-Host "Trying fallback startup method..." -ForegroundColor Yellow |
|
|
|
# Fallback startup method |
|
if ($Debug) { |
|
npm run dev:debug |
|
} elseif ($Watch) { |
|
npm run dev:watch |
|
} else { |
|
npm run dev |
|
} |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "Press any key to exit..." |
|
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
|
|