mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 09:38:19 +08:00
ui: 收到站内消息是增加提醒 (#86)
This commit is contained in:
1 parent
fb47598c57
commit
6cae5cb7d1
10 files changed
+62
-67
No files matched your search
@@ -7,27 +7,38 @@ import tpl from 'vj/utils/tpl';
|
||||
|
||||
const messagePage = new AutoloadPage('messagePage', () => {
|
||||
async function init() {
|
||||
if (UserContext.unreadMsg) {
|
||||
new Notification({
|
||||
type: 'info',
|
||||
message: i18n('You have mew message.'),
|
||||
action: () => window.open('/home/messages', '_blank'),
|
||||
}).show();
|
||||
}
|
||||
|
||||
const { default: SockJs } = await import('../socket');
|
||||
|
||||
const sock = new SockJs('/home/messages-conn');
|
||||
sock.onmessage = (message) => {
|
||||
const msg = JSON.parse(message.data);
|
||||
if (msg.mdoc.flag | FLAG_ALERT) {
|
||||
console.log('Received message', msg);
|
||||
if (msg.mdoc.flag & FLAG_ALERT) {
|
||||
// Is alert
|
||||
const dialog = new InfoDialog({
|
||||
new InfoDialog({
|
||||
$body: tpl`
|
||||
<div class="typo">
|
||||
<p>${i18n(msg.udoc.content)}</p>
|
||||
<p>${i18n('Message from {0}:', msg.mdoc.from)}</p>
|
||||
<p>${i18n(msg.mdoc.content)}</p>
|
||||
</div>`,
|
||||
});
|
||||
dialog.open();
|
||||
}).open();
|
||||
} else {
|
||||
// Is message
|
||||
Notification.show({
|
||||
new Notification({
|
||||
title: msg.udoc.uname,
|
||||
avatar: msg.udoc.gravatar,
|
||||
avatar: msg.udoc.gravatar_url,
|
||||
message: msg.mdoc.content,
|
||||
});
|
||||
duration: 15000,
|
||||
action: () => window.open(`/home/messages?uid=${msg.udoc._id}`, '_blank'),
|
||||
}).show();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user