-
Notifications
You must be signed in to change notification settings - Fork 259
feat: 超级面板支持文件位置快捷跳转 #532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 超级面板支持文件位置快捷跳转 #532
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,10 +76,15 @@ export class PluginDialogAPI { | |
| event.returnValue = undefined | ||
| return | ||
| } | ||
| const result = windowManager.withBlurHideSuppressedSync(() => | ||
| dialog.showSaveDialogSync(targetWindow, options) | ||
| ) | ||
| event.returnValue = result | ||
| 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 | ||
| }) | ||
| } catch (error) { | ||
| console.error('[PluginDialog] 显示文件保存对话框失败:', error) | ||
| event.returnValue = undefined | ||
|
|
@@ -97,10 +102,15 @@ export class PluginDialogAPI { | |
| event.returnValue = [] | ||
| return | ||
| } | ||
| const result = windowManager.withBlurHideSuppressedSync(() => | ||
| dialog.showOpenDialogSync(targetWindow, options) | ||
| ) | ||
| event.returnValue = result || [] | ||
| 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 = [] | ||
| }) | ||
|
Comment on lines
+105
to
+113
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 与 使用异步的 必须恢复使用同步的 const result = windowManager.withBlurHideSuppressedSync(() =>
dialog.showOpenDialogSync(targetWindow, options)
)
event.returnValue = result || [] |
||
| } catch (error) { | ||
| console.error('[PluginDialog] 显示文件打开对话框失败:', error) | ||
| event.returnValue = [] | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -736,23 +736,25 @@ function handleAddToWakeupBlacklist(ctx: SystemCommandContext): any { | |||||||||||
| const blacklist: Array<{ app: string; bundleId?: string; label?: string }> = | ||||||||||||
| settings.wakeupBlacklist ?? [] | ||||||||||||
|
|
||||||||||||
| const appName = winInfo.app | ||||||||||||
|
|
||||||||||||
|
Comment on lines
+739
to
+740
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 由于 如果 建议在获取
Suggested change
|
||||||||||||
| // 去重:macOS 按 bundleId,Windows 按 app 名称 | ||||||||||||
| const isDuplicate = | ||||||||||||
| process.platform === 'darwin' && winInfo.bundleId | ||||||||||||
| ? blacklist.some((item) => item.bundleId === winInfo.bundleId) | ||||||||||||
| : blacklist.some((item) => item.app.toLowerCase() === winInfo.app.toLowerCase()) | ||||||||||||
| : blacklist.some((item) => item.app.toLowerCase() === appName.toLowerCase()) | ||||||||||||
|
|
||||||||||||
| if (isDuplicate) { | ||||||||||||
| ctx.mainWindow?.hide() | ||||||||||||
| if (Notification.isSupported()) { | ||||||||||||
| new Notification({ title: 'ZTools', body: `${winInfo.app} 已在唤醒黑名单中` }).show() | ||||||||||||
| new Notification({ title: 'ZTools', body: `${appName} 已在唤醒黑名单中` }).show() | ||||||||||||
| } | ||||||||||||
| return { success: false, error: '该应用已在唤醒黑名单中' } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| const label = winInfo.app.replace(/\.(exe|app)$/i, '') | ||||||||||||
| const label = appName.replace(/\.(exe|app)$/i, '') | ||||||||||||
| blacklist.push({ | ||||||||||||
| app: winInfo.app, | ||||||||||||
| app: appName, | ||||||||||||
| bundleId: winInfo.bundleId, | ||||||||||||
| label | ||||||||||||
| }) | ||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在
PluginDialogAPI中,show-save-dialog是通过同步 IPC(渲染进程使用sendSync)调用的。主进程必须同步地为event.returnValue赋值。在当前修改中,您使用了异步的
withBlurHideSuppressed和dialog.showSaveDialog,并在.then()回调中异步设置event.returnValue。这会导致主进程在 Promise 解析之前就结束了同步事件处理,渲染进程会立即收到undefined返回值,而不会等待用户在对话框中选择文件,从而导致保存文件对话框功能完全失效。为了保持同步 API 的正确行为,必须恢复使用同步的
withBlurHideSuppressedSync和dialog.showSaveDialogSync。