$ErrorActionPreference = 'Stop' $pluginManagerPath = "$env:LOCALAPPDATA\.dartServer\.plugin_manager" $junctionTarget = "C:\DartPluginCache" Write-Output "=== Dart AOT 中文路径修复工具 ===" Write-Output "" Write-Output "问题: 用户路径包含中文字符导致 Dart 分析器 AOT 编译失败" Write-Output " 当前路径: $pluginManagerPath" Write-Output " 目标路径: $junctionTarget" Write-Output "" if (!(Test-Path $junctionTarget)) { New-Item -ItemType Directory -Path $junctionTarget -Force | Out-Null Write-Output "[1/3] 创建目标目录: $junctionTarget" } else { Write-Output "[1/3] 目标目录已存在: $junctionTarget" } if (Test-Path $pluginManagerPath) { $isJunction = (Get-Item $pluginManagerPath).Attributes -band [IO.FileAttributes]::ReparsePoint if ($isJunction) { Write-Output "[2/3] 联接已存在,跳过" } else { $backupPath = "$pluginManagerPath.bak" if (Test-Path $backupPath) { Remove-Item -Recurse -Force $backupPath } Move-Item -Path $pluginManagerPath -Destination $backupPath -Force Write-Output "[2/3] 备份原目录到: $backupPath" New-Item -ItemType Junction -Path $pluginManagerPath -Target $junctionTarget | Out-Null Write-Output "[2/3] 创建联接: $pluginManagerPath -> $junctionTarget" } } else { $parentDir = Split-Path $pluginManagerPath -Parent if (!(Test-Path $parentDir)) { New-Item -ItemType Directory -Path $parentDir -Force | Out-Null } New-Item -ItemType Junction -Path $pluginManagerPath -Target $junctionTarget | Out-Null Write-Output "[2/3] 创建联接: $pluginManagerPath -> $junctionTarget" } Write-Output "[3/3] 修复完成!" Write-Output "" Write-Output "请重启 VS Code / IDE 使更改生效"