feat: 全面优化用户界面和操作流程 1.统一所有弹窗界面风格 2.优化禁用更新/突破限制/刷新授权的操作流程 3.增加复制命令按钮功能 4.改进错误提示和操作指引 5.提升整体操作流畅度

This commit is contained in:
huangzhenpc
2025-02-14 20:44:16 +08:00
parent 26e159d71c
commit ae698796e7
9 changed files with 945 additions and 509 deletions

83
disable_update.ps1 Normal file
View File

@@ -0,0 +1,83 @@
# 检查管理员权限
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Host "`n[错误] 请以管理员身份运行此脚本" -ForegroundColor Red
Write-Host "请使用 'Start-Process pwsh -Verb RunAs' 启动管理员PowerShell" -ForegroundColor Yellow
Pause
exit
}
Write-Host "`n=== Cursor更新禁用工具 ===" -ForegroundColor Cyan
# 定义路径
$updaterPath = Join-Path $env:LOCALAPPDATA "cursor-updater"
$cursorPath = Join-Path $env:LOCALAPPDATA "Programs\cursor"
$packageJsonPath = Join-Path $cursorPath "resources\app\package.json"
Write-Host "`n正在检查路径..." -ForegroundColor Gray
Write-Host "updater路径: $updaterPath" -ForegroundColor Gray
try {
# 1. 删除现有的updater文件/目录
if (Test-Path $updaterPath) {
Write-Host "`n发现现有updater文件/目录,正在删除..." -ForegroundColor Yellow
Remove-Item -Path $updaterPath -Force -Recurse -ErrorAction Stop
Write-Host "成功删除现有文件/目录" -ForegroundColor Green
}
# 2. 创建空文件
Write-Host "`n正在创建updater文件..." -ForegroundColor Yellow
New-Item -Path $updaterPath -ItemType File -Force -ErrorAction Stop | Out-Null
Write-Host "成功创建updater文件" -ForegroundColor Green
# 3. 设置文件权限
Write-Host "`n正在设置文件权限..." -ForegroundColor Yellow
# 获取当前用户
$currentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
# 创建新的ACL
$acl = New-Object System.Security.AccessControl.FileSecurity
$acl.SetAccessRuleProtection($true, $false) # 禁用继承
# 添加只读权限规则
$readRule = New-Object System.Security.AccessControl.FileSystemAccessRule(
$currentUser,
[System.Security.AccessControl.FileSystemRights]::Read,
[System.Security.AccessControl.AccessControlType]::Allow
)
$acl.AddAccessRule($readRule)
# 应用ACL
Set-Acl -Path $updaterPath -AclObject $acl -ErrorAction Stop
# 设置只读属性
Set-ItemProperty -Path $updaterPath -Name IsReadOnly -Value $true -ErrorAction Stop
Write-Host "成功设置文件权限" -ForegroundColor Green
# 4. 修改package.json
if (Test-Path $packageJsonPath) {
Write-Host "`n正在修改package.json..." -ForegroundColor Yellow
$json = Get-Content $packageJsonPath -Raw | ConvertFrom-Json
$json.updateUrl = ""
$json.disableUpdate = $true
$json | ConvertTo-Json -Depth 10 | Set-Content $packageJsonPath -Encoding UTF8
Write-Host "成功修改package.json" -ForegroundColor Green
}
# 5. 验证权限
Write-Host "`n正在验证文件权限..." -ForegroundColor Yellow
$item = Get-Item $updaterPath
if (-not $item.IsReadOnly) {
throw "文件权限验证失败:文件不是只读"
}
Write-Host "文件权限验证通过" -ForegroundColor Green
Write-Host "`n[成功] Cursor更新已禁用" -ForegroundColor Green
} catch {
Write-Host "`n[错误] 操作失败: $($_.Exception.Message)" -ForegroundColor Red
}
Write-Host "`n按任意键退出..." -ForegroundColor Gray
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")