mirror of https://github.com/msgbyte/tailchat
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
975 B
TypeScript
40 lines
975 B
TypeScript
|
4 years ago
|
import {
|
||
|
|
regGroupPanelBadge,
|
||
|
|
regPluginGroupTextPanelExtraMenu,
|
||
|
|
sharedEvent,
|
||
|
|
} from '@capital/common';
|
||
|
|
import { Icon } from '@capital/component';
|
||
|
|
import React from 'react';
|
||
|
|
import { appendSilent, hasSilent, removeSilent } from './silent';
|
||
|
|
import { initNotify } from './notify';
|
||
|
|
|
||
|
|
const PLUGIN_NAME = 'com.msgbyte.notify';
|
||
|
|
|
||
|
|
if ('Notification' in window) {
|
||
|
|
initNotify();
|
||
|
|
} else {
|
||
|
|
console.warn('浏览器不支持 Notification');
|
||
|
|
}
|
||
|
|
|
||
|
|
regPluginGroupTextPanelExtraMenu({
|
||
|
|
name: `${PLUGIN_NAME}/grouppanelmenu`,
|
||
|
|
label: '免打扰',
|
||
|
|
icon: 'mdi:bell-off-outline',
|
||
|
|
onClick: (panelInfo) => {
|
||
|
|
if (hasSilent(panelInfo.id)) {
|
||
|
|
removeSilent(panelInfo.id);
|
||
|
|
} else {
|
||
|
|
appendSilent(panelInfo.id);
|
||
|
|
}
|
||
|
|
|
||
|
|
sharedEvent.emit('groupPanelBadgeUpdate');
|
||
|
|
},
|
||
|
|
});
|
||
|
|
|
||
|
|
regGroupPanelBadge({
|
||
|
|
name: `${PLUGIN_NAME}/grouppanelbadge`,
|
||
|
|
render: (groupId: string, panelId: string) => {
|
||
|
|
return hasSilent(panelId) ? <Icon icon="mdi:bell-off-outline" /> : null;
|
||
|
|
},
|
||
|
|
});
|