koishi-plugin-chat-patch 3.0.2 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/vue/index.vue +60 -634
- package/client/web/dist/assets/AppIcon-DIku6-h0.png +0 -0
- package/client/web/dist/assets/AppIconDark-BYymN71t.png +0 -0
- package/client/web/dist/assets/CapacitorAppIcon-CSZwNhvi.png +0 -0
- package/client/web/dist/assets/CapacitorAppIconDark-BMvMOzsg.png +0 -0
- package/client/web/dist/assets/Chat-CTdyeaX2.css +1 -0
- package/client/web/dist/assets/Chat-DkZvD7d8.js +28 -0
- package/client/web/dist/assets/MealHungryPan-Beos3lRI.js +1 -0
- package/client/web/dist/assets/MsgBody-aZ4_aija.js +1 -0
- package/client/web/dist/assets/MsgBody.vue_vue_type_script_setup_true_lang-CPZjRLp6.js +67 -0
- package/client/web/dist/assets/NapcatAppIcon-C7VOAkW9.png +0 -0
- package/client/web/dist/assets/Vue-lEhHouxB.png +0 -0
- package/client/web/dist/assets/append_darwin-CqBNU62J.css +1 -0
- package/client/web/dist/assets/append_full_vibrancy-j0D2LM9m.css +1 -0
- package/client/web/dist/assets/append_linux-uhxeBqeC.css +1 -0
- package/client/web/dist/assets/append_linux_vibrancy-COiZq8MS.css +1 -0
- package/client/web/dist/assets/append_napcat-DV8CAyAd.css +1 -0
- package/client/web/dist/assets/append_new-407Lo5_V.css +1 -0
- package/client/web/dist/assets/append_vibrancy-6FHctkOY.css +1 -0
- package/client/web/dist/assets/append_win32-srmD-78y.css +1 -0
- package/client/web/dist/assets/cakes-CxTVKdnK.svg +189 -0
- package/client/web/dist/assets/core-DhEqZVGG.js +1 -0
- package/client/web/dist/assets/event-Cadp6m6J.js +1 -0
- package/client/web/dist/assets/index-CPTXiemn.js +4045 -0
- package/client/web/dist/assets/index-Cg_esKB0.js +1 -0
- package/client/web/dist/assets/index-Cln012sP.css +1 -0
- package/client/web/dist/assets//346/226/271/346/255/243/345/226/265/345/221/234/344/275/223-CJKIKBn3.ttf +0 -0
- package/client/web/dist/assets//346/234/237/345/276/205-C90_OY60.png +0 -0
- package/client/web/dist/bcui/css/color-dark.css +35 -0
- package/client/web/dist/bcui/css/color-light.css +35 -0
- package/client/web/dist/bcui/css/style.css +468 -0
- package/client/web/dist/bcui/js/main.js +193 -0
- package/client/web/dist/css/append-dark.css +13 -0
- package/client/web/dist/css/append-light.css +13 -0
- package/client/web/dist/css/append-napcat-dark.css +14 -0
- package/client/web/dist/css/append-napcat-light.css +14 -0
- package/client/web/dist/favicon.ico +0 -0
- package/client/web/dist/img/icons/icon-for-fuck-apple.png +0 -0
- package/client/web/dist/img/icons/icon-maskable.png +0 -0
- package/client/web/dist/img/icons/icon.png +0 -0
- package/client/web/dist/img/icons/icon.svg +10 -0
- package/client/web/dist/index.html +22 -0
- package/client/web/dist/robots.txt +2 -0
- package/client/web/dist/sw.js +58 -0
- package/client/web/env.d.ts +56 -0
- package/client/web/index.html +21 -0
- package/client/web/package-lock.json +3419 -0
- package/client/web/package.json +62 -0
- package/client/web/public/bcui/css/color-dark.css +35 -0
- package/client/web/public/bcui/css/color-light.css +35 -0
- package/client/web/public/bcui/css/style.css +468 -0
- package/client/web/public/bcui/js/main.js +193 -0
- package/client/web/public/css/append-dark.css +13 -0
- package/client/web/public/css/append-light.css +13 -0
- package/client/web/public/css/append-napcat-dark.css +14 -0
- package/client/web/public/css/append-napcat-light.css +14 -0
- package/client/web/public/favicon.ico +0 -0
- package/client/web/public/img/icons/icon-for-fuck-apple.png +0 -0
- package/client/web/public/img/icons/icon-maskable.png +0 -0
- package/client/web/public/img/icons/icon.png +0 -0
- package/client/web/public/img/icons/icon.svg +10 -0
- package/client/web/public/robots.txt +2 -0
- package/client/web/public/sw.js +58 -0
- package/client/web/scripts/copy-bcui.mjs +17 -0
- package/client/web/src/App.vue +1127 -0
- package/client/web/src/assets/css/append/append_darwin.css +68 -0
- package/client/web/src/assets/css/append/append_full_vibrancy.css +290 -0
- package/client/web/src/assets/css/append/append_linux.css +125 -0
- package/client/web/src/assets/css/append/append_linux_vibrancy.css +22 -0
- package/client/web/src/assets/css/append/append_napcat.css +35 -0
- package/client/web/src/assets/css/append/append_new.css +843 -0
- package/client/web/src/assets/css/append/append_vibrancy.css +113 -0
- package/client/web/src/assets/css/append/append_win32.css +109 -0
- package/client/web/src/assets/css/append/mobile/append_mobile_horizontal.css +349 -0
- package/client/web/src/assets/css/append/mobile/append_mobile_vertical.css +96 -0
- package/client/web/src/assets/css/chat.css +2104 -0
- package/client/web/src/assets/css/msg.css +941 -0
- package/client/web/src/assets/css/options.css +811 -0
- package/client/web/src/assets/css/sys_notice.css +62 -0
- package/client/web/src/assets/css/view.css +2105 -0
- package/client/web/src/assets/font//346/226/271/346/255/243/345/226/265/345/221/234/344/275/223.ttf +0 -0
- package/client/web/src/assets/img/Vue.png +0 -0
- package/client/web/src/assets/img/cakes.svg +189 -0
- package/client/web/src/assets/img/icons/AppIcon.png +0 -0
- package/client/web/src/assets/img/icons/AppIconDark.png +0 -0
- package/client/web/src/assets/img/icons/CapacitorAppIcon.png +0 -0
- package/client/web/src/assets/img/icons/CapacitorAppIconDark.png +0 -0
- package/client/web/src/assets/img/icons/NapcatAppIcon.png +0 -0
- package/client/web/src/assets/img/icons/NapcatAppIconDark.png +0 -0
- package/client/web/src/assets/img/icons/exit.png +0 -0
- package/client/web/src/assets/img/icons/pen.png +0 -0
- package/client/web/src/assets/img/stars.svg +89 -0
- package/client/web/src/assets/img//346/234/237/345/276/205.png +0 -0
- package/client/web/src/assets/l10n/_About I10n.md +35 -0
- package/client/web/src/assets/l10n/_l10nconfig.json +7 -0
- package/client/web/src/assets/l10n/zh-CN.po +1941 -0
- package/client/web/src/assets/logo.png +0 -0
- package/client/web/src/assets/pathMap/LLOneBot.yaml +2 -0
- package/client/web/src/assets/pathMap/Lagrange.OneBot.yaml +180 -0
- package/client/web/src/assets/pathMap/NapCat.Onebot.yaml +224 -0
- package/client/web/src/assets/pathMap/SnowLuma.yaml +80 -0
- package/client/web/src/assets/qed.txt +1 -0
- package/client/web/src/components/AboutPan.vue +197 -0
- package/client/web/src/components/BulletinBody.vue +129 -0
- package/client/web/src/components/DepPan.vue +310 -0
- package/client/web/src/components/EmojiFace.vue +32 -0
- package/client/web/src/components/FacePan.vue +461 -0
- package/client/web/src/components/FileBody.vue +129 -0
- package/client/web/src/components/FileManager.vue +532 -0
- package/client/web/src/components/FriendBody.vue +54 -0
- package/client/web/src/components/GlobalSessionSearchBar.vue +301 -0
- package/client/web/src/components/History.vue +49 -0
- package/client/web/src/components/LazyLottie.vue +82 -0
- package/client/web/src/components/MergePan.vue +127 -0
- package/client/web/src/components/MsgBody.vue +1478 -0
- package/client/web/src/components/MusicPlayer.vue +549 -0
- package/client/web/src/components/NoticeBody.vue +168 -0
- package/client/web/src/components/QzonePermissionPan.vue +150 -0
- package/client/web/src/components/RawMsgRenderPreviewPan.vue +190 -0
- package/client/web/src/components/ThemeColorPickerPan.vue +420 -0
- package/client/web/src/components/TinySessionBody.vue +51 -0
- package/client/web/src/components/UmamiInfoPan.vue +1549 -0
- package/client/web/src/components/UpdatePan.vue +263 -0
- package/client/web/src/components/ViewerCom.vue +1360 -0
- package/client/web/src/components/VoiceMsg.vue +626 -0
- package/client/web/src/components/WelPan.vue +894 -0
- package/client/web/src/components/msg-body/.gitkeep +0 -0
- package/client/web/src/components/msg-component/JsonSegComp.vue +138 -0
- package/client/web/src/components/msg-component/XmlSegComp.vue +132 -0
- package/client/web/src/components/msg-component/jsonComp/AutoReply.vue +97 -0
- package/client/web/src/components/msg-component/jsonComp/Contact.lua.vue +129 -0
- package/client/web/src/components/msg-component/jsonComp/Feed.lua.vue +94 -0
- package/client/web/src/components/msg-component/jsonComp/Forum.vue +84 -0
- package/client/web/src/components/msg-component/jsonComp/Mannounce.vue +111 -0
- package/client/web/src/components/msg-component/jsonComp/Map.vue +52 -0
- package/client/web/src/components/msg-component/jsonComp/Miniapp.lua.vue +53 -0
- package/client/web/src/components/msg-component/jsonComp/Miniapp.vue +69 -0
- package/client/web/src/components/msg-component/jsonComp/Music.lua.vue +135 -0
- package/client/web/src/components/msg-component/jsonComp/Tuwen.lua.vue +56 -0
- package/client/web/src/components/notice-component/.gitkeep +0 -0
- package/client/web/src/components/notice-component/MealHungryPan.vue +119 -0
- package/client/web/src/components/tooltip/CustomFaceTooltip.vue +22 -0
- package/client/web/src/components/tooltip/Tooltip.vue +50 -0
- package/client/web/src/components/tooltip/Tooltips.vue +14 -0
- package/client/web/src/components/tooltip/UserInfoTooltip.vue +69 -0
- package/client/web/src/function/base.ts +238 -0
- package/client/web/src/function/connect.ts +2042 -0
- package/client/web/src/function/debug.ts +10 -0
- package/client/web/src/function/elements/information.ts +141 -0
- package/client/web/src/function/elements/system.ts +101 -0
- package/client/web/src/function/elements/vueComp.ts +62 -0
- package/client/web/src/function/favicon.ts +76 -0
- package/client/web/src/function/input.ts +69 -0
- package/client/web/src/function/model/emoji.ts +127 -0
- package/client/web/src/function/model/img.ts +150 -0
- package/client/web/src/function/model/msg-body.ts +51 -0
- package/client/web/src/function/msg.ts +2674 -0
- package/client/web/src/function/notify.ts +225 -0
- package/client/web/src/function/option.ts +749 -0
- package/client/web/src/function/satori-model.ts +818 -0
- package/client/web/src/function/satori.ts +325 -0
- package/client/web/src/function/sender.ts +178 -0
- package/client/web/src/function/tooltip.ts +49 -0
- package/client/web/src/function/utils/appUtil.ts +2288 -0
- package/client/web/src/function/utils/avatarUtil.ts +31 -0
- package/client/web/src/function/utils/backgroundUtil.ts +110 -0
- package/client/web/src/function/utils/linkViewUtil.ts +101 -0
- package/client/web/src/function/utils/localHistoryUtil.ts +517 -0
- package/client/web/src/function/utils/msgUtil.ts +1242 -0
- package/client/web/src/function/utils/pinyin.ts +141 -0
- package/client/web/src/function/utils/recordUtil.ts +187 -0
- package/client/web/src/function/utils/sessionUtil.ts +114 -0
- package/client/web/src/function/utils/systemUtil.ts +664 -0
- package/client/web/src/main.ts +91 -0
- package/client/web/src/pages/Chat.vue +3453 -0
- package/client/web/src/pages/Friends.vue +636 -0
- package/client/web/src/pages/Info.vue +717 -0
- package/client/web/src/pages/Messages.vue +875 -0
- package/client/web/src/pages/Options.vue +82 -0
- package/client/web/src/pages/Qzone.vue +1178 -0
- package/client/web/src/pages/chat-view/ChatDanmaku.vue +759 -0
- package/client/web/src/pages/chat-view/ChatGlagame.vue +642 -0
- package/client/web/src/pages/chat-view/ChatTerminal.vue +1044 -0
- package/client/web/src/pages/chat-view/SystemNotice.vue +171 -0
- package/client/web/src/pages/options/OptAccount.vue +107 -0
- package/client/web/src/pages/options/OptAddon.vue +185 -0
- package/client/web/src/pages/options/OptDev.vue +704 -0
- package/client/web/src/pages/options/OptFunction.vue +403 -0
- package/client/web/src/pages/options/OptInfo.vue +165 -0
- package/client/web/src/pages/options/OptView.vue +846 -0
- package/client/web/src/runtime/backend.ts +310 -0
- package/client/web/src/state/auth.ts +14 -0
- package/client/web/src/state/chat.ts +36 -0
- package/client/web/src/state/connection.ts +20 -0
- package/client/web/src/state/contact.ts +37 -0
- package/client/web/src/state/qzone.ts +18 -0
- package/client/web/src/state/sessionHistory.ts +25 -0
- package/client/web/src/state/settings.ts +18 -0
- package/client/web/src/state/sticker.ts +10 -0
- package/client/web/src/state/ui.ts +56 -0
- package/client/web/tsconfig.json +27 -0
- package/client/web/tsconfig.tsbuildinfo +1 -0
- package/client/web/vite.config.ts +33 -0
- package/dist/index.js +1 -12
- package/dist/style.css +1 -1
- package/lib/index.js +2070 -2077
- package/package.json +15 -2
- package/readme.md +0 -22
- package/src/bootstrap.ts +71 -0
- package/src/cache.ts +319 -0
- package/src/config.ts +23 -35
- package/src/database.ts +650 -0
- package/src/index.ts +27 -59
- package/src/media.ts +302 -0
- package/src/recorder.ts +175 -0
- package/src/self-message.ts +456 -0
- package/src/server.d.ts +26 -0
- package/src/types.ts +108 -48
- package/src/web.ts +712 -0
- package/client/vue/chat-logic.ts +0 -683
- package/client/vue/composables/useChatActions.ts +0 -61
- package/client/vue/composables/useChatData.ts +0 -185
- package/client/vue/composables/useImageCache.ts +0 -281
- package/client/vue/composables/useVideoCache.ts +0 -125
- package/client/vue/types.ts +0 -72
- package/lib/api-handlers.d.ts +0 -25
- package/lib/config.d.ts +0 -14
- package/lib/file-manager.d.ts +0 -124
- package/lib/index.d.ts +0 -17
- package/lib/logger.d.ts +0 -9
- package/lib/message-handler.d.ts +0 -35
- package/lib/types.d.ts +0 -57
- package/lib/utils.d.ts +0 -18
- package/src/api-handlers.ts +0 -646
- package/src/file-manager.ts +0 -1436
- package/src/message-handler.ts +0 -507
- package/src/utils.ts +0 -189
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import app from '../main'
|
|
2
|
+
import { NotifyInfo, NotificationElem } from './elements/system'
|
|
3
|
+
import { jumpToChat } from './utils/appUtil'
|
|
4
|
+
import {
|
|
5
|
+
LocalNotificationSchema,
|
|
6
|
+
DeliveredNotifications
|
|
7
|
+
} from '@capacitor/local-notifications'
|
|
8
|
+
import { backend } from '../runtime/backend'
|
|
9
|
+
|
|
10
|
+
export class Notify {
|
|
11
|
+
// 针对 MSG 类型的通知,记录用户的通知数量
|
|
12
|
+
private static userNotifyList: { [key: string]: number } = {}
|
|
13
|
+
// Web 端端通知列表,key tag
|
|
14
|
+
private static notifyList: { [key: string]: Notification } = {}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 发送一条通知
|
|
18
|
+
* @param info 通知信息
|
|
19
|
+
*/
|
|
20
|
+
public notify(info: NotifyInfo) {
|
|
21
|
+
const { $t } = app.config.globalProperties
|
|
22
|
+
// 判断当前 userId 是否已存在通知
|
|
23
|
+
const userId = info.tag.split('/')[0]
|
|
24
|
+
if (Notify.userNotifyList[userId] === undefined) {
|
|
25
|
+
Notify.userNotifyList[userId] = 1
|
|
26
|
+
} else {
|
|
27
|
+
Notify.userNotifyList[userId]++
|
|
28
|
+
// 修改通知内容为:“<内容>” 以及<数量>条消息
|
|
29
|
+
info.body = $t('“{body}” 以及 {num} 条消息', {
|
|
30
|
+
body: info.body,
|
|
31
|
+
num: Notify.userNotifyList[userId] - 1,
|
|
32
|
+
})
|
|
33
|
+
// 关闭之前的通知
|
|
34
|
+
this.closeAll(userId)
|
|
35
|
+
}
|
|
36
|
+
// 发送消息
|
|
37
|
+
if (backend.isDesktop()) {
|
|
38
|
+
backend.call(undefined, 'sys:sendNotice', false, backend.type == 'tauri' ? { data: info } : info)
|
|
39
|
+
} else if(backend.isMobile()) {
|
|
40
|
+
const data = {
|
|
41
|
+
title: info.title,
|
|
42
|
+
body: info.body,
|
|
43
|
+
// id 相同的通知会被覆盖,这里使用用户 ID 作为通知 ID 便于覆盖
|
|
44
|
+
id: Number(info.tag.split('/')[0]),
|
|
45
|
+
schedule: {
|
|
46
|
+
at: new Date(Date.now() + 100)
|
|
47
|
+
},
|
|
48
|
+
sound: backend.platform === 'ios' ? 'beep.wav' : 'beep.mp3',
|
|
49
|
+
actionTypeId: 'msgQuickReply',
|
|
50
|
+
extra: {
|
|
51
|
+
userId: info.tag.split('/')[0],
|
|
52
|
+
msgId: info.tag.split('/')[1],
|
|
53
|
+
chatType: info.type
|
|
54
|
+
}
|
|
55
|
+
} as LocalNotificationSchema
|
|
56
|
+
backend.call('LocalNotifications', 'schedule', false, { notifications: [data] })
|
|
57
|
+
} else {
|
|
58
|
+
// Safari:在 iOS 下,如果页面没有被创建为主屏幕,通知无法被调用
|
|
59
|
+
// 最见鬼的是它不是方法返回失败,而且整个 Notification 对象都没有
|
|
60
|
+
const isSupported = () =>
|
|
61
|
+
'Notification' in window &&
|
|
62
|
+
'serviceWorker' in navigator &&
|
|
63
|
+
'PushManager' in window
|
|
64
|
+
if (isSupported()) {
|
|
65
|
+
// 检查通知权限,老旧浏览器不支持这个功能
|
|
66
|
+
if (Notification.permission === 'default') {
|
|
67
|
+
Notification.requestPermission(() => {
|
|
68
|
+
this.sendNotice(info)
|
|
69
|
+
})
|
|
70
|
+
} else if (Notification.permission !== 'denied') {
|
|
71
|
+
this.sendNotice(info)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 发送独立通知
|
|
79
|
+
* @param info 通知信息
|
|
80
|
+
*/
|
|
81
|
+
public notifySingle(info: NotifyInfo) {
|
|
82
|
+
if (backend.isDesktop()) {
|
|
83
|
+
backend.call(undefined, 'sys:sendNotice', false, info)
|
|
84
|
+
} else if (backend.isMobile()) {
|
|
85
|
+
const data = {
|
|
86
|
+
title: info.title,
|
|
87
|
+
body: info.body,
|
|
88
|
+
// id 为随机数,不会被覆盖;主要用于应用的通知
|
|
89
|
+
id: Math.floor(Math.random() * 100000),
|
|
90
|
+
schedule: {
|
|
91
|
+
at: new Date(Date.now() + 100)
|
|
92
|
+
},
|
|
93
|
+
sound: backend.platform === 'ios' ? 'beep.wav' : 'beep.mp3'
|
|
94
|
+
} as LocalNotificationSchema
|
|
95
|
+
backend.call('LocalNotifications', 'schedule', false, { notifications: [data] })
|
|
96
|
+
} else {
|
|
97
|
+
// Safari:在 iOS 下,如果页面没有被创建为主屏幕,通知无法被调用
|
|
98
|
+
// 最见鬼的是它不是方法返回失败,而且整个 Notification 对象都没有
|
|
99
|
+
const isSupported = () =>
|
|
100
|
+
'Notification' in window &&
|
|
101
|
+
'serviceWorker' in navigator &&
|
|
102
|
+
'PushManager' in window
|
|
103
|
+
if (isSupported()) {
|
|
104
|
+
// 检查通知权限,老旧浏览器不支持这个功能
|
|
105
|
+
if (Notification.permission === 'default') {
|
|
106
|
+
Notification.requestPermission(() => {
|
|
107
|
+
this.sendNotice(info)
|
|
108
|
+
})
|
|
109
|
+
} else if (Notification.permission !== 'denied') {
|
|
110
|
+
this.sendNotice(info)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* 关闭用户的所有通知
|
|
118
|
+
* @param userId 用户 ID
|
|
119
|
+
*/
|
|
120
|
+
public async closeAll(userId: string) {
|
|
121
|
+
if (backend.isDesktop()) {
|
|
122
|
+
backend.call(undefined, 'sys:closeAllNotice', false, String(userId))
|
|
123
|
+
} else if(backend.isMobile()) {
|
|
124
|
+
const list = (await backend.call('LocalNotifications', 'getDeliveredNotifications', true)) as
|
|
125
|
+
unknown as DeliveredNotifications
|
|
126
|
+
if(list.notifications) {
|
|
127
|
+
list.notifications.forEach((item) => {
|
|
128
|
+
if (item.extra.userId === userId) {
|
|
129
|
+
backend.call('LocalNotifications', 'cancel', false, { notifications: [{ id: item.id }] })
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
const keys = Object.keys(Notify.notifyList)
|
|
135
|
+
keys.forEach((key) => {
|
|
136
|
+
if (key.startsWith(userId)) {
|
|
137
|
+
this.close(key)
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
delete Notify.userNotifyList[userId]
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 关闭所有通知
|
|
146
|
+
*/
|
|
147
|
+
public clear() {
|
|
148
|
+
if (backend.isDesktop()) {
|
|
149
|
+
backend.call(undefined, 'sys:clearNotice', false)
|
|
150
|
+
} else if(backend.isMobile()) {
|
|
151
|
+
backend.call('LocalNotifications', 'removeAllDeliveredNotifications', false)
|
|
152
|
+
} else {
|
|
153
|
+
const keys = Object.keys(Notify.notifyList)
|
|
154
|
+
keys.forEach((key) => {
|
|
155
|
+
this.close(key)
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// ==============================
|
|
161
|
+
// PS: 以下为 Web 端通知的方法
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* 关闭一条通知
|
|
165
|
+
* @param tag 通知标签
|
|
166
|
+
*/
|
|
167
|
+
private close(tag: string) {
|
|
168
|
+
if (backend.isDesktop()) {
|
|
169
|
+
backend.call(undefined, 'sys:closeNotice', false, tag)
|
|
170
|
+
} else {
|
|
171
|
+
Notify.notifyList[tag]?.close()
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* 关闭一条通知(如果是消息通知,则跳转到对应的聊天页面)
|
|
177
|
+
* @param tag 通知标签
|
|
178
|
+
* @returns 通知对象
|
|
179
|
+
*/
|
|
180
|
+
private closeJump(tag: string | undefined) {
|
|
181
|
+
if (tag !== undefined) {
|
|
182
|
+
if (tag.indexOf('/') > 0) {
|
|
183
|
+
// MSG 类型的通知
|
|
184
|
+
const userId = tag.split('/')[0]
|
|
185
|
+
const msgId = tag.substring(userId.length + 1, tag.length)
|
|
186
|
+
delete Notify.userNotifyList[userId]
|
|
187
|
+
// 跳转到这条消息的发送者页面
|
|
188
|
+
window.focus()
|
|
189
|
+
jumpToChat(userId, msgId)
|
|
190
|
+
}
|
|
191
|
+
this.close(tag)
|
|
192
|
+
// MacOS:刷新 touchbar
|
|
193
|
+
if (backend.isDesktop()) {
|
|
194
|
+
backend.call(undefined, 'sys:newMessage', false)
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* 发送一条通知(Web 端)
|
|
201
|
+
* @param info 通知信息
|
|
202
|
+
* @returns 通知对象
|
|
203
|
+
*/
|
|
204
|
+
private sendNotice(info: NotifyInfo) {
|
|
205
|
+
// 构建通知
|
|
206
|
+
let notificationTile = ''
|
|
207
|
+
const notificationBody = {} as NotificationElem
|
|
208
|
+
notificationBody.requireInteraction = true
|
|
209
|
+
notificationTile = info.title
|
|
210
|
+
notificationBody.body = info.body
|
|
211
|
+
notificationBody.tag = info.tag
|
|
212
|
+
notificationBody.icon = info.icon
|
|
213
|
+
// 发起通知
|
|
214
|
+
const notification = new Notification(
|
|
215
|
+
notificationTile,
|
|
216
|
+
notificationBody,
|
|
217
|
+
)
|
|
218
|
+
notification.onclick = (event: Event) => {
|
|
219
|
+
const info = event.target as NotificationOptions
|
|
220
|
+
this.closeJump(info.tag)
|
|
221
|
+
}
|
|
222
|
+
// 保存通知对象
|
|
223
|
+
Notify.notifyList[info.tag] = notification
|
|
224
|
+
}
|
|
225
|
+
}
|