fix: local file path is not working on MD and DB

related to https://github.com/logseq/db-test/issues/389
This commit is contained in:
Tienson Qin
2025-07-30 15:16:23 +08:00
parent 2c13bce35a
commit 37736741e6
2 changed files with 25 additions and 34 deletions

View File

@@ -1,5 +1,6 @@
const fs = require('fs')
const path = require('path')
const os = require('os')
const { ipcRenderer, contextBridge, shell, clipboard, webFrame } = require('electron')
const IS_MAC = process.platform === 'darwin'
@@ -86,8 +87,11 @@ contextBridge.exposeInMainWorld('apis', {
await shell.openExternal(url, options)
},
async openPath (path) {
await shell.openPath(path)
async openPath (relativePath) {
const absolutePath = path.resolve(
relativePath.startsWith('~') ? path.join(os.homedir(), relativePath.slice(1)) : relativePath
);
await shell.openPath(absolutePath)
},
/**