fix: open asset file with default app on Electron

related to https://github.com/logseq/db-test/issues/337
This commit is contained in:
Tienson Qin
2025-06-22 16:06:52 +08:00
parent 2383e44539
commit ff2ebe31ef

View File

@@ -537,17 +537,33 @@
title
[:span [:span.opacity-70 "[[📚"] title [:span.opacity-70 "]]"]])]
db-based?
(util/mobile?)
[:a.asset-ref {:href @src
:on-click share-fn}
title]
(and db-based? util/web-platform?)
(let [file-name (str (:block/title (:asset-block config)) "." (name ext))]
[:a.asset-ref.is-plaintext
[:a.asset-ref
{:href @src
:download file-name}
file-name])
(and (util/electron?) (:asset-block config))
(let [asset-block (:asset-block config)
file-name (if db-based?
(str (:block/title asset-block) "." (name ext))
href)]
[:a.asset-ref
{:on-click (fn [e]
(util/stop e)
(let [repo-dir (config/get-repo-dir repo)
file-fpath (path/path-join repo-dir (str "assets/" (:block/uuid asset-block) "." (name ext)))]
(js/window.apis.openPath file-fpath)))}
file-name])
:else
[:a.asset-ref {:href @src
:on-click share-fn}
title])))))
title)))))
;; TODO: safe encoding asciis
;; TODO: image link to another link