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
f129063c
authored
Oct 14, 2021
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
update
parent
c1153f8d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
28 deletions
model/index.ts
store/index.ts
model/index.ts
View file @
f129063c
...
@@ -124,7 +124,12 @@ export interface Message {
...
@@ -124,7 +124,12 @@ export interface Message {
export
type
MessageRequestResult
=
readonly
Message
[];
export
type
MessageRequestResult
=
readonly
Message
[];
export
interface
BaseChatItem
{
export
interface
BaseChatItemBusinessData
{
model_name
:
string
;
obj_id
:
string
;
}
export
interface
BaseChatItem
extends
BaseChatItemBusinessData
{
id
:
number
;
id
:
number
;
org_id
:
string
;
org_id
:
string
;
uid
:
string
;
uid
:
string
;
...
@@ -160,8 +165,6 @@ export interface BaseChatItem {
...
@@ -160,8 +165,6 @@ export interface BaseChatItem {
last_msg_ts
:
number
;
last_msg_ts
:
number
;
members_updated
:
number
;
members_updated
:
number
;
user_updated
:
number
;
user_updated
:
number
;
model_name
:
string
;
obj_id
:
string
;
}
}
export
interface
RawChatItem
extends
BaseChatItem
{
export
interface
RawChatItem
extends
BaseChatItem
{
...
...
store/index.ts
View file @
f129063c
import
Vue
from
"vue"
;
import
Vue
from
"vue"
;
import
{
Module
}
from
"vuex"
;
import
{
Module
}
from
"vuex"
;
import
{
dbController
}
from
"../database"
;
import
{
dbController
}
from
"../database"
;
import
{
ChatMember
,
MessageType
,
ServiceType
,
MessageHandled
,
RawChatItem
}
from
"../model"
;
import
{
ChatMember
,
MessageType
,
ServiceType
,
MessageHandled
,
RawChatItem
,
BaseChatItemBusinessData
,
}
from
"../model"
;
import
{
isAccessibleUrl
}
from
"../service/tools"
;
import
{
isAccessibleUrl
}
from
"../service/tools"
;
import
{
unique
}
from
"../utils"
;
import
{
unique
}
from
"../utils"
;
import
{
getChatModelInfo
}
from
"../utils/chat-info"
;
import
{
getChatModelInfo
}
from
"../utils/chat-info"
;
...
@@ -77,10 +84,7 @@ async function preCacheImgs(msgs?: any[]) {
...
@@ -77,10 +84,7 @@ async function preCacheImgs(msgs?: any[]) {
function
buildChatItem
(
chat
:
RawChatItem
)
{
function
buildChatItem
(
chat
:
RawChatItem
)
{
if
(
!
chat
.
model_name
&&
chat
.
business_data
)
{
if
(
!
chat
.
model_name
&&
chat
.
business_data
)
{
const
b
=
JSON
.
parse
(
chat
.
business_data
)
as
{
const
b
=
JSON
.
parse
(
chat
.
business_data
)
as
BaseChatItemBusinessData
;
model_name
:
string
;
obj_id
:
string
;
};
chat
.
model_name
=
b
.
model_name
;
chat
.
model_name
=
b
.
model_name
;
b
.
obj_id
&&
(
chat
.
obj_id
=
b
.
obj_id
);
b
.
obj_id
&&
(
chat
.
obj_id
=
b
.
obj_id
);
}
}
...
@@ -550,7 +554,10 @@ export default {
...
@@ -550,7 +554,10 @@ export default {
.
createChat
(
true
);
.
createChat
(
true
);
const
chatId
=
Number
(
imChatId
);
const
chatId
=
Number
(
imChatId
);
await
commit
(
ChatStore
.
MUTATION_SHOW_CHAT
,
true
);
await
commit
(
ChatStore
.
MUTATION_SHOW_CHAT
,
true
);
await
dispatch
(
ChatStore
.
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
,
chatId
);
await
dispatch
(
ChatStore
.
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
,
chatId
);
// 打开会话后获取一下会话列表,刷新未读消息
// 打开会话后获取一下会话列表,刷新未读消息
dispatch
(
ChatStore
.
ACTION_GET_MY_CHAT_LIST
);
dispatch
(
ChatStore
.
ACTION_GET_MY_CHAT_LIST
);
},
},
...
@@ -623,19 +630,10 @@ export default {
...
@@ -623,19 +630,10 @@ export default {
return
;
return
;
}
}
const
chat
=
data
.
args
[
0
]
as
RawChatItem
;
const
chat
=
data
.
args
[
0
]
as
RawChatItem
;
if
(
!
chat
.
model_name
&&
chat
.
business_data
)
{
commit
(
const
b
=
JSON
.
parse
(
chat
.
business_data
)
as
{
ChatStore
.
MUTATION_SAVE_SINGLE_CHAT
,
model_name
:
string
;
(
wantedChatRoom
=
buildChatItem
(
chat
))
obj_id
:
string
;
);
};
chat
.
model_name
=
b
.
model_name
;
chat
.
obj_id
=
b
.
obj_id
;
}
wantedChatRoom
=
{
...
chat
,
chat_id
:
chat
.
id
,
}
as
ChatType
;
commit
(
ChatStore
.
MUTATION_SAVE_SINGLE_CHAT
,
wantedChatRoom
);
}
else
{
}
else
{
commit
(
ChatStore
.
MUTATION_CLEAR_SINGLE_CHAT
);
commit
(
ChatStore
.
MUTATION_CLEAR_SINGLE_CHAT
);
}
}
...
@@ -663,7 +661,6 @@ export default {
...
@@ -663,7 +661,6 @@ export default {
);
);
})
})
.
catch
(
console
.
error
);
.
catch
(
console
.
error
);
commit
(
ChatStore
.
MUTATION_INITING_CHAT
);
commit
(
ChatStore
.
MUTATION_INITING_CHAT
);
removeRegisterChatEvents
.
forEach
((
k
)
=>
k
());
removeRegisterChatEvents
.
forEach
((
k
)
=>
k
());
removeRegisterChatEvents
=
[];
removeRegisterChatEvents
=
[];
...
@@ -674,7 +671,7 @@ export default {
...
@@ -674,7 +671,7 @@ export default {
]);
]);
commit
(
commit
(
ChatStore
.
MUTATION_SAVE_CHAT_TITLE
,
ChatStore
.
MUTATION_SAVE_CHAT_TITLE
,
wantedChatRoom
.
title
||
chatId
wantedChatRoom
.
title
||
`会话
${
chatId
}
`
);
);
commit
(
ChatStore
.
MUTATION_INITING_CHAT_DONE
);
commit
(
ChatStore
.
MUTATION_INITING_CHAT_DONE
);
commit
(
ChatStore
.
MUTATION_SCROLL_TO_BOTTOM
);
commit
(
ChatStore
.
MUTATION_SCROLL_TO_BOTTOM
);
...
@@ -688,9 +685,9 @@ export default {
...
@@ -688,9 +685,9 @@ export default {
},
},
async
[
ChatStore
.
ACTION_GET_CHAT_MEMBERS
]({
commit
,
state
})
{
async
[
ChatStore
.
ACTION_GET_CHAT_MEMBERS
]({
commit
,
state
})
{
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
if
(
chatId
==
null
)
return
;
if
(
!
chatId
)
return
;
const
getChatMembersResult
=
await
xim
.
fetchChatMembers
(
chatId
);
const
getChatMembersResult
=
await
xim
.
fetchChatMembers
(
chatId
);
if
(
getChatMembersResult
==
null
)
return
;
if
(
!
getChatMembersResult
)
return
;
const
chatMembers
=
getChatMembersResult
.
args
[
0
]
as
ChatMember
[];
const
chatMembers
=
getChatMembersResult
.
args
[
0
]
as
ChatMember
[];
let
newChatMembers
=
await
Promise
.
all
(
let
newChatMembers
=
await
Promise
.
all
(
chatMembers
.
map
(
async
(
member
)
=>
{
chatMembers
.
map
(
async
(
member
)
=>
{
...
@@ -888,8 +885,10 @@ export default {
...
@@ -888,8 +885,10 @@ export default {
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
](
state
)
{
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
](
state
)
{
// 过滤消息撤回
// 过滤消息撤回
const
msgList
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
??
[];
const
msgList
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
??
[];
const
drawList
=
msgList
.
filter
(
i
=>
i
.
type
===
MessageType
.
Withdraw
).
map
(
i
=>
+
i
.
msg
);
const
drawList
=
msgList
return
msgList
.
filter
(
i
=>
!
drawList
.
includes
(
i
.
id
));
.
filter
((
i
)
=>
i
.
type
===
MessageType
.
Withdraw
)
.
map
((
i
)
=>
+
i
.
msg
);
return
msgList
.
filter
((
i
)
=>
!
drawList
.
includes
(
i
.
id
));
},
},
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
](
state
)
{
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
](
state
)
{
return
state
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]
||
[];
return
state
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]
||
[];
...
...
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