同步聊天修复到根目录pages/utils(与副本工程结构一致)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-06-23 23:30:14 +08:00
parent 033359f6f4
commit 7b3e7a39e9
9 changed files with 258 additions and 65 deletions

View File

@@ -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();