fix: openActivityTarget navigates to parent folder and previews files

- resolveActivityTarget uses 'targetId'/'targetPath' for all types
  (note, file, folder) instead of type-specific property names
- openActivityTarget for files: resolves the file node via
  GetNodeDetail, navigates to its parent folder in the Files tab,
  then auto-previews the file if it's a previewable type
- For root-level files (no parent_id): loads root items
- Removed spurious OpenFolder(targetPath) call that silently failed
  because OpenFolder expects a node ID, not a filesystem path
This commit is contained in:
2026-06-03 17:32:18 +08:00
parent 4ec03c849f
commit e30a75c5a0
4 changed files with 26 additions and 12 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -16,7 +16,7 @@
background: #13131f;
}
</style>
<script type="module" crossorigin src="/assets/main-B4NdnBxC.js"></script>
<script type="module" crossorigin src="/assets/main-D_8wOpYY.js"></script>
<link rel="stylesheet" crossorigin href="/assets/main-BafVhx43.css">
</head>
<body>
+22 -8
View File
@@ -1345,19 +1345,33 @@
selectNode(node)
if (target.tab === 'notes') {
activeTab = 'notes'
if (target.noteId) {
if (target.targetId) {
try { notes = await wailsCall('ListNotes', targetNode) || [] } catch(e) {}
const note = notes.find(n => n.id === target.noteId)
const note = notes.find(n => n.id === target.targetId)
if (note) setTimeout(() => openNote(note), 100)
}
} else if (target.tab === 'files') {
activeTab = 'files'
// Without explicit loadFolder the files tab stays empty because selectNode
// resets fileItems and the tab's click handler doesn't fire on programmatic toggle.
await loadFolder(selectedNode.id)
// target.targetPath is a filesystem path; OpenFolder opens the system file manager.
if (target.targetPath) {
try { await wailsCall('OpenFolder', target.targetPath) } catch(e) {}
if (target.targetId) {
// targetId is the node ID of the file/folder in the tree.
// Navigate to its parent folder so the user sees context.
try {
const detail = await wailsCall('GetNodeDetail', target.targetId)
if (detail && detail.parent_id) {
await loadFolder(detail.parent_id)
const fileItem = fileItems.find(f => f.id === target.targetId)
if (fileItem && fileItem.type === 'file' && canPreviewFile(fileItem)) {
setTimeout(() => openPreview(fileItem), 150)
}
} else {
// No parent — item sits at the root level
await loadFolder(targetNode)
}
} catch(e) {
await loadFolder(targetNode)
}
} else {
await loadFolder(targetNode)
}
}
} catch (e) {