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
6711c5df
authored
Jan 13, 2022
by
董文博
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' of
http://gitlab.corp.qinqinxiaobao.com:9880/uniplat/customer-service
parents
d6f6f97f
64c2972a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
59 additions
and
52 deletions
components/chat-room.vue
components/image-preview.vue
database/index.ts
model/index.ts
service/monitor.ts
store/index.ts
store/model.ts
xim/index.ts
xim/xim.ts
components/chat-room.vue
View file @
6711c5df
...
@@ -56,15 +56,9 @@
...
@@ -56,15 +56,9 @@
@
chatStore
.
State
(
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
)
@
chatStore
.
State
(
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
)
private
readonly
chatId
!
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
;
private
readonly
chatId
!
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
;
@
chatStore
.
Mutation
(
ChatStore
.
MUTATION_CLEAR_CURRENT_CHAT_MEMBERS
)
private
readonly
clearChatMembers
!
:
ChatStore
.
MUTATION_CLEAR_CURRENT_CHAT_MEMBERS
;
@
chatStore
.
State
(
ChatStore
.
STATE_CURRENT_CHAT_INPUTING
)
@
chatStore
.
State
(
ChatStore
.
STATE_CURRENT_CHAT_INPUTING
)
private
readonly
currentInputPeople
!
:
ChatStore
.
STATE_CURRENT_CHAT_INPUTING
;
private
readonly
currentInputPeople
!
:
ChatStore
.
STATE_CURRENT_CHAT_INPUTING
;
@
chatStore
.
State
(
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
)
private
readonly
currentChatUniplatId
!
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
;
@
chatStore
.
State
(
ChatStore
.
STATE_CHAT_CURRENT_IS_CHAT_MEMBER
)
@
chatStore
.
State
(
ChatStore
.
STATE_CHAT_CURRENT_IS_CHAT_MEMBER
)
private
readonly
isChatMember
!
:
ChatStore
.
STATE_CHAT_CURRENT_IS_CHAT_MEMBER
;
private
readonly
isChatMember
!
:
ChatStore
.
STATE_CHAT_CURRENT_IS_CHAT_MEMBER
;
...
@@ -82,12 +76,6 @@
...
@@ -82,12 +76,6 @@
@
Provide
()
showReadSummary
=
true
;
@
Provide
()
showReadSummary
=
true
;
@
Watch
(
"currentChatUniplatId"
)
private
whenCurrentChatIdChanged
(
newValue
:
string
,
oldValue
:
string
)
{
if
(
Number
(
oldValue
)
===
Number
(
newValue
))
return
;
this
.
clearChatMembers
();
}
private
get
getCurrentInputingPeople
()
{
private
get
getCurrentInputingPeople
()
{
return
this
.
currentInputPeople
return
this
.
currentInputPeople
.
map
(()
=>
""
/* this.userInfo[k].name */
)
.
map
(()
=>
""
/* this.userInfo[k].name */
)
...
@@ -174,6 +162,7 @@
...
@@ -174,6 +162,7 @@
),
),
300
300
);
);
this
.
$emit
(
"send"
);
}
}
}
}
</
script
>
</
script
>
...
@@ -184,7 +173,7 @@
...
@@ -184,7 +173,7 @@
width
:
46px
;
width
:
46px
;
height
:
20px
;
height
:
20px
;
line-height
:
20px
;
line-height
:
20px
;
background
:
#22bd7a
;
background
-color
:
#22bd7a
;
font-size
:
13px
;
font-size
:
13px
;
border-radius
:
2px
;
border-radius
:
2px
;
color
:
#ffffff
;
color
:
#ffffff
;
...
...
components/image-preview.vue
View file @
6711c5df
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
width=
"90%"
width=
"90%"
>
>
<div
class=
"d-flex flex-column"
>
<div
class=
"d-flex flex-column"
>
<div
class=
"d-flex justify-content-center"
>
<div
class=
"d-flex justify-content-center
align-items-start
"
>
<img
v-if=
"file"
:src=
"file.url"
/>
<img
v-if=
"file"
:src=
"file.url"
/>
<i
class=
"el-icon-close"
@
click=
"close"
></i>
<i
class=
"el-icon-close"
@
click=
"close"
></i>
</div>
</div>
...
...
database/index.ts
View file @
6711c5df
...
@@ -63,17 +63,17 @@ class ChatCacheDatabaseController {
...
@@ -63,17 +63,17 @@ class ChatCacheDatabaseController {
}
}
resolve
();
resolve
();
};
};
r
.
onsuccess
=
(
e
)
=>
{
r
.
onsuccess
=
e
=>
{
this
.
db
=
(
e
.
target
as
any
).
result
;
this
.
db
=
(
e
.
target
as
any
).
result
;
console
.
log
(
`index database init comepleted`
);
console
.
log
(
`index database init comepleted`
);
setupDb
();
setupDb
();
};
};
r
.
onupgradeneeded
=
(
e
)
=>
{
r
.
onupgradeneeded
=
e
=>
{
this
.
db
=
(
e
.
target
as
any
).
result
;
this
.
db
=
(
e
.
target
as
any
).
result
;
console
.
log
(
`upgrade database comepleted`
);
console
.
log
(
`upgrade database comepleted`
);
setupDb
();
setupDb
();
};
};
r
.
onerror
=
(
e
)
=>
{
r
.
onerror
=
e
=>
{
console
.
log
(
`index database init failed,
${
e
}
`
);
console
.
log
(
`index database init failed,
${
e
}
`
);
this
.
setupError
=
true
;
this
.
setupError
=
true
;
reject
();
reject
();
...
@@ -88,7 +88,7 @@ class ChatCacheDatabaseController {
...
@@ -88,7 +88,7 @@ class ChatCacheDatabaseController {
const
k
=
this
.
buildChatMessageKey
(
chat
);
const
k
=
this
.
buildChatMessageKey
(
chat
);
const
t
=
this
.
messageDatabases
.
get
(
k
);
const
t
=
this
.
messageDatabases
.
get
(
k
);
if
(
!
t
)
{
if
(
!
t
)
{
return
new
Promise
<
void
>
(
(
resolve
)
=>
{
return
new
Promise
<
void
>
(
resolve
=>
{
if
(
this
.
uid
&&
indexedDB
)
{
if
(
this
.
uid
&&
indexedDB
)
{
const
r
=
indexedDB
.
open
(
k
,
this
.
msgVersion
);
const
r
=
indexedDB
.
open
(
k
,
this
.
msgVersion
);
// eslint-disable-next-line @typescript-eslint/no-this-alias
// eslint-disable-next-line @typescript-eslint/no-this-alias
...
@@ -102,17 +102,17 @@ class ChatCacheDatabaseController {
...
@@ -102,17 +102,17 @@ class ChatCacheDatabaseController {
}
}
setTimeout
(()
=>
resolve
(),
200
);
setTimeout
(()
=>
resolve
(),
200
);
};
};
r
.
onsuccess
=
function
(
e
)
{
r
.
onsuccess
=
function
(
e
)
{
const
db
=
(
e
.
target
as
any
).
result
;
const
db
=
(
e
.
target
as
any
).
result
;
that
.
messageDatabases
.
set
(
k
,
db
);
that
.
messageDatabases
.
set
(
k
,
db
);
setupDb
();
setupDb
();
};
};
r
.
onupgradeneeded
=
function
(
e
)
{
r
.
onupgradeneeded
=
function
(
e
)
{
const
db
=
(
e
.
target
as
any
).
result
;
const
db
=
(
e
.
target
as
any
).
result
;
that
.
messageDatabases
.
set
(
k
,
db
);
that
.
messageDatabases
.
set
(
k
,
db
);
setupDb
();
setupDb
();
};
};
r
.
onerror
=
function
(
e
)
{
r
.
onerror
=
function
(
e
)
{
console
.
log
(
console
.
log
(
`chat message index database init failed,
${
e
}
`
`chat message index database init failed,
${
e
}
`
);
);
...
@@ -163,11 +163,11 @@ class ChatCacheDatabaseController {
...
@@ -163,11 +163,11 @@ class ChatCacheDatabaseController {
}
}
public
updateChat
(
p
:
ChatStore
.
ChatUpdateParameter
)
{
public
updateChat
(
p
:
ChatStore
.
ChatUpdateParameter
)
{
return
new
Promise
<
void
>
(
(
resolve
)
=>
{
return
new
Promise
<
void
>
(
resolve
=>
{
if
(
this
.
db
)
{
if
(
this
.
db
)
{
const
store
=
this
.
buildStore
(
this
.
chatListKey
);
const
store
=
this
.
buildStore
(
this
.
chatListKey
);
const
t
=
store
.
get
(
p
.
chat
);
const
t
=
store
.
get
(
p
.
chat
);
t
.
onsuccess
=
(
r
)
=>
{
t
.
onsuccess
=
r
=>
{
const
chat
=
(
r
.
target
as
any
).
result
as
Chat
;
const
chat
=
(
r
.
target
as
any
).
result
as
Chat
;
if
(
chat
)
{
if
(
chat
)
{
chat
.
eid
=
p
.
eid
as
string
;
chat
.
eid
=
p
.
eid
as
string
;
...
@@ -191,11 +191,11 @@ class ChatCacheDatabaseController {
...
@@ -191,11 +191,11 @@ class ChatCacheDatabaseController {
}
}
public
updateChat4UnreadCount
(
chat
:
number
,
unread
:
number
)
{
public
updateChat4UnreadCount
(
chat
:
number
,
unread
:
number
)
{
return
new
Promise
<
void
>
(
(
resolve
)
=>
{
return
new
Promise
<
void
>
(
resolve
=>
{
if
(
this
.
db
)
{
if
(
this
.
db
)
{
const
store
=
this
.
buildStore
(
this
.
chatListKey
);
const
store
=
this
.
buildStore
(
this
.
chatListKey
);
const
t
=
store
.
get
(
chat
);
const
t
=
store
.
get
(
chat
);
t
.
onsuccess
=
(
r
)
=>
{
t
.
onsuccess
=
r
=>
{
const
chat
=
(
r
.
target
as
any
).
result
as
Chat
;
const
chat
=
(
r
.
target
as
any
).
result
as
Chat
;
if
(
chat
)
{
if
(
chat
)
{
chat
.
unread_msg_count
=
unread
;
chat
.
unread_msg_count
=
unread
;
...
@@ -214,11 +214,11 @@ class ChatCacheDatabaseController {
...
@@ -214,11 +214,11 @@ class ChatCacheDatabaseController {
}
}
public
setRead
(
chat
:
number
)
{
public
setRead
(
chat
:
number
)
{
return
new
Promise
<
void
>
(
(
resolve
)
=>
{
return
new
Promise
<
void
>
(
resolve
=>
{
if
(
this
.
db
)
{
if
(
this
.
db
)
{
const
store
=
this
.
buildStore
(
this
.
chatListKey
);
const
store
=
this
.
buildStore
(
this
.
chatListKey
);
const
t
=
store
.
get
(
chat
);
const
t
=
store
.
get
(
chat
);
t
.
onsuccess
=
(
r
)
=>
{
t
.
onsuccess
=
r
=>
{
const
chat
=
(
r
.
target
as
any
).
result
as
Chat
;
const
chat
=
(
r
.
target
as
any
).
result
as
Chat
;
if
(
chat
)
{
if
(
chat
)
{
chat
.
unread_msg_count
=
0
;
chat
.
unread_msg_count
=
0
;
...
@@ -253,7 +253,7 @@ class ChatCacheDatabaseController {
...
@@ -253,7 +253,7 @@ class ChatCacheDatabaseController {
allRead
?:
boolean
;
allRead
?:
boolean
;
}
}
)
{
)
{
return
new
Promise
<
void
>
(
(
resolve
)
=>
{
return
new
Promise
<
void
>
(
resolve
=>
{
if
(
this
.
db
)
{
if
(
this
.
db
)
{
const
store
=
this
.
buildChatMessageStore
(
chat
);
const
store
=
this
.
buildChatMessageStore
(
chat
);
if
(
option
.
end
&&
option
.
end
>
option
.
start
)
{
if
(
option
.
end
&&
option
.
end
>
option
.
start
)
{
...
@@ -267,7 +267,7 @@ class ChatCacheDatabaseController {
...
@@ -267,7 +267,7 @@ class ChatCacheDatabaseController {
};
};
for
(
let
i
=
option
.
start
;
i
<=
option
.
end
;
i
++
)
{
for
(
let
i
=
option
.
start
;
i
<=
option
.
end
;
i
++
)
{
const
r
=
store
.
get
(
i
);
const
r
=
store
.
get
(
i
);
r
.
onsuccess
=
(
m
)
=>
{
r
.
onsuccess
=
m
=>
{
const
p
=
(
m
.
target
as
any
).
result
as
Message
;
const
p
=
(
m
.
target
as
any
).
result
as
Message
;
if
(
p
)
{
if
(
p
)
{
if
(
option
.
allRead
)
{
if
(
option
.
allRead
)
{
...
@@ -284,7 +284,7 @@ class ChatCacheDatabaseController {
...
@@ -284,7 +284,7 @@ class ChatCacheDatabaseController {
}
}
}
else
{
}
else
{
const
r
=
store
.
get
(
option
.
start
);
const
r
=
store
.
get
(
option
.
start
);
r
.
onsuccess
=
(
m
)
=>
{
r
.
onsuccess
=
m
=>
{
const
p
=
(
m
.
target
as
any
).
result
as
Message
;
const
p
=
(
m
.
target
as
any
).
result
as
Message
;
if
(
p
)
{
if
(
p
)
{
if
(
option
.
allRead
)
{
if
(
option
.
allRead
)
{
...
@@ -306,7 +306,7 @@ class ChatCacheDatabaseController {
...
@@ -306,7 +306,7 @@ class ChatCacheDatabaseController {
}
}
public
removeChatFromList
(
chat
:
number
)
{
public
removeChatFromList
(
chat
:
number
)
{
return
new
Promise
<
void
>
(
(
resolve
)
=>
{
return
new
Promise
<
void
>
(
resolve
=>
{
if
(
this
.
db
)
{
if
(
this
.
db
)
{
const
store
=
this
.
buildStore
(
this
.
chatListKey
);
const
store
=
this
.
buildStore
(
this
.
chatListKey
);
const
t
=
store
.
delete
(
chat
);
const
t
=
store
.
delete
(
chat
);
...
@@ -319,27 +319,27 @@ class ChatCacheDatabaseController {
...
@@ -319,27 +319,27 @@ class ChatCacheDatabaseController {
}
}
public
getChatList
()
{
public
getChatList
()
{
return
new
Promise
<
Chat
[]
>
(
(
resolve
)
=>
{
return
new
Promise
<
Chat
[]
>
(
resolve
=>
{
if
(
!
this
.
db
)
{
if
(
!
this
.
db
)
{
return
resolve
([]);
return
resolve
([]);
}
}
const
store
=
this
.
buildStore
(
this
.
chatListKey
);
const
store
=
this
.
buildStore
(
this
.
chatListKey
);
const
r
=
store
.
getAll
();
const
r
=
store
.
getAll
();
r
.
onsuccess
=
(
o
)
=>
resolve
((
o
.
target
as
any
).
result
);
r
.
onsuccess
=
o
=>
resolve
((
o
.
target
as
any
).
result
);
r
.
onerror
=
()
=>
resolve
([]);
r
.
onerror
=
()
=>
resolve
([]);
});
});
}
}
public
getChatByCode
(
code
:
string
)
{
public
getChatByCode
(
code
:
string
)
{
return
new
Promise
<
Chat
|
null
>
(
(
resolve
)
=>
{
return
new
Promise
<
Chat
|
null
>
(
resolve
=>
{
if
(
!
this
.
db
)
{
if
(
!
this
.
db
)
{
return
resolve
(
null
);
return
resolve
(
null
);
}
}
const
store
=
this
.
buildStore
(
this
.
chatListKey
);
const
store
=
this
.
buildStore
(
this
.
chatListKey
);
const
r
=
store
.
getAll
();
const
r
=
store
.
getAll
();
r
.
onsuccess
=
(
o
)
=>
{
r
.
onsuccess
=
o
=>
{
const
items
=
(
o
.
target
as
any
).
result
as
Chat
[];
const
items
=
(
o
.
target
as
any
).
result
as
Chat
[];
resolve
(
items
.
find
(
(
i
)
=>
i
.
biz_type_code
===
code
)
as
Chat
);
resolve
(
items
.
find
(
i
=>
i
.
biz_type_code
===
code
)
as
Chat
);
};
};
r
.
onerror
=
()
=>
resolve
(
null
);
r
.
onerror
=
()
=>
resolve
(
null
);
});
});
...
@@ -364,21 +364,21 @@ class ChatCacheDatabaseController {
...
@@ -364,21 +364,21 @@ class ChatCacheDatabaseController {
}
}
public
getChatMessages
(
chat
:
number
)
{
public
getChatMessages
(
chat
:
number
)
{
return
new
Promise
<
Message
[]
>
(
(
resolve
)
=>
{
return
new
Promise
<
Message
[]
>
(
resolve
=>
{
if
(
!
this
.
db
)
{
if
(
!
this
.
db
)
{
return
resolve
([]);
return
resolve
([]);
}
}
this
.
setupChatMessageDatabase
(
chat
).
finally
(()
=>
{
this
.
setupChatMessageDatabase
(
chat
).
finally
(()
=>
{
const
store
=
this
.
buildChatMessageStore
(
chat
);
const
store
=
this
.
buildChatMessageStore
(
chat
);
const
r
=
store
.
getAll
();
const
r
=
store
.
getAll
();
r
.
onsuccess
=
(
o
)
=>
resolve
((
o
.
target
as
any
).
result
);
r
.
onsuccess
=
o
=>
resolve
((
o
.
target
as
any
).
result
);
r
.
onerror
=
()
=>
resolve
([]);
r
.
onerror
=
()
=>
resolve
([]);
});
});
});
});
}
}
public
appendMessages
(
chat
:
number
,
items
:
Message
[])
{
public
appendMessages
(
chat
:
number
,
items
:
Message
[])
{
return
new
Promise
<
void
>
(
(
resolve
)
=>
{
return
new
Promise
<
void
>
(
resolve
=>
{
if
(
!
this
.
db
||
!
items
||
!
items
.
length
)
{
if
(
!
this
.
db
||
!
items
||
!
items
.
length
)
{
return
resolve
();
return
resolve
();
}
}
...
@@ -413,7 +413,7 @@ class ChatCacheDatabaseController {
...
@@ -413,7 +413,7 @@ class ChatCacheDatabaseController {
public
mergeChatList
(
source1
:
Chat
[],
source2
:
Chat
[])
{
public
mergeChatList
(
source1
:
Chat
[],
source2
:
Chat
[])
{
for
(
const
item
of
source2
)
{
for
(
const
item
of
source2
)
{
const
t
=
source1
.
find
(
(
i
)
=>
i
.
id
===
item
.
id
);
const
t
=
source1
.
find
(
i
=>
i
.
id
===
item
.
id
);
if
(
t
)
{
if
(
t
)
{
item
.
unread_msg_count
=
Math
.
max
(
item
.
unread_msg_count
=
Math
.
max
(
item
.
unread_msg_count
,
item
.
unread_msg_count
,
...
@@ -445,14 +445,14 @@ class ChatCacheDatabaseController {
...
@@ -445,14 +445,14 @@ class ChatCacheDatabaseController {
msg
:
number
,
msg
:
number
,
status
:
MessageHandled
status
:
MessageHandled
)
{
)
{
return
new
Promise
<
void
>
(
(
resolve
)
=>
{
return
new
Promise
<
void
>
(
resolve
=>
{
if
(
!
this
.
db
)
{
if
(
!
this
.
db
)
{
return
resolve
();
return
resolve
();
}
}
this
.
setupChatMessageDatabase
(
chat
).
finally
(()
=>
{
this
.
setupChatMessageDatabase
(
chat
).
finally
(()
=>
{
const
store
=
this
.
buildChatMessageStore
(
chat
);
const
store
=
this
.
buildChatMessageStore
(
chat
);
const
r
=
store
.
get
(
msg
);
const
r
=
store
.
get
(
msg
);
r
.
onsuccess
=
(
o
)
=>
{
r
.
onsuccess
=
o
=>
{
const
p
=
(
o
.
target
as
any
).
result
as
Message
;
const
p
=
(
o
.
target
as
any
).
result
as
Message
;
p
.
handled
=
status
;
p
.
handled
=
status
;
const
u
=
store
.
put
(
p
);
const
u
=
store
.
put
(
p
);
...
...
model/index.ts
View file @
6711c5df
...
@@ -82,6 +82,11 @@ export interface ChatOption {
...
@@ -82,6 +82,11 @@ export interface ChatOption {
message
?:
ChatMessageController
;
message
?:
ChatMessageController
;
avatar
?:
string
;
avatar
?:
string
;
/**
* 禁用IndexDb
*/
disabledIndexDb
?:
boolean
;
}
}
export
interface
ChatMessageController
{
export
interface
ChatMessageController
{
...
...
service/monitor.ts
View file @
6711c5df
import
Axios
,
{
AxiosResponse
}
from
"axios"
;
import
Axios
,
{
AxiosResponse
,
AxiosAdapter
}
from
"axios"
;
import
{
UniplatSdk
}
from
"uniplat-sdk"
;
import
{
UniplatSdk
}
from
"uniplat-sdk"
;
import
{
ImEnvironment
}
from
"../model"
;
import
{
ImEnvironment
}
from
"../model"
;
...
@@ -26,6 +26,7 @@ export interface SdkMonitorOption {
...
@@ -26,6 +26,7 @@ export interface SdkMonitorOption {
userAgent
?:
boolean
;
userAgent
?:
boolean
;
envir
:
ImEnvironment
;
envir
:
ImEnvironment
;
product
:
Product
;
product
:
Product
;
call
?:
(
r
:
any
)
=>
void
;
}
}
class
WebMonitor
{
class
WebMonitor
{
...
@@ -33,6 +34,7 @@ class WebMonitor {
...
@@ -33,6 +34,7 @@ class WebMonitor {
private
envir
=
ImEnvironment
.
Dev
;
private
envir
=
ImEnvironment
.
Dev
;
private
product
=
Product
.
Default
;
private
product
=
Product
.
Default
;
private
readonly
url
=
"https://pre-hrs-monitor.hrs100.com"
;
private
readonly
url
=
"https://pre-hrs-monitor.hrs100.com"
;
private
adapter
:
AxiosAdapter
|
undefined
;
public
updateKey
(
key
:
string
)
{
public
updateKey
(
key
:
string
)
{
this
.
key
=
key
;
this
.
key
=
key
;
...
@@ -42,6 +44,7 @@ class WebMonitor {
...
@@ -42,6 +44,7 @@ class WebMonitor {
private
buildHeaders
()
{
private
buildHeaders
()
{
return
{
return
{
headers
:
{
authorization
:
"cdd0a34e-f537-4e5b-808e-2ba06af21845"
},
headers
:
{
authorization
:
"cdd0a34e-f537-4e5b-808e-2ba06af21845"
},
adapter
:
this
.
adapter
,
};
};
}
}
...
@@ -85,11 +88,17 @@ class WebMonitor {
...
@@ -85,11 +88,17 @@ class WebMonitor {
);
);
}
}
public
useSdk
(
sdk
:
UniplatSdk
,
options
:
SdkMonitorOption
)
{
public
useSdk
(
sdk
:
UniplatSdk
,
options
:
SdkMonitorOption
,
adapter
?:
AxiosAdapter
)
{
this
.
envir
=
options
.
envir
;
this
.
envir
=
options
.
envir
;
this
.
product
=
options
.
product
;
this
.
product
=
options
.
product
;
this
.
adapter
=
adapter
;
sdk
.
events
.
addUniversalErrorResponseCallback
(
sdk
.
events
.
addUniversalErrorResponseCallback
(
(
r
:
AxiosResponse
<
any
>
)
=>
{
(
r
:
AxiosResponse
<
any
>
)
=>
{
options
.
call
&&
options
.
call
(
r
);
if
(
this
.
enable
())
{
if
(
this
.
enable
())
{
const
msg
:
string
[]
=
[];
const
msg
:
string
[]
=
[];
msg
.
push
(
msg
.
push
(
...
@@ -111,12 +120,14 @@ class WebMonitor {
...
@@ -111,12 +120,14 @@ class WebMonitor {
if
(
r
.
config
&&
r
.
config
.
data
)
{
if
(
r
.
config
&&
r
.
config
.
data
)
{
const
form
=
r
.
config
.
data
as
FormData
;
const
form
=
r
.
config
.
data
as
FormData
;
if
(
form
.
getAll
)
{
if
(
form
.
getAll
)
{
const
p
=
form
.
getAll
(
'parameters'
);
const
p
=
form
.
getAll
(
"parameters"
);
for
(
const
item
of
p
)
{
for
(
const
item
of
p
)
{
msg
.
push
(
`Payload:
${
item
}
`
);
msg
.
push
(
`Payload:
${
item
}
`
);
}
}
}
else
{
}
else
{
msg
.
push
(
`Payload:
${
JSON
.
stringify
(
r
.
config
.
data
)}
`
);
msg
.
push
(
`Payload:
${
JSON
.
stringify
(
r
.
config
.
data
)}
`
);
}
}
}
}
...
...
store/index.ts
View file @
6711c5df
This diff is collapsed.
Click to expand it.
store/model.ts
View file @
6711c5df
...
@@ -252,9 +252,6 @@ export namespace ChatStore {
...
@@ -252,9 +252,6 @@ export namespace ChatStore {
keyword
?:
string
keyword
?:
string
)
=>
Promise
<
ChatType
[]
>
;
)
=>
Promise
<
ChatType
[]
>
;
export
const
ACTION_FORCE_RELOAD_CHAT_LIST
=
"重新获取我的会话列表"
;
export
type
ACTION_FORCE_RELOAD_CHAT_LIST
=
()
=>
Promise
<
ChatType
[]
>
;
export
const
ACTION_REBUILD_UNREAD_MESSAGE_COUNT
=
"重新计算未读消息数"
;
export
const
ACTION_REBUILD_UNREAD_MESSAGE_COUNT
=
"重新计算未读消息数"
;
export
type
ACTION_REBUILD_UNREAD_MESSAGE_COUNT
=
()
=>
void
;
export
type
ACTION_REBUILD_UNREAD_MESSAGE_COUNT
=
()
=>
void
;
...
...
xim/index.ts
View file @
6711c5df
...
@@ -58,7 +58,12 @@ class Chat {
...
@@ -58,7 +58,12 @@ class Chat {
option
.
message
&&
(
this
.
messageController
=
option
.
message
);
option
.
message
&&
(
this
.
messageController
=
option
.
message
);
option
.
avatar
!==
undefined
&&
(
this
.
defaultAvatar
=
option
.
avatar
);
option
.
avatar
!==
undefined
&&
(
this
.
defaultAvatar
=
option
.
avatar
);
await
this
.
setupIndexDb
(
option
.
orgId
());
if
(
!
option
.
disabledIndexDb
){
await
this
.
setupIndexDb
(
option
.
orgId
()).
catch
(
err
=>
{
// 必须catch error不然小程序不会向后运行
console
.
error
(
"setupIndexDb Error"
)
});
}
this
.
token
=
async
()
=>
option
.
sdk
().
global
.
jwtToken
;
this
.
token
=
async
()
=>
option
.
sdk
().
global
.
jwtToken
;
tokenManager
.
save
(
this
.
token
);
tokenManager
.
save
(
this
.
token
);
...
@@ -151,7 +156,7 @@ class Chat {
...
@@ -151,7 +156,7 @@ class Chat {
.
finally
(()
=>
{
.
finally
(()
=>
{
this
.
registerXimEvent
();
this
.
registerXimEvent
();
if
(
xim
.
isConnected
())
{
if
(
xim
.
isConnected
())
{
resolve
(
);
setTimeout
(
resolve
,
200
);
}
else
{
}
else
{
reject
(
new
Error
(
`xim is not connected`
));
reject
(
new
Error
(
`xim is not connected`
));
}
}
...
...
xim/xim.ts
View file @
6711c5df
...
@@ -8,7 +8,7 @@ import { Message, NotifyMessage } from "./models/chat";
...
@@ -8,7 +8,7 @@ import { Message, NotifyMessage } from "./models/chat";
import
chat
from
"./index"
;
import
chat
from
"./index"
;
import
{
STATUS
}
from
"xchat-client/dist/xchat"
;
import
{
STATUS
}
from
"xchat-client/dist/xchat"
;
wampDebug
(
tru
e
);
wampDebug
(
fals
e
);
const
DefaultMsgPageSize
=
20
;
const
DefaultMsgPageSize
=
20
;
...
...
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