同步聊天修复到根目录pages/utils(与副本工程结构一致)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// utils/chat-core.js
|
||||
import GoEasy from '../static/lib/goeasy-2.13.24.esm.min';
|
||||
import { jianquanxian } from './imAuth/jianquanxian';
|
||||
import { getFreshImUser } from './im-user.js';
|
||||
|
||||
let _globalPrivateHandler = null;
|
||||
let _globalGroupHandler = null;
|
||||
@@ -209,16 +210,22 @@ async function connectWithIdentity(app, identityType, userId, isAutoRestore = fa
|
||||
saveConnectionState(app);
|
||||
|
||||
const uid = wx.getStorageSync('uid');
|
||||
const role = app.globalData.currentRole || identityType || 'normal';
|
||||
const freshUser = getFreshImUser(app, role, uid);
|
||||
const currentUser = app.globalData.currentUser || {
|
||||
id: uid,
|
||||
name: '用户' + (uid ? uid.substring(0, 6) : ''),
|
||||
avatar: app.globalData.ossImageUrl + app.globalData.morentouxiang,
|
||||
name: freshUser.name,
|
||||
avatar: freshUser.avatar,
|
||||
};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.goEasy.connect({
|
||||
id: userId,
|
||||
data: { name: currentUser.name, avatar: currentUser.avatar, identityType },
|
||||
data: {
|
||||
name: freshUser.name || currentUser.name,
|
||||
avatar: freshUser.avatar || currentUser.avatar || (app.globalData.ossImageUrl + app.globalData.morentouxiang),
|
||||
identityType,
|
||||
},
|
||||
onSuccess: () => {
|
||||
app.globalData.goEasyConnection.status = 'connected';
|
||||
app.globalData.goEasyConnection.lastConnectTime = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user