fix tauri-plugin-opener perms and Show Location action
This commit is contained in:
+16
-11
@@ -4,7 +4,7 @@ import { ask, message, open } from '@tauri-apps/plugin-dialog'
|
|||||||
import { exists, remove } from '@tauri-apps/plugin-fs'
|
import { exists, remove } from '@tauri-apps/plugin-fs'
|
||||||
import { isPermissionGranted, requestPermission } from '@tauri-apps/plugin-notification'
|
import { isPermissionGranted, requestPermission } from '@tauri-apps/plugin-notification'
|
||||||
import { sendNotification } from '@tauri-apps/plugin-notification'
|
import { sendNotification } from '@tauri-apps/plugin-notification'
|
||||||
import { revealItemInDir } from '@tauri-apps/plugin-opener'
|
import { openPath } from '@tauri-apps/plugin-opener'
|
||||||
import { platform } from '@tauri-apps/plugin-os'
|
import { platform } from '@tauri-apps/plugin-os'
|
||||||
import { exit } from '@tauri-apps/plugin-process'
|
import { exit } from '@tauri-apps/plugin-process'
|
||||||
import { isDirectoryEmpty } from './fs'
|
import { isDirectoryEmpty } from './fs'
|
||||||
@@ -70,24 +70,29 @@ export async function buildMenu() {
|
|||||||
})
|
})
|
||||||
submenuItems.push(unmountMenuItem)
|
submenuItems.push(unmountMenuItem)
|
||||||
|
|
||||||
// Add "Open in Finder" option for mounted remotes
|
// Add "Show Location" option for mounted remotes
|
||||||
const mountPoint = storeState.mountedRemotes[remote]
|
const mountPoint = storeState.mountedRemotes[remote]
|
||||||
console.log('Adding Open in Finder', mountPoint)
|
console.log('Adding Show Location', mountPoint)
|
||||||
const openInFinderItem = await MenuItem.new({
|
const showLocationItem = await MenuItem.new({
|
||||||
id: `open-${remote}`,
|
id: `open-${remote}`,
|
||||||
|
|
||||||
text: 'Open in Finder',
|
text: 'Show Location',
|
||||||
action: async () => {
|
action: async () => {
|
||||||
console.log('Open in Finder')
|
console.log('Show Location', mountPoint)
|
||||||
console.log(mountPoint)
|
|
||||||
if (mountPoint) {
|
if (mountPoint) {
|
||||||
console.log('Opening in Finder')
|
try {
|
||||||
await revealItemInDir(mountPoint)
|
await openPath(mountPoint)
|
||||||
console.log('Opened in Finder')
|
} catch (err) {
|
||||||
|
console.error('Error opening path:', err)
|
||||||
|
await message(`Failed to open ${mountPoint} (${err})`, {
|
||||||
|
title: 'Open Error',
|
||||||
|
kind: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
submenuItems.push(openInFinderItem)
|
submenuItems.push(showLocationItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!alreadyMounted && !remoteConfig?.disabledActions?.includes('tray-mount')) {
|
if (!alreadyMounted && !remoteConfig?.disabledActions?.includes('tray-mount')) {
|
||||||
|
|||||||
@@ -240,7 +240,25 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"opener:default",
|
|
||||||
|
"opener:allow-open-url",
|
||||||
|
{
|
||||||
|
"identifier": "opener:allow-open-path",
|
||||||
|
"allow": [
|
||||||
|
{
|
||||||
|
"path": "*/**"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identifier": "opener:allow-reveal-item-in-dir",
|
||||||
|
"allow": [
|
||||||
|
{
|
||||||
|
"path": "*/**"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"opener:allow-default-urls",
|
||||||
|
|
||||||
"updater:allow-download",
|
"updater:allow-download",
|
||||||
"updater:allow-download-and-install",
|
"updater:allow-download-and-install",
|
||||||
|
|||||||
Reference in New Issue
Block a user