聊天:订单状态实时展示、图片收发修复、联系打手跳转优化
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
// 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';
|
||||
import { parseOrderCardText } from './group-chat.js';
|
||||
import { persistGroupMeta } from './im-user.js';
|
||||
|
||||
let _globalPrivateHandler = null;
|
||||
let _globalGroupHandler = null;
|
||||
@@ -200,7 +201,9 @@ function disconnectGoEasy(app) {
|
||||
|
||||
async function connectWithIdentity(app, identityType, userId, isAutoRestore = false) {
|
||||
const quanxian = await jianquanxian(app);
|
||||
if (!quanxian.allowed) return Promise.reject(quanxian.reason);
|
||||
if (!quanxian.allowed) {
|
||||
return Promise.reject(new Error(quanxian.reason || '无聊天权限'));
|
||||
}
|
||||
|
||||
app.globalData.goEasyConnection.autoReconnect = true;
|
||||
app.globalData.goEasyConnection.status = 'connecting';
|
||||
@@ -444,14 +447,8 @@ function handleNewMessage(app, message) {
|
||||
function shouldShowNotification(app) {
|
||||
if (app.globalData.messageManager.notificationMuted) return false;
|
||||
if (isDoNotDisturbTime(app)) return false;
|
||||
if (app.globalData.pageState.isInChatPage) {
|
||||
const pages = getCurrentPages();
|
||||
if (pages.length > 0) {
|
||||
const currentPage = pages[pages.length - 1];
|
||||
if (currentPage.data && currentPage.data.currentChatId) {
|
||||
if (isMessageFromCurrentChat(app, currentPage.data.currentChatId)) return false;
|
||||
}
|
||||
}
|
||||
if (app.globalData.pageState.isInChatPage && app.globalData.pageState.currentChatId) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -472,8 +469,16 @@ function isDoNotDisturbTime(app) {
|
||||
}
|
||||
}
|
||||
|
||||
function isMessageFromCurrentChat(app, currentChatId) {
|
||||
return false;
|
||||
function isMessageFromCurrentChat(app, message) {
|
||||
const pageState = app.globalData.pageState || {};
|
||||
if (!pageState.isInChatPage || !pageState.currentChatId) return false;
|
||||
if (message.groupId) {
|
||||
return message.groupId === pageState.currentChatId;
|
||||
}
|
||||
const myId = app.globalData.goEasyConnection?.userId || getCurrentGoEasyUserId();
|
||||
if (!myId) return false;
|
||||
const peerId = message.senderId === myId ? message.receiverId : message.senderId;
|
||||
return peerId === pageState.currentChatId || message.senderId === pageState.currentChatId;
|
||||
}
|
||||
|
||||
function showNotificationDirect(app, data) {
|
||||
@@ -534,6 +539,20 @@ function formatMessageForNotification(message) {
|
||||
}
|
||||
|
||||
function cacheMessage(app, message) {
|
||||
if (message.groupId && message.type === 'text' && message.payload?.text) {
|
||||
const card = parseOrderCardText(message.payload.text);
|
||||
if (card && card.zhuangtai != null) {
|
||||
if (!app.globalData.groupInfoMap) app.globalData.groupInfoMap = {};
|
||||
const meta = {
|
||||
...(app.globalData.groupInfoMap[message.groupId] || {}),
|
||||
orderId: card.orderId,
|
||||
orderZhuangtai: card.zhuangtai,
|
||||
orderDesc: card.jieshao,
|
||||
};
|
||||
app.globalData.groupInfoMap[message.groupId] = meta;
|
||||
persistGroupMeta(app, message.groupId, meta);
|
||||
}
|
||||
}
|
||||
const { latestMessages } = app.globalData.messageManager;
|
||||
latestMessages.unshift({
|
||||
id: message.messageId,
|
||||
|
||||
Reference in New Issue
Block a user