Skip to content

feat: 超级面板支持文件位置快捷跳转#532

Merged
lzx8589561 merged 1 commit into
ZToolsCenter:mainfrom
Particaly:feat/super-panel-file-location-jump
Jun 7, 2026
Merged

feat: 超级面板支持文件位置快捷跳转#532
lzx8589561 merged 1 commit into
ZToolsCenter:mainfrom
Particaly:feat/super-panel-file-location-jump

Conversation

@Particaly

@Particaly Particaly commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

关联 native 提交:#10

resolve #450resolve #81

20260606_205654.mp4

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

Copy link
Copy Markdown
Contributor

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 a file location quick-jump feature to the SuperPanel, allowing users to quickly navigate file manager windows and file dialogs on Windows and macOS. Key changes include adding native window management APIs, updating IPC handlers, and enhancing the SuperPanel UI to display jump targets. Feedback on these changes highlights critical issues where synchronous dialog APIs were incorrectly refactored to be asynchronous, which breaks IPC return values. Additionally, a potential runtime crash was identified in the system commands due to a missing null-check on the optional application name, and a leftover debug log in the SuperPanel component should be removed.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +79 to +87
windowManager
.withBlurHideSuppressed(() => dialog.showSaveDialog(targetWindow, options))
.then((data: Electron.SaveDialogReturnValue) => {
event.returnValue = data.canceled ? undefined : data.filePath
})
.catch((error: Error) => {
console.error('[PluginDialog] 显示文件保存对话框失败:', error)
event.returnValue = undefined
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

PluginDialogAPI 中,show-save-dialog 是通过同步 IPC(渲染进程使用 sendSync)调用的。主进程必须同步地为 event.returnValue 赋值。

在当前修改中,您使用了异步的 withBlurHideSuppresseddialog.showSaveDialog,并在 .then() 回调中异步设置 event.returnValue。这会导致主进程在 Promise 解析之前就结束了同步事件处理,渲染进程会立即收到 undefined 返回值,而不会等待用户在对话框中选择文件,从而导致保存文件对话框功能完全失效。

为了保持同步 API 的正确行为,必须恢复使用同步的 withBlurHideSuppressedSyncdialog.showSaveDialogSync

        const result = windowManager.withBlurHideSuppressedSync(() =>
          dialog.showSaveDialogSync(targetWindow, options)
        )
        event.returnValue = result

Comment on lines +105 to +113
windowManager
.withBlurHideSuppressed(() => dialog.showOpenDialog(targetWindow, options))
.then((data: Electron.OpenDialogReturnValue) => {
event.returnValue = data.canceled ? [] : data.filePaths
})
.catch((error: Error) => {
console.error('[PluginDialog] 显示文件打开对话框失败:', error)
event.returnValue = []
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

show-save-dialog 类似,show-open-dialog 也是通过同步 IPC(渲染进程使用 sendSync)调用的。

使用异步的 withBlurHideSuppresseddialog.showOpenDialog 会导致渲染进程在对话框弹出时立即收到空数组 [] 返回值,而不会等待用户选择文件。

必须恢复使用同步的 withBlurHideSuppressedSyncdialog.showOpenDialogSync 以确保同步返回选中的文件路径。

        const result = windowManager.withBlurHideSuppressedSync(() =>
          dialog.showOpenDialogSync(targetWindow, options)
        )
        event.returnValue = result || []

Comment on lines +739 to +740
const appName = winInfo.app

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

由于 WindowActivationInfopreviousActiveWindow 中的 app 属性现在被改为了可选属性(app?: string),winInfo.app 有可能为 undefined

如果 appNameundefined,直接调用 appName.toLowerCase() 将会抛出 TypeError: Cannot read properties of undefined (reading 'toLowerCase') 运行时崩溃。

建议在获取 appName 后进行非空校验,如果为空则安全返回。

Suggested change
const appName = winInfo.app
const appName = winInfo.app
if (!appName) {
return { success: false, error: '无法获取应用名称' }
}

Comment on lines +861 to +863
const info = currentWindowInfo.value
console.log('object', info);
if (!info) return null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

此处保留了调试用的 console.log('object', info);。建议将其移除以保持代码整洁,避免污染生产环境的控制台日志。

  const info = currentWindowInfo.value
  if (!info) return null

@lzx8589561 lzx8589561 merged commit 1972f98 into ZToolsCenter:main Jun 7, 2026
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.

[Feature] 希望可以增加目录快速跳转 [Feature] 实现文件夹跳转功能(Windows)

2 participants