Skip to content

Add plugin 窗口置顶 v1.0.0#192

Draft
evanwen97-ops wants to merge 2 commits into
ZToolsCenter:mainfrom
evanwen97-ops:plugin/topwindow
Draft

Add plugin 窗口置顶 v1.0.0#192
evanwen97-ops wants to merge 2 commits into
ZToolsCenter:mainfrom
evanwen97-ops:plugin/topwindow

Conversation

@evanwen97-ops
Copy link
Copy Markdown
Contributor

@evanwen97-ops evanwen97-ops commented May 15, 2026

插件信息

  • 名称: 窗口置顶
  • 插件ID: topwindow
  • 版本: 1.0.0
  • 描述: 一个简单的窗口置顶插件,支持切换当前窗口的置顶状态。
  • 作者: evanwen97-ops
  • 类型: 新增

本次变更

  • feat: TopWindow plugin v1.0.0 - Windows window always-on-top toggle
  • fix: add title field to plugin.json for CLI publish

截图 / 演示

自检清单

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

此 PR 由 ztools-plugin-cli 自动管理:每次 ztools publish 在分支上追加一个 commit,PR 链接保持不变。

- feat: TopWindow plugin v1.0.0 - Windows window always-on-top toggle
- fix: add title field to plugin.json for CLI publish
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the topwindow plugin for ZTools, which allows users to toggle the 'Always on Top' status of the active window on Windows systems. The implementation uses a PowerShell script to interface with Win32 APIs via C# interop. The review feedback focuses on improving the robustness of the plugin by handling edge cases in window title parsing, enhancing error diagnostics by capturing stderr from the child process, and ensuring correct character encoding for non-ASCII window titles.

Comment on lines +34 to +36
const parts = output.split('||');
const action = parts[0] || '';
const title = parts[1] || '';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

使用 split('||') 解析输出结果时,如果窗口标题本身包含 || 字符串(虽然少见但可能存在),会导致标题显示不完整。建议使用解构赋值配合 join 来确保获取完整的标题内容。

Suggested change
const parts = output.split('||');
const action = parts[0] || '';
const title = parts[1] || '';
const [action, ...titleParts] = output.split('||');
const title = titleParts.join('||');

Comment on lines +26 to +30
if (error) {
console.error('TopWindow exec error:', error.message);
try {
window.ztools.showNotification('TopWindow 执行失败: ' + error.message);
} catch (e) { /* ignore */ }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

在处理 exec 执行错误时,建议同时记录或显示 stderr 的内容。PowerShell 的具体错误详情(如权限不足、脚本内部错误等)通常会输出到 stderr,这对于排查插件执行失败的原因非常有帮助。

@@ -0,0 +1,54 @@
$code = @'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

建议在脚本开头显式设置输出编码为 UTF-8。由于窗口标题可能包含中文字符,如果 PowerShell 使用默认的系统 ANSI 编码输出,Node.js 在读取 stdout 时可能会出现乱码。

[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$code = @'

@lzx8589561
Copy link
Copy Markdown
Contributor

image 只支持windows系统的话需要添加这个平台标识

- feat: TopWindow plugin v1.0.0 - Windows window always-on-top toggle
- fix: add title field to plugin.json for CLI publish
- feat: 透明背景logo + 添加win32平台标识 + 重新打包
- chore: 添加构建产物plugin.json
- docs: 添加CHANGELOG.md
- chore: 将build目录加入gitignore并从git中移除
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