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
23cf5fea
authored
Oct 12, 2021
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
未读消息计数
parent
b707d4d5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
10 deletions
components/controller/chat-list.ts
components/message-list.vue
model/index.ts
store/index.ts
store/model.ts
components/controller/chat-list.ts
View file @
23cf5fea
...
...
@@ -44,6 +44,9 @@ export default class ChatList extends Vue {
@
chatStore
.
Action
(
ChatStore
.
ACTION_UPDATE_CHAT
)
protected
readonly
updateChat
!
:
ChatStore
.
ACTION_UPDATE_CHAT
;
@
chatStore
.
Action
(
ChatStore
.
ACTION_REBUILD_UNREAD_MESSAGE_COUNT
)
protected
readonly
updateUnreadMessageCount
!
:
ChatStore
.
ACTION_REBUILD_UNREAD_MESSAGE_COUNT
;
protected
parseMesage
(
data
:
ChatItem
)
{
if
(
data
.
last_msg_sender
&&
data
.
last_msg_sender
!==
"0"
)
{
if
(
!
this
.
userNames
[
data
.
last_msg_sender
])
{
...
...
components/message-list.vue
View file @
23cf5fea
...
...
@@ -198,6 +198,7 @@ export default class MessageList extends Vue {
this
.
saveScrollToBottomFunc
(
this
.
scrollToNewMsg
);
this
.
scrollToNewMsg
();
setTimeout
(()
=>
this
.
scroll2End
(
200
));
setTimeout
(()
=>
this
.
scroll2End
(
1000
));
}
public
beforeDestroy
()
{
...
...
model/index.ts
View file @
23cf5fea
...
...
@@ -124,7 +124,7 @@ export interface Message {
export
type
MessageRequestResult
=
readonly
Message
[];
export
interface
CreateChatByServicemanRequestResult
{
export
interface
BaseChatItem
{
id
:
number
;
org_id
:
string
;
uid
:
string
;
...
...
@@ -135,7 +135,6 @@ export interface CreateChatByServicemanRequestResult {
app_id
:
string
;
tag
:
string
;
msg_id
:
number
;
ext
:
string
;
exit_msg_id
:
number
;
is_exited
:
boolean
;
dnd
:
number
;
...
...
@@ -144,7 +143,6 @@ export interface CreateChatByServicemanRequestResult {
join_msg_id
:
number
;
last_read_msg_id
:
number
;
biz_id
:
string
;
business_data
:
string
;
is_finish
:
boolean
;
is_deleted
:
boolean
;
is_remove
:
boolean
;
...
...
@@ -164,6 +162,23 @@ export interface CreateChatByServicemanRequestResult {
user_updated
:
number
;
}
export
interface
RawChatItem
extends
BaseChatItem
{
ext
:
string
;
business_data
:
string
;
last_msg_content
:
string
;
}
export
interface
TransferedChatItem
extends
BaseChatItem
{
chat_id
:
number
;
ext
:
string
;
business_data
:
{
detail_name
:
string
;
model_name
:
string
;
obj_id
:
string
;
};
last_msg_content
:
{
text
?:
string
};
}
export
type
ChatMemberExtraInfo
=
{
name
?:
string
;
phone
?:
string
;
...
...
store/index.ts
View file @
23cf5fea
...
...
@@ -2,7 +2,7 @@ import Vue from "vue";
import
{
Module
}
from
"vuex"
;
import
{
dbController
}
from
"../database"
;
import
{
ChatMember
,
ServiceType
,
MessageHandled
}
from
"../model"
;
import
{
ChatMember
,
ServiceType
,
MessageHandled
,
RawChatItem
}
from
"../model"
;
import
{
isAccessibleUrl
}
from
"../service/tools"
;
import
{
unique
}
from
"../utils"
;
import
{
getChatModelInfo
}
from
"../utils/chat-info"
;
...
...
@@ -74,7 +74,7 @@ async function preCacheImgs(msgs: any[]) {
);
}
function
buildChatItem
(
chat
:
any
)
{
function
buildChatItem
(
chat
:
RawChatItem
)
{
let
business_data
;
if
(
chat
.
business_data
)
{
business_data
=
JSON
.
parse
(
chat
.
business_data
);
...
...
@@ -115,6 +115,7 @@ export default {
[
ChatStore
.
STATE_CHAT_CURRENT_USER_TYPE
]:
null
,
[
ChatStore
.
STATE_CHAT_SEND_FAIL_MESSAGE
]:
null
,
[
ChatStore
.
STATE_CHAT_USERNAME
]:
{},
[
ChatStore
.
STATE_CURRENT_UNREAD_MESSAGE_COUNT
]:
0
,
}),
mutations
:
{
[
ChatStore
.
MUTATION_SHOW_CHAT
](
state
,
isSingle
?:
boolean
)
{
...
...
@@ -357,9 +358,16 @@ export default {
},
},
actions
:
{
async
[
ChatStore
.
ACTION_GET_MY_CHAT_LIST
]({
commit
})
{
async
[
ChatStore
.
ACTION_GET_MY_CHAT_LIST
]({
commit
,
state
})
{
let
cache
=
await
dbController
.
getChatList
();
const
buildUnreadMessage
=
(
items
:
ChatType
[])
=>
{
let
sum
=
0
;
items
.
forEach
((
i
)
=>
(
sum
+=
i
.
unread_msg_count
));
state
[
ChatStore
.
STATE_CURRENT_UNREAD_MESSAGE_COUNT
]
=
sum
;
return
items
;
};
if
(
cache
&&
cache
.
length
)
{
commit
(
ChatStore
.
MUTATION_SAVE_CHAT_LIST
,
{
list
:
cache
,
...
...
@@ -377,19 +385,25 @@ export default {
}
});
return
cache
;
return
buildUnreadMessage
(
cache
)
;
}
const
data
=
await
xim
.
fetchChatList
();
if
(
data
==
null
)
return
;
const
chatList
=
data
.
args
[
0
];
const
items
=
chatList
.
map
((
chat
:
any
)
=>
buildChatItem
(
chat
));
const
chatList
=
data
.
args
[
0
]
as
RawChatItem
[]
;
const
items
=
chatList
.
map
((
chat
)
=>
buildChatItem
(
chat
));
dbController
.
saveChatList
(
items
);
commit
(
ChatStore
.
MUTATION_SAVE_CHAT_LIST
,
{
list
:
items
,
total
:
9999
,
});
return
items
;
return
buildUnreadMessage
(
items
);
},
async
[
ChatStore
.
ACTION_REBUILD_UNREAD_MESSAGE_COUNT
]({
state
})
{
let
items
=
await
dbController
.
getChatList
();
let
sum
=
0
;
items
.
forEach
((
i
)
=>
(
sum
+=
i
.
unread_msg_count
));
state
[
ChatStore
.
STATE_CURRENT_UNREAD_MESSAGE_COUNT
]
=
sum
;
},
// async [ChatStore.ACTION_JOIN_CHAT](
// { commit },
...
...
store/model.ts
View file @
23cf5fea
...
...
@@ -81,6 +81,9 @@ export namespace ChatStore {
export
const
STATE_FUNC_ON_NEW_MSG
=
"收到消息回调方法"
;
export
type
STATE_FUNC_ON_NEW_MSG
=
(
e
:
chatDto
.
Message
)
=>
void
;
export
const
STATE_CURRENT_UNREAD_MESSAGE_COUNT
=
"当前未读消息数"
;
export
type
STATE_CURRENT_UNREAD_MESSAGE_COUNT
=
number
;
/* getter */
export
const
GETTER_CURRENT_CHAT_PRESENT_MEMBERS
=
"当前会话未退出的参与者"
;
export
type
GETTER_CURRENT_CHAT_PRESENT_MEMBERS
=
dto
.
ChatMembers
|
null
;
...
...
@@ -243,6 +246,9 @@ export namespace ChatStore {
keyword
?:
string
)
=>
Promise
<
ChatType
[]
>
;
export
const
ACTION_REBUILD_UNREAD_MESSAGE_COUNT
=
"重新计算未读消息数"
;
export
type
ACTION_REBUILD_UNREAD_MESSAGE_COUNT
=
()
=>
void
;
export
const
ACTION_JOIN_CHAT
=
"加入某个会话"
;
export
type
ACTION_JOIN_CHAT
=
(
chatId
:
number
)
=>
void
;
...
...
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