admin管理员组

文章数量:1279207

I'm developing a Tauri v2 application (using Svelte and Tabulator) where I need to open a Slack deep link using the custom protocol (e.g., slack://user?team=TEAM_IDid=USER_ID). My goal is to launch the native Slack app on macOS using this URL. However, I’m running into several issues and have tried multiple approaches without success.

What I’ve Tried

  1. Using the Opener Plugin I attempted to use the Opener plugin:

js

import { openPath } from '@tauri-apps/plugin-opener';
// Attempting to open a Slack URL using openPath:
await openPath('slack://user?team=EDUA2R4KG&id=WR9RY8KMF');
This fails because openPath is intended for file paths rather than URLs.
  1. Using the Shell Plugin’s open Command I then tried the shell plugin’s open command on macOS:

js import { Command } from '@tauri-apps/plugin-shell';

const openUrlMacos = async (url) => {
  const cmd = await Command.create('open', [url]);
  await cmd.execute();
};

await openUrlMacos('slack://user?team=EDUA2R4KG&id=WR9RY8KMF');

Even after updating my capabilities configuration, I get the error:

Unhandled Promise Rejection: program not allowed on the configured shell scope: open My capabilities file (src-tauri/capabilities/default.json) is configured as follows:

json

{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "default",
  "description": "Capability for the main window",
  "windows": ["main"],
  "permissions": [
    "core:default",
    "dialog:default",
    "fs:default",
    "shell:default",
    {
      "identifier": "shell:allow-open",
      "allow": [
        {
          "name": "open",
          "cmd": "open",
          "args": ["*"]
        }
      ]
    }
  ]
}

This still doesn’t allow opening the custom slack:// URL.

My Questions Is there a known workaround or fix to allow opening slack:// URLs on macOS with Tauri v2? Should I consider switching to an HTTPS-based Slack URL (if available) as a workaround, or is there a way to enable custom protocols via Tauri’s capabilities? Any help or suggestions on how to reliably launch a custom protocol URL in Tauri on macOS would be greatly appreciated!

本文标签: Tauri v2 on macOS How to Open Custom slack URLsStack Overflow