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
284f5a4a
authored
Jul 12, 2021
by
panjiangyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
以来注入
parent
020bfda3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
47 deletions
model/index.ts
store/index.ts
xim/index.ts
model/index.ts
View file @
284f5a4a
import
type
{
UniplatSdk
}
from
"uniplat-sdk"
export
interface
Chat
{
chat_id
:
number
title
:
string
...
...
@@ -40,32 +42,17 @@ export interface ChatOption {
* 长链接chat sdk地址
*/
webSocketUri
:
string
/**
* 基础服务Api地址,开发环境可传空值
*/
serviceBaseUri
:
string
/**
* 通信服务Api地址,开发环境可传空值
*/
chatServiceBaseUri
:
string
/**
* 小站id
*/
stationId
:
number
sdk
:
UniplatSdk
orgId
?:
number
|
string
orgId
:
()
=>
string
|
number
logger
?:
ChatServiceLogger
/**
* 用户映射, key 是 eid,value 是用户名+头像地址
*/
userMapping
?:
{
[
key
:
string
]:
{
name
:
string
;
avatar
:
string
}
}
/**
* 是否来源于桌面用户端
*/
webHost
?:
boolean
}
export
interface
ChatServiceLogger
{
...
...
store/index.ts
View file @
284f5a4a
import
{
Module
}
from
"vuex"
import
{
RootStoreState
}
from
"
../..
/store/model"
import
{
RootStoreState
}
from
"
@
/store/model"
import
{
ChatMember
}
from
"../model"
import
{
ChatStore
,
ChatStoreState
,
ChatStatus
,
ChatMemberType
}
from
"./model"
import
xim
,
{
ChatNotifyListener
}
from
"../xim/xim"
import
{
unique
}
from
"../utils"
import
Chat
from
"../xim"
import
{
decode
}
from
"../utils/jwt"
import
Vue
from
"vue"
import
type
{
UniplatSdk
}
from
"uniplat-sdk"
import
{
Global
}
from
"@/common/global"
import
chatType
from
"../xim/chat-type"
import
{
isAccessibleUrl
}
from
"../service/tools"
import
chat
from
"../xim/"
export
const
ns
=
ChatStore
.
ns
const
sdk
=
()
=>
Vue
.
prototype
.
sdk
as
UniplatSdk
const
global
=
()
=>
Vue
.
prototype
.
global
as
Global
const
sdk
=
chat
.
getSdk
const
UniplatChatModelName
=
"UniplatChat"
const
model
=
()
=>
sdk
().
model
(
UniplatChatModelName
)
const
orgId
=
()
=>
global
().
org
?.
id
??
"0"
const
orgId
=
chat
.
getOrgId
const
getMyinfo
=
(
function
()
{
let
data
return
async
()
=>
{
...
...
xim/index.ts
View file @
284f5a4a
...
...
@@ -3,8 +3,12 @@ import { ChatOption, TokenStringGetter } from "./../model"
import
{
ChatLoggerService
}
from
"./logger"
import
{
EmojiService
}
from
"../service/emoji"
import
tokenManager
from
"./token"
import
type
{
UniplatSdk
}
from
"uniplat-sdk"
class
Chat
{
private
_sdk
:
UniplatSdk
private
_orgId
:
()
=>
string
|
number
=
()
=>
"0"
private
token
!
:
TokenStringGetter
private
userMapping
:
{
[
key
:
string
]:
{
name
:
string
;
avatar
:
string
}
}
=
{}
private
webHost
=
false
...
...
@@ -21,6 +25,8 @@ class Chat {
`You must specify a web socket address for chat service`
)
}
this
.
_sdk
=
option
.
sdk
this
.
_orgId
=
option
.
orgId
// if (option.enterpriseTokenString) {
// this.token = option.enterpriseTokenString
...
...
@@ -29,15 +35,18 @@ class Chat {
tokenManager
.
save
(
this
.
token
)
// }
this
.
userMapping
=
option
.
userMapping
||
{}
// if (option.webHost) {
// this.webHost = option.webHost
// }
// XimService.buildInstance(new XimService(option));
EmojiService
.
raiseOnReady
(
this
.
token
)
return
this
.
initChatSdk
(
option
.
webSocketUri
)
}
public
getSdk
=
()
=>
{
return
this
.
_sdk
}
public
getOrgId
=
()
=>
{
return
this
.
_orgId
()
}
public
isWebHost
()
{
return
this
.
webHost
}
...
...
@@ -76,20 +85,7 @@ class Chat {
}
public
getUserMapping
()
{
return
this
.
userMapping
}
public
appendUserMappingItem
(
eid
:
string
,
name
:
string
,
avatar
:
string
)
{
if
(
this
.
userMapping
[
eid
])
{
if
(
name
)
{
this
.
userMapping
[
eid
].
name
=
name
}
if
(
avatar
)
{
this
.
userMapping
[
eid
].
avatar
=
avatar
}
}
else
{
this
.
userMapping
[
eid
]
=
{
name
,
avatar
}
}
return
{}
}
private
debug
(
message
:
string
)
{
...
...
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