Skip to content

Commit 45e2d9c

Browse files
committed
Add warning confirmations before scan and uninstall operations
1 parent 2d99418 commit 45e2d9c

1 file changed

Lines changed: 36 additions & 3 deletions

File tree

uninstall.ps1

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,17 @@ function Show-MainForm {
473473
}
474474
$Global:SelectedProduct = $productName
475475

476+
$scanWarning = [System.Windows.Forms.MessageBox]::Show(
477+
"⚠️ 即将对 ""$productName"" 进行全盘扫描`n`n扫描将搜索以下内容:`n• 文件和文件夹`n• NPM/PNPM 全局包`n• 环境变量`n• Windows 服务`n• 计划任务`n• 注册表项`n`n扫描完成后,您可以选择要删除的项目。`n`n是否继续?",
478+
"扫描确认",
479+
[System.Windows.Forms.MessageBoxButtons]::YesNo,
480+
[System.Windows.Forms.MessageBoxIcon]::Warning
481+
)
482+
483+
if ($scanWarning -ne [System.Windows.Forms.DialogResult]::Yes) {
484+
return
485+
}
486+
476487
$statusLabel.Text = "正在扫描 $productName..."
477488
$progressBar.Value = 0
478489
$resultListView.Items.Clear()
@@ -498,14 +509,36 @@ function Show-MainForm {
498509
})
499510

500511
$uninstallButton.Add_Click({
512+
$selectedCount = ($resultListView.Items | Where-Object { $_.Checked }).Count
513+
if ($selectedCount -eq 0) {
514+
[System.Windows.Forms.MessageBox]::Show(
515+
"请先勾选要删除的项目!",
516+
"提示",
517+
[System.Windows.Forms.MessageBoxButtons]::OK,
518+
[System.Windows.Forms.MessageBoxIcon]::Information
519+
)
520+
return
521+
}
522+
501523
$result = [System.Windows.Forms.MessageBox]::Show(
502-
"确定要卸载选中的项目吗?`n此操作不可恢复!",
503-
"确认卸载",
524+
"🚨 警告:即将删除选中的 $selectedCount 个项目!`n`n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`n ⚠️ 此操作将永久删除所有选中的文件、`n 文件夹、注册表项和系统配置!`n`n ❌ 删除后无法恢复!`n ❌ 数据将永久丢失!`n ❌ 回收站中找不到!`n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`n`n确定要继续吗?",
525+
"⚠️ 危险操作确认",
504526
[System.Windows.Forms.MessageBoxButtons]::YesNo,
505527
[System.Windows.Forms.MessageBoxIcon]::Warning
506528
)
507529

508530
if ($result -eq [System.Windows.Forms.DialogResult]::Yes) {
531+
$secondConfirm = [System.Windows.Forms.MessageBox]::Show(
532+
"🔴 最后确认:您真的要删除这些项目吗?`n`n此操作不可撤销!",
533+
"🔴 最终确认",
534+
[System.Windows.Forms.MessageBoxButtons]::YesNo,
535+
[System.Windows.Forms.MessageBoxIcon]::Exclamation
536+
)
537+
538+
if ($secondConfirm -ne [System.Windows.Forms.DialogResult]::Yes) {
539+
return
540+
}
541+
509542
$selectedItems = @()
510543
foreach ($listItem in $resultListView.Items) {
511544
if ($listItem.Checked) {
@@ -516,7 +549,7 @@ function Show-MainForm {
516549
if ($selectedItems.Count -gt 0) {
517550
Remove-ScannedItems -Items $selectedItems -ProgressBar $progressBar -StatusLabel $statusLabel
518551
[System.Windows.Forms.MessageBox]::Show(
519-
"卸载完成!`n已删除 $($selectedItems.Count)",
552+
"卸载完成!`n`n已删除 $($selectedItems.Count)",
520553
"完成",
521554
[System.Windows.Forms.MessageBoxButtons]::OK,
522555
[System.Windows.Forms.MessageBoxIcon]::Information

0 commit comments

Comments
 (0)