# server/games/erqiwang/shared/ -> client/js/01_SubGame/codes/shared/ 单向同步 # 【只有这一个方向】权威源在服务端,前端副本只读;前端的本地改动会被本脚本覆盖。 $ErrorActionPreference = 'Stop' $root = Split-Path -Parent $MyInvocation.MyCommand.Path $src = Join-Path $root 'server\games\erqiwang\shared' $dst = Join-Path $root 'client\js\01_SubGame\codes\shared' if (-not (Test-Path $src)) { Write-Error "源目录不存在: $src"; exit 1 } if (-not (Test-Path $dst)) { New-Item -ItemType Directory -Path $dst -Force | Out-Null } $files = Get-ChildItem -Path $src -Filter *.js -File if ($files.Count -eq 0) { Write-Error "源目录没有 .js 文件: $src"; exit 1 } foreach ($f in $files) { Copy-Item -Path $f.FullName -Destination (Join-Path $dst $f.Name) -Force Write-Host ("同步: " + $f.Name) } Write-Host ("完成,共 " + $files.Count + " 个文件 -> " + $dst)