|
@@ -6,7 +6,7 @@ import { getConversationSync, getMessageSync, getChatKey, setUnread, deleteConve
|
|
|
import { Base64 } from 'js-base64'
|
|
|
|
|
|
import { useUserStore } from '@/store/user'
|
|
|
-import { useLoginType } from '@/store/loginType'
|
|
|
+import { isEnterprise } from '@/utils/auth'
|
|
|
import { useIMStore } from '@/store/im'
|
|
|
|
|
|
|
|
@@ -92,14 +92,13 @@ const ConnectStatus = {
|
|
|
// api 接入
|
|
|
export function useDataSource () {
|
|
|
const userStore = useUserStore()
|
|
|
- const loginType = useLoginType()
|
|
|
// 最近会话数据源
|
|
|
WKSDK.shared().config.provider.syncConversationsCallback = async () => {
|
|
|
const query = {
|
|
|
msg_count: 1
|
|
|
}
|
|
|
- if (loginType.loginType === 'enterprise') {
|
|
|
- Object.assign(query, { enterpriseId: userStore.baseInfo.enterpriseId })
|
|
|
+ if (isEnterprise()) {
|
|
|
+ Object.assign(query, { enterpriseId: userStore.entBaseInfo.enterpriseId })
|
|
|
}
|
|
|
const resultConversations = []
|
|
|
const resp = await getConversationSync(query)
|
|
@@ -132,8 +131,8 @@ export function useDataSource () {
|
|
|
limit,
|
|
|
pull_mode,
|
|
|
}
|
|
|
- if (loginType.loginType === 'enterprise') {
|
|
|
- Object.assign(query, { enterpriseId: userStore.baseInfo.enterpriseId })
|
|
|
+ if (isEnterprise()) {
|
|
|
+ Object.assign(query, { enterpriseId: userStore.entBaseInfo.enterpriseId })
|
|
|
}
|
|
|
const resp = await getMessageSync(query)
|
|
|
const messageList = resp && resp["messages"]
|
|
@@ -159,12 +158,13 @@ export function useDataSource () {
|
|
|
|
|
|
async function getKey () {
|
|
|
const userStore = useUserStore()
|
|
|
- const loginType = useLoginType()
|
|
|
+
|
|
|
const keyQuery = {
|
|
|
userId: userStore.accountInfo.userId
|
|
|
}
|
|
|
- if (loginType.loginType === 'enterprise') {
|
|
|
- Object.assign(keyQuery, { enterpriseId: userStore.baseInfo.enterpriseId })
|
|
|
+ if (isEnterprise()) {
|
|
|
+ Object.assign(keyQuery, { enterpriseId: userStore.entBaseInfo.enterpriseId })
|
|
|
+ console.log('企业模式', keyQuery)
|
|
|
}
|
|
|
const { uid, wsUrl, token } = await getChatKey(keyQuery)
|
|
|
return {
|
|
@@ -203,7 +203,7 @@ export const useIM = () => {
|
|
|
})
|
|
|
|
|
|
async function messageListen (message) {
|
|
|
- // console.log('收到消息', message)
|
|
|
+ console.log('收到消息', message)
|
|
|
IM.setFromChannel(message.channel.channelID)
|
|
|
setUnreadCount()
|
|
|
}
|