Skip to content

Update plugin 解除占用 v1.1.0 - #635

Merged
lzx8589561 merged 1 commit into
ZToolsCenter:mainfrom
Taitres:plugin/unlock
Oct 2, 2026
Merged

lzx8589561 merged 1 commit into
ZToolsCenter:mainfrom
Taitres:plugin/unlock

Conversation

@Taitres

@Taitres Taitres commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

插件信息

  • 名称: 解除占用
  • 插件ID: unlock
  • 版本: 1.1.0
  • CLI版本: 1.3.2
  • 描述: 解除文件占用、粉碎文件、检测端口占用,支持拖拽文件和手动输入路径
  • 作者: Taitres
  • 类型: 更新

本次变更

修复

  • 重启管理器兜底检测完全失效:RmGetList 的 pnProcInfoNeeded(out) 与 pnProcInfo(ref) 传入了同一个变量,计数被写回清零,导致分配 0 字节缓冲区、永远查不到占用者;异常还被空 catch 吞掉,所以一直静默失败。现在两者使用不同变量,失败会输出到 stderr 并记入运行记录。
  • 一个文件被多个进程占用时漏报:witr 匹配到多个目标时退出码为 4,输出的是一份人类可读列表(不是 JSON),此前被当作"无占用者"。现在会解析出全部 PID,并逐个用 witr --pid 补全启动链。
  • 重启管理器结构体越界写内存:RM_PROCESS_INFO 按 Ansi 计算大小,而 RmGetList 按 WCHAR[256]/WCHAR[64] 写入,缓冲区被写穿导致 PowerShell 宿主堆损坏(0xC0000374;1 个占用者侥幸不崩,2 个以上必崩)。结构体解析改到 C# 内完成,并显式标注 CharSet.Unicode。
  • 路径特殊字符:生成的 PowerShell 脚本改为单引号字面量并转义 ',路径中含 $、反引号、双引号时不再被当成变量或破坏脚本(此前可造成脚本错误甚至命令注入)。

新增

  • 结束进程后闭环验证:结束占用进程后轮询探测(约 1.8s)文件能否重新独占打开,只有确认解除才提示成功;仍被占用时明确提示"可能还有其他程序或系统服务在访问",并刷新剩余占用者列表。端口检测同样会复查端口是否释放。
  • 一键结束全部占用进程(文件与端口)并统一验证结果。
  • 占用状态四态探测:被占用 / 可独占打开 / 文件夹 / 路径不存在。文件夹被占用(很常见的工作目录占用)会给出可执行的排查建议,不再只显示"无法确认锁定状态"。
  • 权限不足与文件被占用分别提示,不再混为一谈、不再误入"查找占用进程"流程。

改进

  • 前端提示改为成功 / 提示 / 注意 / 错误四级提示条,全部口语化文案:不再出现"退出码"、"engine="、"PID xxx 仍然存活"等调试字眼;需要排查时可展开底部"运行记录"。
  • 进程卡片文案中文化:Why It Exists → "它是怎么跑起来的"、Source → "来源"、Working Dir → "工作目录"、kill → "结束进程"。
  • 进程卡片展示 Windows 服务短名,并提示"直接结束可能触发服务自动重启,建议先停止该服务"。
  • 占用者名称解析为真实进程名(此前重启管理器可能只给出单个字母,如 W)。
  • 新增 preload 接口与文案的回归测试:重启管理器检测、双占用者端到端、闭环验证、占用状态探测、提示文案不含调试字眼、preload 暴露的接口齐全(75 个用例全绿)。测试串行执行,并改为"等占用真的建立"再断言,消除竞态导致的偶发失败。
  • witr 仍为可选依赖:首次运行时自动释放/下载,不可用时由 Windows 重启管理器接管检测,功能不受影响。

截图 / 演示

自检清单

  • plugin.json 的 name / title / version / description / author 字段均已检查
  • 已移除调试日志、未使用文件、敏感信息(.env、token、密钥等)
  • 本次 PR 的 diff 仅涉及 plugins/unlock/ 目录
  • 已在本地 ZTools 客户端实际加载并测试过此插件,主要功能正常
  • 同意以仓库声明的开源协议发布此插件

此 PR 由 ztools-plugin-cli 自动管理:每次 ztools publish 基于最新主仓库重建发布分支;打开的 PR 链接保持不变。

- chore: remove example components, update App.vue
- feat(preload): add pure helper utilities for process management
- test(preload): add unit tests for pure helper functions
- feat(preload): implement find/close/kill process APIs
- feat(types): update Services interface for unlock APIs
- feat(ui): add Unlock component with drag-drop and process management
- feat(config): update plugin.json with unlock feature
- docs: update README for unlock plugin
- fix: replace inline PowerShell with compiled C# .ps1 scripts, add debug logging
- fix: rewrite detection to handle.exe + exclusive probe + process fallback
- chore: remove test file
- fix: show hint instead of 392 processes when handle.exe not installed
- fix: replace handle.exe/RM with WMI command-line detection (524ms, works without admin)
- chore: cleanup
- fix: simplify close to RM shutdown only, clean up unused handle.exe files
- chore: cleanup test files
- feat: add admin retry button - launchs elevated PowerShell to close handles
- feat: add npm run pack, install, release commands for .zpx packaging
- chore: ignore release/ directory
- chore: fix .gitignore encoding, ignore release/
- fix: remove stray closing brace breaking detect-lock.ps1 syntax
- fix: correct try/catch structure and remove extra closing brace in detect-lock.ps1
- fix: support directory drag, rewrite admin handle closer with NT path matching and result reporting
- fix: directory drag via separate cmds, no-BOM JSON result, dir lock detection, self-filter WMI
- docs(plan): Windows-only unlock plugin implementation plan
- chore: remove obsolete close-handle and admin-close scripts
- feat(preload): add parseDetectOutput pure function with tests
- refactor(preload): simplify utils to Windows-only taskkill
- refactor(preload): rewrite services.js to Windows-only, use parseDetectOutput
- docs(preload): document UTF-8/JSON coupling on PowerShell stdout
- feat(preload): rewrite detect-lock.ps1 to use Restart Manager RmGetList
- feat(preload): bundle handle.exe via download script + postinstall
- feat(preload): add parseHandleExeOutput pure function with tests
- feat(preload): add handle.exe fallback in findLockingProcesses
- fix(preload): only surface __LOCKED__ hint when locked:true, not on API failure
- feat(types): update Services interface for Windows-only unlock plugin
- feat(ui): simplify to kill-only, add appType label, split __LOCKED__ by locked flag
- chore: restrict plugin to Windows platform
- docs: update README for Windows-only unlock plugin with handle.exe fallback
- fix: probe file with exclusive open when detection finds no process
- docs: spec for v2 three-module design (unlock + shredder + port scanner)
- feat(types): add PortInfo, ShredderResult, TabType; remove AppType
- fix(types): ShredderResult extends OperationResult
- chore: remove Restart Manager detection module (no longer used)
- feat(unlock): create handle.exe-only detection module with temp script for Chinese paths
- style(unlock): use const/let instead of var, strict assert per code review
- feat(shredder): add file shred/delete module with PowerShell implementation
- refactor(shredder): extract isDirectory, remove dead imports, fix tests for real dirs
- feat(portscan): add port occupancy detection module with Get-NetTCPConnection
- refactor(services): aggregate from unlock/shredder/portscan modules
- feat(ui): add tab container with unlock/shredder/port tabs
- feat(ui): add simplified UnlockTab with handle.exe-only results
- feat(ui): add ShredderTab with delete/shred modes and auto-unlock
- feat(ui): add PortTab with port scan table and kill button
- docs(plugin): update title/description for three-module tool, add search features
- chore(build): skip emptyOutDir to avoid handle.exe lock conflict on Windows
- v1.0
- v1.0
- v1.0发布
- v1.0 修复
- v1.1.0: 修复占用漏报与重启管理器失效,结束进程后闭环验证,提示文案改为用户友好
@lzx8589561
lzx8589561 marked this pull request as ready for review October 2, 2026 13:22
@lzx8589561
lzx8589561 merged commit 227a707 into ZToolsCenter:main Oct 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants