跳到内容
Tauri

@tauri-apps/plugin-deep-link

function getCurrent(): Promise<string[] | null>

获取触发深度链接的当前 URL。在应用加载时使用此功能,以检查您的应用是否通过深度链接启动。

Promise<string[] | null>

import { getCurrent } from '@tauri-apps/plugin-deep-link';
const urls = await getCurrent();

请注意,使用 [Self::register] 动态注册深度链接方案时,您必须手动检查参数。此外,深度链接可能作为 CLI 参数提供,因此您应该检查其格式是否符合您的预期。

2.0.0

来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/deep-link/guest-js/index.ts#L23


function isRegistered(protocol): Promise<boolean>

检查应用程序是否是指定协议的默认处理程序。

参数类型描述
协议字符串不带 :// 的协议名称。

Promise<boolean>

import { isRegistered } from '@tauri-apps/plugin-deep-link';
await isRegistered("my-scheme");

2.0.0

来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/deep-link/guest-js/index.ts#L80


function onOpenUrl(handler): Promise<UnlistenFn>

deep-link://new-url 事件的辅助函数,用于在应用程序运行时每次触发协议时运行一个函数。在应用程序加载时使用 getCurrent 检查应用程序是否通过深度链接启动。

参数类型
处理程序(urls) => void

Promise<UnlistenFn>

import { onOpenUrl } from '@tauri-apps/plugin-deep-link';
await onOpenUrl((urls) => { console.log(urls) });

2.0.0

来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/deep-link/guest-js/index.ts#L99


function register(protocol): Promise<null>

将应用程序注册为指定协议的默认处理程序。

参数类型描述
协议字符串不带 :// 的协议名称。例如,如果您想让您的应用程序处理 tauri:// 链接,请将此方法与 tauri 作为协议进行调用。

Promise<null>

import { register } from '@tauri-apps/plugin-deep-link';
await register("my-scheme");

2.0.0

来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/deep-link/guest-js/index.ts#L42


function unregister(protocol): Promise<null>

将应用程序取消注册为指定协议的默认处理程序。

参数类型描述
协议字符串不带 :// 的协议名称。

Promise<null>

import { unregister } from '@tauri-apps/plugin-deep-link';
await unregister("my-scheme");

2.0.0

来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/deep-link/guest-js/index.ts#L61


© 2025 Tauri 贡献者。CC-BY / MIT