mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-05-09 12:36:07 +02:00
eccd6f977a
Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de> Co-authored-by: Lucas Nogueira <lucas@tauri.app> Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
26 lines
734 B
TypeScript
26 lines
734 B
TypeScript
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import { invoke } from "@tauri-apps/api/tauri";
|
|
import { UnlistenFn, listen } from "@tauri-apps/api/event";
|
|
|
|
export async function getCurrent(): Promise<string[] | null> {
|
|
return await invoke<string[] | null>("plugin:deep-link|get_current");
|
|
|
|
// return await invoke("plugin:deep-link|get_current");
|
|
}
|
|
|
|
export async function onOpenUrl(
|
|
handler: (urls: string[]) => void,
|
|
): Promise<UnlistenFn> {
|
|
const current = await getCurrent();
|
|
if (current != null) {
|
|
handler(current);
|
|
}
|
|
|
|
return await listen<string[]>("deep-link://new-url", (event) =>
|
|
handler(event.payload),
|
|
);
|
|
}
|