From 13271f11b6909ea5b9d355fc5d473902a4b9c9fa Mon Sep 17 00:00:00 2001 From: Muse Date: Sat, 14 Nov 2026 17:08:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(files):=20=E6=9C=AA=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=90=8E=E5=88=B7=E6=96=B0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=A0=91=EF=BC=9B=E5=85=B3=E9=97=AD=20Tauri=20=E6=8B=96?= =?UTF-8?q?=E6=94=BE=E6=8B=A6=E6=88=AA=E6=94=BE=E8=A1=8C=E4=BE=A7=E6=A0=8F?= =?UTF-8?q?=20HTML5=20=E6=8B=96=E6=8B=BD=EF=BC=88docs/25=20=E5=9B=9E?= =?UTF-8?q?=E4=BF=AE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/25-文件管理四项.md | 14 ++++++++++++++ src-tauri/tauri.conf.json | 2 +- src/App.tsx | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/25-文件管理四项.md b/docs/25-文件管理四项.md index 35bdf85..40806e5 100644 --- a/docs/25-文件管理四项.md +++ b/docs/25-文件管理四项.md @@ -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。 diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 3639c4b..ab9bb9c 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -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"} \ No newline at end of file +{"$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"} \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index 1688d32..a454f78 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -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 }) // 恢复记录可能按旧键(未命名/旧路径)写入,新旧键都清,避免下次启动误报草稿