Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.
Rust chatgptclaudeclidesktopdesktop-appelectron-alternativegeminilinuxmacosnativefierno-electronrusttauriweb-to-desktopwebsite-to-appwebviewwindowsyoutube
fix: support notification onclick callback via Web Notification API
Tw93bf20e16a9a9c
diff --git a/src-tauri/src/inject/event.js b/src-tauri/src/inject/event.jsindex 3472ab1d..870c9592 100644--- a/src-tauri/src/inject/event.js+++ b/src-tauri/src/inject/event.js@@ -1027,23 +1027,41 @@ document.addEventListener("DOMContentLoaded", () => {document.addEventListener("DOMContentLoaded", function () {let permVal = "granted";+ let lastNotifTime = 0;+ let lastNotif = null;++ window.addEventListener("focus", () => {+ if (lastNotif?.onclick && Date.now() - lastNotifTime < 5000) {+ lastNotif.onclick(new Event("click"));+ lastNotif = null;+ }+ });+window.Notification = function (title, options) {const { invoke } = window.__TAURI__.core;const body = options?.body || "";let icon = options?.icon || "";- // If the icon is a relative path, convert to full path using URIif (icon.startsWith("/")) {icon = window.location.origin + icon;}- invoke("send_notification", {- params: {- title,- body,- icon,- },+ const notif = {+ onclick: null,+ onclose: null,+ onshow: null,+ onerror: null,+ close: () => {},+ };++ lastNotifTime = Date.now();+ lastNotif = notif;++ invoke("send_notification", { params: { title, body, icon } }).then(() => {+ if (notif.onshow) notif.onshow(new Event("show"));});++ return notif;};window.Notification.requestPermission = async () => "granted";