fix(files): 未命名保存后刷新文件树;关闭 Tauri 拖放拦截放行侧栏 HTML5 拖拽(docs/25 回修)

This commit is contained in:
Muse
2026-11-14 17:08:01 +08:00
parent c2958ebf8c
commit 13271f11b6
3 changed files with 18 additions and 1 deletions

View File

@@ -56,3 +56,17 @@
新窗口仍能收到草稿提示;
- 未命名保存直接落根目录、避让命名;
- 「打开所在位置」资源管理器定位效果。
## 真机回修(2026-11-14 晚)
1. **未命名保存后文件树不刷新**:saveTab 只在新建/新建文件夹流程里刷
树,保存落点变化(未命名首次保存、另存为)时没刷。已补:writeTextFile
成功且路径变化时 setTreeRefresh +1。
2. **侧栏拖拽显示禁止符号、drop 不触发**:实现本身(HTML5 DnD)在
DOM 层测试是通过的,真机失效的根因是 Tauri 窗口默认开启
`dragDropEnabled` 原生拖放拦截——它会吞掉 WebView 内的 HTML5 拖拽
事件(本应用没有任何功能在用原生拖放事件)。主窗口配置
(tauri.conf.json)与运行时新窗口(WebviewWindow 参数)均已设
`dragDropEnabled: false`。附带好处:编辑器内 ProseMirror 的文本拖放
同样被拦截所禁,一并恢复。若真机仍不行,下一步改指针式拖拽
(pointer events 自绘),不再依赖 HTML5 DnD。

View File

@@ -1 +1 @@
{"$schema":"https://schema.tauri.app/config/2","app":{"security":{"csp":null},"windows":[{"center":true,"decorations":false,"height":820,"label":"main","minHeight":600,"minWidth":920,"resizable":true,"title":"new-markdown","width":1280}]},"build":{"beforeBuildCommand":"npm run build","beforeDevCommand":"npm run dev","devUrl":"http://localhost:1420","frontendDist":"../dist"},"bundle":{"active":true,"category":"Productivity","icon":["icons/32x32.png","icons/128x128.png","icons/128x128@2x.png","icons/icon.ico","icons/icon.png"],"shortDescription":"Windows Markdown 所见即所得编辑器","targets":["nsis","msi"]},"identifier":"app.newmarkdown.desktop","productName":"new-markdown","version":"0.1.0"}
{"$schema":"https://schema.tauri.app/config/2","app":{"security":{"csp":null},"windows":[{"center":true,"decorations":false,"height":820,"label":"main","minHeight":600,"minWidth":920,"resizable":true,"title":"new-markdown","width":1280,"dragDropEnabled":false}]},"build":{"beforeBuildCommand":"npm run build","beforeDevCommand":"npm run dev","devUrl":"http://localhost:1420","frontendDist":"../dist"},"bundle":{"active":true,"category":"Productivity","icon":["icons/32x32.png","icons/128x128.png","icons/128x128@2x.png","icons/icon.ico","icons/icon.png"],"shortDescription":"Windows Markdown 所见即所得编辑器","targets":["nsis","msi"]},"identifier":"app.newmarkdown.desktop","productName":"new-markdown","version":"0.1.0"}

View File

@@ -346,6 +346,7 @@ export default function App() {
minWidth: 920,
minHeight: 600,
decorations: false,
dragDropEnabled: false,
})
} catch (e) { setError(`打开新窗口失败:${String(e)}`) }
}, [])
@@ -389,6 +390,8 @@ export default function App() {
}
await writeTextFile(path, toDiskContent(snapshot, target.lineEnding), target.hadBom)
dispatch({ type: 'saved', id: target.id, savedContent: snapshot, path, title: baseName(path) })
// 落点变化(未命名首次保存、另存为)意味着磁盘上多/改了一个文件,刷新左侧文件树
if (target.path !== path) setTreeRefresh((n) => n + 1)
const stat = await statFile(path)
if (stat.exists) baselinesRef.current.set(target.id, { mtimeMs: stat.mtimeMs, size: stat.size })
// 恢复记录可能按旧键(未命名/旧路径)写入,新旧键都清,避免下次启动误报草稿