fix(desktop): 拖动窗口图标时不再崩溃 (#3573)#3616
Merged
esengine merged 1 commit intoJun 9, 2026
Merged
Conversation
Wails 的 EnableFileDrop 全局开启后,拖动窗口左上角图标 (非磁盘文件)会触发 ResolveFilePaths 抛出未捕获错误, 导致整个应用崩溃。 在 onFilesDropped 中注册全局 error/unhandledrejection 拦截器, 吞掉 'additional File object is not a file on the disk' 错误, 仅允许真实的文件拖拽到达回调。
esengine
approved these changes
Jun 9, 2026
esengine
left a comment
Owner
There was a problem hiding this comment.
Reviewed the diff: the fix is correct, focused, and CI is green. Approving for merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
拖动窗口左上角的蓝色 Reasonix 图标到窗口本身时,应用崩溃并显示:
根因
main.go中DragAndDrop: &options.DragAndDrop{EnableFileDrop: true}全局开启了文件拖拽。当用户拖动窗口图标(不是磁盘上的文件)时,Wails 内部的ResolveFilePaths尝试将其解析为文件路径,失败后抛出未捕获的错误,导致整个应用崩溃。可选方案
方案 A:CSS 阻止拖拽(最简单)
给窗口图标加
pointer-events: none或-webkit-app-region: no-drag。方案 B:关闭全局拖拽 + 局部处理(最彻底)
将
main.go的EnableFileDrop改为false,在 composer 区域用 HTML5onDrop自己处理文件。方案 C:错误拦截(本 PR 采用,折中方案)
在
bridge.ts的onFilesDropped中注册全局error和unhandledrejection拦截器,精准吞掉该错误。修复内容
本 PR 采用方案 C。如果后续决定采用方案 B 彻底重构,这个拦截器也可以随时移除。