🌱 发送通知

This commit is contained in:
BTMuli
2026-01-02 00:01:30 +08:00
parent 03136c4864
commit 0288e38c95
8 changed files with 132 additions and 19 deletions

33
src/utils/TGNotify.ts Normal file
View File

@@ -0,0 +1,33 @@
/**
* 系统通知简单封装
* @since Beta v.0.9.1
*/
import showSnackbar from "@comp/func/snackbar.js";
import {
isPermissionGranted,
requestPermission,
sendNotification,
} from "@tauri-apps/plugin-notification";
/**
* 展示通知
* @param title - 标题
* @param text - 内容
*/
async function showNormalNotify(title: string, text: string): Promise<void> {
const check = await isPermissionGranted();
if (!check) {
const permission = await requestPermission();
if (permission !== "granted") {
showSnackbar.warn("Notify permission is not allowed!");
return;
}
}
sendNotification({ title: title, body: text });
}
const TGNotify = {
normal: showNormalNotify,
};
export default TGNotify;