Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
foreign
/
customer-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1cda55d0
authored
Nov 03, 2021
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
notify
parent
4a06dee9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
2 deletions
xim/xim.ts
xim/xim.ts
View file @
1cda55d0
...
...
@@ -38,6 +38,10 @@ const chatType = "group";
export
class
Xim
{
private
eventBus
=
new
Vue
();
private
readonly
messageNotifyActions
:
{
key
:
string
;
action
:
(
m
:
Message
)
=>
void
;
}[]
=
[];
private
client
?:
XChatClient
;
...
...
@@ -420,6 +424,17 @@ export class Xim {
private
handleMsg
(
kind
:
any
,
msg
:
any
)
{
this
.
debug
(
`收到消息
${
new
Date
().
getTime
()}
`
,
kind
,
msg
);
if
(
(
kind
===
"chat"
||
kind
===
"chat_notify"
)
&&
msg
&&
msg
.
msg_type
!==
"read"
&&
msg
.
msg_type
!==
"user.input"
)
{
for
(
const
item
of
this
.
messageNotifyActions
)
{
item
.
action
(
msg
);
}
}
switch
(
kind
)
{
case
"chat"
:
this
.
emit
(
`msg`
,
msg
);
...
...
@@ -453,8 +468,15 @@ export class Xim {
}
public
registerOnMessage
(
vue
:
Vue
,
action
:
(
e
:
Message
)
=>
void
)
{
this
.
on
(
"msg"
,
action
);
vue
.
$once
(
"hook:beforeDestroy"
,
()
=>
this
.
off
(
"msg"
,
action
));
const
key
=
`
${
new
Date
().
valueOf
()}
-
${
Math
.
random
()}
`
;
this
.
messageNotifyActions
.
push
({
key
,
action
});
vue
.
$once
(
"hook:beforeDestroy"
,
()
=>
{
const
t
=
this
.
messageNotifyActions
.
find
((
i
)
=>
i
.
key
===
key
);
if
(
t
)
{
const
index
=
this
.
messageNotifyActions
.
indexOf
(
t
);
this
.
messageNotifyActions
.
splice
(
index
,
1
);
}
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment