初始化web服务功能

This commit is contained in:
xintaofei
2026-03-25 14:26:26 +08:00
parent ae70f17d2e
commit ac09d3db9e
99 changed files with 3253 additions and 304 deletions

View File

@@ -1,9 +1,22 @@
import { invoke } from "@tauri-apps/api/core"
import { getTransport } from "./transport"
import { isDesktop } from "./transport"
export async function notifyTurnComplete(
title: string,
body: string
): Promise<void> {
if (!document.hidden) return
await invoke("send_notification", { title, body })
if (isDesktop()) {
await getTransport().call("send_notification", { title, body })
} else {
// Web fallback: Browser Notification API
if (Notification.permission === "granted") {
new Notification(title, { body })
} else if (Notification.permission !== "denied") {
const permission = await Notification.requestPermission()
if (permission === "granted") {
new Notification(title, { body })
}
}
}
}