# 清理Electron缓存和用户数据脚本 # 用于修复 "Unable to move the cache: 拒绝访问" 错误 Write-Host "🔧 开始清理Electron缓存和用户数据..." -ForegroundColor Yellow # 获取当前用户的应用数据路径 $userDataPath = "$env:APPDATA\gofaster" $localDataPath = "$env:LOCALAPPDATA\gofaster" Write-Host "用户数据路径: $userDataPath" -ForegroundColor Cyan Write-Host "本地数据路径: $localDataPath" -ForegroundColor Cyan # 定义需要清理的目录 $cacheDirs = @( "$userDataPath\Cache", "$userDataPath\Code Cache", "$userDataPath\GPUCache", "$userDataPath\Session Storage", "$userDataPath\Local Storage", "$localDataPath\Cache", "$localDataPath\Code Cache", "$localDataPath\GPUCache" ) # 清理缓存目录 foreach ($dir in $cacheDirs) { if (Test-Path $dir) { try { Write-Host "正在清理: $dir" -ForegroundColor Green Remove-Item -Path $dir -Recurse -Force -ErrorAction Stop Write-Host "✅ 已清理: $dir" -ForegroundColor Green } catch { Write-Host "⚠️ 清理失败: $dir - $($_.Exception.Message)" -ForegroundColor Yellow } } else { Write-Host "目录不存在: $dir" -ForegroundColor Gray } } # 清理可能存在的其他缓存文件 $cacheFiles = @( "$userDataPath\*.log", "$userDataPath\*.tmp", "$userDataPath\*.cache" ) foreach ($pattern in $cacheFiles) { try { $files = Get-ChildItem -Path $pattern -ErrorAction SilentlyContinue foreach ($file in $files) { Remove-Item -Path $file.FullName -Force -ErrorAction Stop Write-Host "✅ 已清理文件: $($file.Name)" -ForegroundColor Green } } catch { Write-Host "⚠️ 清理文件失败: $pattern - $($_.Exception.Message)" -ForegroundColor Yellow } } Write-Host "✅ Electron缓存清理完成!" -ForegroundColor Green Write-Host "现在可以重新启动应用程序了。" -ForegroundColor Cyan # 询问是否立即启动应用 $startApp = Read-Host "是否立即启动应用程序? (y/n)" if ($startApp -eq 'y' -or $startApp -eq 'Y') { Write-Host "正在启动应用程序..." -ForegroundColor Yellow Set-Location "app" .\dev-enhanced.ps1 }