mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 17:46:28 +08:00
core&ui: add clarification (#669)
This commit is contained in:
1 parent
bc4f5115d2
commit
c8c8063240
14 files changed
+373
-80
No files matched your search
@@ -2,13 +2,24 @@ import { nanoid } from 'nanoid';
|
||||
import ReconnectingWebsocket from 'reconnecting-websocket';
|
||||
import { InfoDialog } from 'vj/components/dialog';
|
||||
import VjNotification from 'vj/components/notification/index';
|
||||
import { FLAG_ALERT, FLAG_INFO, FLAG_RICHTEXT } from 'vj/constant/message';
|
||||
import {
|
||||
FLAG_ALERT, FLAG_I18N, FLAG_INFO, FLAG_RICHTEXT,
|
||||
} from 'vj/constant/message';
|
||||
import { AutoloadPage } from 'vj/misc/Page';
|
||||
import { i18n, tpl } from 'vj/utils';
|
||||
|
||||
let previous: VjNotification;
|
||||
const onmessage = (msg) => {
|
||||
console.log('Received message', msg);
|
||||
if (msg.mdoc.flag & FLAG_I18N) {
|
||||
try {
|
||||
msg.mdoc.content = JSON.parse(msg.mdoc.content);
|
||||
if (msg.mdoc.content.url) msg.mdoc.url = msg.mdoc.content.url;
|
||||
msg.mdoc.content = i18n(msg.mdoc.content.message, ...msg.mdoc.content.params);
|
||||
} catch (e) {
|
||||
msg.mdoc.content = i18n(msg.mdoc.content);
|
||||
}
|
||||
}
|
||||
if (msg.mdoc.flag & FLAG_ALERT) {
|
||||
// Is alert
|
||||
new InfoDialog({
|
||||
@@ -24,7 +35,7 @@ const onmessage = (msg) => {
|
||||
if (msg.mdoc.flag & FLAG_INFO) {
|
||||
if (previous) previous.hide();
|
||||
previous = new VjNotification({
|
||||
message: i18n(msg.mdoc.content),
|
||||
message: msg.mdoc.content,
|
||||
duration: 3000,
|
||||
});
|
||||
previous.show();
|
||||
@@ -33,15 +44,17 @@ const onmessage = (msg) => {
|
||||
if (document.hidden) return false;
|
||||
// Is message
|
||||
new VjNotification({
|
||||
...(msg.udoc._id === 1 && msg.mdoc.flag & FLAG_RICHTEXT)
|
||||
? { message: i18n('You received a system message, click here to view.') }
|
||||
: {
|
||||
...(msg.udoc._id === 1)
|
||||
? {
|
||||
type: 'info',
|
||||
message: msg.mdoc.flag & FLAG_RICHTEXT ? i18n('You received a system message, click here to view.') : msg.mdoc.content,
|
||||
} : {
|
||||
title: msg.udoc.uname,
|
||||
avatar: msg.udoc.avatarUrl,
|
||||
message: msg.mdoc.content,
|
||||
},
|
||||
duration: 15000,
|
||||
action: () => window.open(`/home/messages?uid=${msg.udoc._id}`, '_blank'),
|
||||
action: () => window.open(msg.mdoc.url ? msg.mdoc.url : `/home/messages?uid=${msg.udoc._id}`, '_blank'),
|
||||
}).show();
|
||||
return true;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user