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
b160ab72
authored
Jan 10, 2022
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' into pre
parents
0a5d3bd6
eed04240
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
80 additions
and
70 deletions
components/controller/chat-list.ts
components/message-list.vue
components/message.vue
hybrid-input/index.vue
model/im.ts
service/monitor.ts
store/index.ts
components/controller/chat-list.ts
View file @
b160ab72
...
...
@@ -7,6 +7,8 @@ import { ChatUserInfoService } from "@/customer-service/utils/user-info";
@
Component
({
components
:
{}
})
export
default
class
ChatList
extends
Vue
{
private
nextTimer
=
0
;
@
chatStore
.
Action
(
ChatStore
.
ACTION_GET_MY_CHAT_LIST
)
protected
readonly
getMyChatList
!
:
ChatStore
.
ACTION_GET_MY_CHAT_LIST
;
...
...
@@ -91,4 +93,18 @@ export default class ChatList extends Vue {
}
return
this
.
parseMesage
(
item
);
}
/**
* 一分钟更新一次会话列表
*/
protected
enableAutoRefresh
()
{
this
.
nextTimer
=
setTimeout
(
()
=>
this
.
getMyChatList
().
finally
(()
=>
this
.
enableAutoRefresh
()),
60
*
1000
);
}
beforeDestroy
()
{
clearTimeout
(
this
.
nextTimer
);
}
}
components/message-list.vue
View file @
b160ab72
...
...
@@ -50,7 +50,6 @@
import
{
dbController
}
from
"../database"
;
import
{
getLastMessageId
}
from
"../store"
;
import
{
CustomerServiceEvent
}
from
"../event"
;
import
xim
from
"../xim/xim"
;
@
Component
({
components
:
{
message
,
ImagePreview
,
VideoPreview
}
})
export
default
class
MessageList
extends
Vue
{
...
...
@@ -95,7 +94,7 @@
private
get
messages
()
{
if
(
this
.
historyMessage
)
{
if
(
this
.
sendingMessages
)
{
if
(
this
.
sendingMessages
&&
this
.
sendingMessages
.
length
)
{
return
[...
this
.
historyMessage
,
...
this
.
sendingMessages
].
filter
(
(
i
)
=>
i
.
chat_id
===
this
.
chatId
&&
i
.
id
>
0
);
...
...
@@ -103,7 +102,7 @@
return
this
.
historyMessage
;
}
if
(
this
.
sendingMessages
)
{
if
(
this
.
sendingMessages
&&
this
.
sendingMessages
.
length
)
{
return
this
.
sendingMessages
.
filter
(
(
i
)
=>
i
.
chat_id
===
this
.
chatId
&&
i
.
id
>
0
);
...
...
@@ -190,15 +189,6 @@
public
created
()
{
this
.
handleScrollWrapper
();
this
.
onNewMessage
((
e
)
=>
{
if
(
e
.
type
===
MessageType
.
Withdraw
)
{
const
ids
=
xim
.
withDrawMsgHandle
(
e
);
this
.
executeWithDraw
(
ids
);
dbController
.
removeMessage
(
e
.
chat_id
,
ids
)
.
finally
(()
=>
this
.
refresh
());
}
});
}
public
mounted
()
{
...
...
components/message.vue
View file @
b160ab72
...
...
@@ -230,9 +230,6 @@
@
chatStore
.
State
(
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
)
private
readonly
chatId
!
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
;
@
chatStore
.
Mutation
(
ChatStore
.
MUTATION_WITHDRAW
)
private
readonly
executeWithDraw
!
:
ChatStore
.
MUTATION_WITHDRAW
;
@
chatStore
.
Action
(
ChatStore
.
ACTION_SET_HANDLED
)
private
readonly
setHandled
!
:
ChatStore
.
ACTION_SET_HANDLED
;
...
...
@@ -293,7 +290,7 @@
if
(
this
.
isPayMessage
)
{
return
true
;
}
if
(
this
.
needReadTip
)
{
if
(
this
.
needReadTip
&&
this
.
isMyMessage
)
{
return
new
Date
().
valueOf
()
-
this
.
data
.
ts
*
1000
<
oneDay
;
}
}
...
...
@@ -562,14 +559,7 @@
},
});
}
ximInstance
.
withdraw
(
this
.
chatId
,
this
.
data
.
id
).
finally
(()
=>
{
dbController
.
removeMessage
(
this
.
chatId
,
[
this
.
data
.
id
])
.
finally
(()
=>
{
this
.
executeWithDraw
([
this
.
data
.
id
]);
this
.
$emit
(
"withdraw"
,
this
.
data
.
id
);
});
});
ximInstance
.
withdraw
(
this
.
chatId
,
this
.
data
.
id
);
}
private
hoverWithdraw
()
{
...
...
hybrid-input/index.vue
View file @
b160ab72
...
...
@@ -369,30 +369,17 @@
*/
private
combine
(
nodes
:
ChildNode
[])
{
const
sendingNodes
:
ChildNode
[]
=
[];
let
needCreateNewNode
=
false
;
let
text
=
""
;
for
(
const
item
of
nodes
)
{
if
(
!
isImageOrFile
(
item
)
&&
item
.
textContent
)
{
if
(
needCreateNewNode
)
{
text
=
""
;
needCreateNewNode
=
false
;
}
text
+=
item
.
textContent
;
}
else
{
needCreateNewNode
=
true
;
if
(
text
)
{
this
.
checkTextLength
(
text
);
const
node
=
document
.
createTextNode
(
text
);
sendingNodes
.
push
(
node
);
}
if
(
isImageOrFile
(
item
))
{
sendingNodes
.
push
(
item
);
continue
;
}
if
(
item
.
textContent
)
{
const
text
=
item
.
textContent
;
this
.
checkTextLength
(
text
);
const
node
=
document
.
createTextNode
(
text
);
sendingNodes
.
push
(
node
);
}
}
if
(
text
)
{
this
.
checkTextLength
(
text
);
const
node
=
document
.
createTextNode
(
text
);
sendingNodes
.
push
(
node
);
}
return
sendingNodes
;
...
...
model/im.ts
View file @
b160ab72
...
...
@@ -174,15 +174,15 @@ export const imItems = [
// 亲亲小保
{
type
:
IMDomainType
.
社保客服
,
title
:
"
社保客服
"
,
title
:
"
在线咨询
"
,
},
{
type
:
IMDomainType
.
pc
网站咨询
,
title
:
"
pc网站
咨询"
,
title
:
"
在线
咨询"
,
},
{
type
:
IMDomainType
.
手机官网咨询
,
title
:
"
手机官网
咨询"
,
title
:
"
在线
咨询"
,
},
{
type
:
IMDomainType
.
问答动态提醒
,
...
...
service/monitor.ts
View file @
b160ab72
...
...
@@ -108,9 +108,17 @@ class WebMonitor {
r
.
config
&&
r
.
config
.
params
&&
msg
.
push
(
`Params:
${
JSON
.
stringify
(
r
.
config
.
params
)}
`
);
r
.
config
&&
r
.
config
.
data
&&
msg
.
push
(
`Payload:
${
JSON
.
stringify
(
r
.
config
.
data
)}
`
);
if
(
r
.
config
&&
r
.
config
.
data
)
{
const
form
=
r
.
config
.
data
as
FormData
;
if
(
form
.
getAll
)
{
const
p
=
form
.
getAll
(
'parameters'
);
for
(
const
item
of
p
)
{
msg
.
push
(
`Payload:
${
item
}
`
);
}
}
else
{
msg
.
push
(
`Payload:
${
JSON
.
stringify
(
r
.
config
.
data
)}
`
);
}
}
msg
.
push
(
`Exception:
${(
...
...
store/index.ts
View file @
b160ab72
...
...
@@ -28,22 +28,24 @@ const UniplatChatModelName = "UniplatChat";
const
model
=
()
=>
Chat
.
getSdk
().
model
(
UniplatChatModelName
);
const
orgId
=
()
=>
Chat
.
getOrgId
()
as
string
;
function
uniqueMessages
(
messages
:
NonNullable
<
ChatStore
.
STATE_CHAT_MSG_HISTORY
>
function
combineMessages
(
items1
:
ChatStore
.
STATE_CHAT_MSG_HISTORY
,
items2
:
ChatStore
.
STATE_CHAT_MSG_HISTORY
,
chat
:
number
)
{
const
arr
=
[...
messages
]
;
return
unique
(
arr
,
function
(
item
,
all
)
{
return
all
.
findIndex
((
k
)
=>
k
.
id
===
item
.
id
);
});
}
function
filterMessages
(
messages
:
NonNullable
<
ChatStore
.
STATE_CHAT_MSG_HISTORY
>
,
chatid
:
number
)
{
return
uniqueMessages
(
Array
.
from
(
messages
)).
filter
(
(
k
)
=>
k
.
chat_id
===
chatid
);
const
set
=
new
Set
<
number
>
()
;
const
items
:
Message
[]
=
[];
for
(
const
item
of
[...
items1
,
...
items2
])
{
if
(
item
.
chat_id
!==
chat
)
{
continue
;
}
const
id
=
item
.
id
;
if
(
!
set
.
has
(
id
))
{
set
.
add
(
id
);
items
.
push
(
item
);
}
}
return
items
.
sort
((
x
,
y
)
=>
(
x
.
id
-
y
.
id
?
1
:
-
1
)
);
}
let
removeRegisterChatEvents
:
(()
=>
void
)[]
=
[];
...
...
@@ -237,7 +239,7 @@ export default {
?
newItems
.
filter
((
i
)
=>
!
withdraw
.
includes
(
i
.
id
))
:
newItems
;
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
=
Object
.
freeze
(
filterMessages
([...
old
,
...
filterout
]
,
chatid
)
combineMessages
(
old
,
filterout
,
chatid
)
);
}
},
...
...
@@ -274,7 +276,7 @@ export default {
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
if
(
!
chatId
)
return
;
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
=
Object
.
freeze
(
filterMessages
([...(
data
||
[]),
...
old
]
,
chatId
)
combineMessages
(
data
||
[],
old
,
chatId
)
);
},
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
](
...
...
@@ -588,7 +590,20 @@ export default {
.
updateChat4UnreadCount
(
p
.
chat
,
p
.
unread
)
.
then
(()
=>
dispatch
(
ChatStore
.
ACTION_REBUILD_UNREAD_MESSAGE_COUNT
)
);
)
.
finally
(()
=>
{
if
(
!
p
.
unread
)
{
const
messages
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
];
if
(
messages
&&
messages
.
length
)
{
xim
.
setRead
(
p
.
chat
,
messages
[
0
].
id
,
messages
[
messages
.
length
-
1
].
id
);
}
}
});
},
async
[
ChatStore
.
ACTION_GET_CHAT_MESSAGES
]({
state
,
commit
,
getters
})
{
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
...
...
@@ -763,7 +778,11 @@ export default {
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
const
onNewMsg
=
(
e
:
Message
)
=>
{
const
thenAction
=
()
=>
{
if
(
e
.
type
===
MessageType
.
Withdraw
)
{
if
(
e
.
type
===
MessageType
.
Withdraw
&&
// 这里再取一次当前chatId避免数据和当前不一致
e
.
chat_id
===
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
)
{
commit
(
ChatStore
.
MUTATION_WITHDRAW
,
xim
.
withDrawMsgHandle
(
e
)
...
...
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