|
@@ -214,9 +214,6 @@ export const useIM = () => {
|
|
|
async function resetConfig () {
|
|
|
try {
|
|
|
const { uid, wssUrl, token } = await getKey()
|
|
|
- if (!wssUrl) {
|
|
|
- return
|
|
|
- }
|
|
|
IM.setUid(uid)
|
|
|
// 单机模式可以直接设置地址
|
|
|
WKSDK.shared().config.addr = 'wss://' + wssUrl// 默认端口为5200 + wsUrl
|
|
@@ -227,6 +224,7 @@ export const useIM = () => {
|
|
|
console.log(error)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return {
|
|
|
resetConfig
|
|
|
}
|
|
@@ -330,26 +328,31 @@ async function syncConversation () {
|
|
|
|
|
|
// 发起聊天
|
|
|
export async function initChart (userId, enterpriseId) {
|
|
|
- const channel = ref()
|
|
|
- // const list = ref([])
|
|
|
- const query = {
|
|
|
- userId,
|
|
|
- enterpriseId
|
|
|
- }
|
|
|
- // 创建聊天频道
|
|
|
- const { data } = await getChatKey(query)
|
|
|
- const { uid } = data
|
|
|
- const _channel = new Channel(uid, ChannelTypePerson)
|
|
|
- channel.value = _channel
|
|
|
- const conversation = WKSDK.shared().conversationManager.findConversation(_channel)
|
|
|
- if(!conversation) {
|
|
|
- // 如果最近会话不存在,则创建一个空的会话
|
|
|
- WKSDK.shared().conversationManager.createEmptyConversation(_channel)
|
|
|
- }
|
|
|
- const res = await getMoreMessages(1, _channel)
|
|
|
- return {
|
|
|
- channel,
|
|
|
- ...res
|
|
|
+ try {
|
|
|
+ const channel = ref()
|
|
|
+ // const list = ref([])
|
|
|
+ const query = {
|
|
|
+ userId,
|
|
|
+ enterpriseId
|
|
|
+ }
|
|
|
+ // 创建聊天频道
|
|
|
+ const { data } = await getChatKey(query)
|
|
|
+ console.log(data, 'data')
|
|
|
+ const { uid } = data
|
|
|
+ const _channel = new Channel(uid, ChannelTypePerson)
|
|
|
+ channel.value = _channel
|
|
|
+ const conversation = WKSDK.shared().conversationManager.findConversation(_channel)
|
|
|
+ if(!conversation) {
|
|
|
+ // 如果最近会话不存在,则创建一个空的会话
|
|
|
+ WKSDK.shared().conversationManager.createEmptyConversation(_channel)
|
|
|
+ }
|
|
|
+ const res = await getMoreMessages(1, _channel)
|
|
|
+ return {
|
|
|
+ channel,
|
|
|
+ ...res
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -382,32 +385,8 @@ export function send (text, _channel, type) {
|
|
|
WKSDK.shared().chatManager.send(_text, _channel)
|
|
|
return
|
|
|
}
|
|
|
- // if (type === 101) {
|
|
|
- // _text = new ObjectContent(text)
|
|
|
- // WKSDK.shared().chatManager.send(_text, _channel)
|
|
|
- // // console.log(_text)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // if (type === 102) {
|
|
|
- // _text = new ObjectContent2(text)
|
|
|
- // WKSDK.shared().chatManager.send(_text, _channel)
|
|
|
- // // console.log(_text)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // // 求职者拒绝面试邀请
|
|
|
- // if (type === 103) {
|
|
|
- // _text = new ObjectContent3(text)
|
|
|
- // WKSDK.shared().chatManager.send(_text, _channel)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // // 求职者接受面试邀请
|
|
|
- // if (type === 104) {
|
|
|
- // _text = new ObjectContent4(text)
|
|
|
- // WKSDK.shared().chatManager.send(_text, _channel)
|
|
|
- // return
|
|
|
- // }
|
|
|
_text = new MessageText(text)
|
|
|
- // console.log(_text)
|
|
|
+ console.log(WKSDK.shared().chatManager, 111111)
|
|
|
WKSDK.shared().chatManager.send(_text, _channel)
|
|
|
}
|
|
|
|