style: add translation for com.msgbyte.notify

pull/56/head
moonrailgun 3 years ago
parent 801cdcf145
commit 5db553aa7c

@ -2,23 +2,26 @@ import {
regGroupPanelBadge,
regPluginGroupTextPanelExtraMenu,
sharedEvent,
showToasts,
} from '@capital/common';
import { Icon } from '@capital/component';
import React from 'react';
import { appendSilent, hasSilent, removeSilent } from './silent';
import { initNotify } from './notify';
import { Translate } from './translate';
const PLUGIN_NAME = 'com.msgbyte.notify';
if ('Notification' in window) {
initNotify();
} else {
console.warn('浏览器不支持 Notification');
showToasts(Translate.nosupport, 'warning');
console.warn(Translate.nosupport);
}
regPluginGroupTextPanelExtraMenu({
name: `${PLUGIN_NAME}/grouppanelmenu`,
label: '免打扰',
label: Translate.slient,
icon: 'mdi:bell-off-outline',
onClick: (panelInfo) => {
if (hasSilent(panelInfo.id)) {

@ -4,6 +4,7 @@ import {
getCachedUserInfo,
getServiceWorkerRegistration,
} from '@capital/common';
import { Translate } from './translate';
import { hasSilent } from './silent';
export function initNotify() {
@ -37,7 +38,7 @@ export function initNotify() {
getServiceWorkerRegistration();
if (registration) {
registration.showNotification(`来自 ${nickname}`, {
registration.showNotification(`${Translate.from} ${nickname}`, {
body: content,
icon,
tag: 'tailchat-message',
@ -45,7 +46,7 @@ export function initNotify() {
});
} else {
// fallback
new Notification(`来自 ${nickname}`, {
new Notification(`${Translate.from} ${nickname}`, {
body: content,
icon,
tag: 'tailchat-message',

@ -0,0 +1,13 @@
import { localTrans } from '@capital/common';
export const Translate = {
nosupport: localTrans({
'zh-CN': '当前浏览器不支持 Notification',
'en-US': 'This browser not support Notification',
}),
slient: localTrans({ 'zh-CN': '免打扰', 'en-US': 'Slient' }),
from: localTrans({
'zh-CN': '来自',
'en-US': 'From',
}),
};
Loading…
Cancel
Save