An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve sendNotification (#17167)
Jeffrey Chen07e74561ff7d
diff --git a/app/electron/main.js b/app/electron/main.jsindex c263e9ba6e..064e240764 100644--- a/app/electron/main.js+++ b/app/electron/main.js@@ -54,8 +54,8 @@ app.setPath("userData", app.getPath("userData") + "-Electron"); // `~/.config`fs.rmSync(app.getPath("appData") + "/" + app.name, {recursive: true}); // 删除自动创建的应用目录 https://github.com/siyuan-note/siyuan/issues/13150if (process.platform === "win32") {- // Windows 需要设置 AppUserModelId 才能正确显示应用名称 https://github.com/siyuan-note/siyuan/issues/17022- app.setAppUserModelId(app.name);+ // Windows 需要设置 AppUserModelId 才能正确显示应用名称和应用图标 https://github.com/siyuan-note/siyuan/issues/17022+ app.setAppUserModelId("org.b3log.siyuan");}if (!app.requestSingleInstanceLock()) {@@ -958,8 +958,7 @@ app.whenReady().then(() => {new Notification({title: data.title,body: data.body,- icon: path.join(appDir, "stage", "icon.png"),- timeoutType: "never",+ timeoutType: data.timeoutType,}).show();break;case "setSpellCheckerLanguages":diff --git a/app/src/plugin/platformUtils.ts b/app/src/plugin/platformUtils.tsindex 158a4b6422..f16f2257f7 100644--- a/app/src/plugin/platformUtils.ts+++ b/app/src/plugin/platformUtils.ts@@ -20,9 +20,27 @@ export const updateHotkeyTip = compatibility.updateHotkeyTip;export const getLocalStorage = compatibility.getLocalStorage;export const setStorageVal = compatibility.setStorageVal;-export const sendNotification = (channel: string, title: string, body: string, delayInSeconds: number): Promise<number> => {+export interface ISendNotificationOptions {+ channel?: string,+ title?: string,+ body?: string,+ delayInSeconds?: number,+ timeoutType?: "default" | "never"+}++export const sendNotification = (options: ISendNotificationOptions): Promise<number> => {return new Promise((resolve) => {+ const title = options.title || "";+ const body = options.body || "";+ const delayInSeconds = options.delayInSeconds || 0;+ if (!title.trim() && !body.trim()) {+ // 不能同时为空+ resolve(-1);+ return;+ }+/// #if BROWSER+ const channel = options.channel || "Plugin Notification";if (window.JSAndroid && window.JSAndroid.sendNotification) {const id = window.JSAndroid.sendNotification(channel, title, body, delayInSeconds);resolve(id);@@ -49,11 +67,13 @@ export const sendNotification = (channel: string, title: string, body: string, dresolve(-1);}/// #else+ const timeoutType = options.timeoutType || "default";const timeoutId = window.setTimeout(() => {ipcRenderer.send(Constants.SIYUAN_CMD, {cmd: "notification",title,- body+ body,+ timeoutType});}, delayInSeconds * 1000);resolve(timeoutId);@@ -62,6 +82,9 @@ export const sendNotification = (channel: string, title: string, body: string, d};export const cancelNotification = (id: number) => {+ if (id <= 0) {+ return;+ }/// #if BROWSERif (window.JSAndroid && window.JSAndroid.cancelNotification) {window.JSAndroid.cancelNotification(id);