From 086683f7822d7a2e88a1bb24542a96da1d6f2a8d Mon Sep 17 00:00:00 2001 From: Lei OT Date: Sat, 4 Jan 2025 21:11:10 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E8=AF=B7=E6=B1=82=E7=99=BB=E5=BD=95qrc?= =?UTF-8?q?ode:=20=E5=B7=B2=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/accounts/WAIQRCode.jsx | 5 +++++ wai-server/api/channels/channel.controller.js | 11 ++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/views/accounts/WAIQRCode.jsx b/src/views/accounts/WAIQRCode.jsx index 685353b..5a7273b 100644 --- a/src/views/accounts/WAIQRCode.jsx +++ b/src/views/accounts/WAIQRCode.jsx @@ -31,6 +31,11 @@ const WAIQRCode = ({ ...props }) => { .catch((ex) => { setQRStatus('expired') console.error(ex) + notification.warning({ + placement: 'top', + message: ex.message, + // description: ex.message, + }) }) }, []) diff --git a/wai-server/api/channels/channel.controller.js b/wai-server/api/channels/channel.controller.js index 8d7aa79..a174535 100644 --- a/wai-server/api/channels/channel.controller.js +++ b/wai-server/api/channels/channel.controller.js @@ -7,12 +7,13 @@ const { objectMapper, isEmpty } = require('../../utils/commons.util'); const { domain, name: domainName } = require('../../config').server; exports.newConnect = async ctx => { + const { phone } = ctx.query; + const existsSession = sessionStore.getSession(phone); + if (!isEmpty(existsSession)) { + ctx.assert(null, 400, `WhatsApp ${phone} 已连接`); + // return { phone, session_id: phone, ...existsSession, stauts: 'open', wai_server: domain }; + } try { - const { phone } = ctx.query; - const existsSession = sessionStore.getSession(phone); - if (!isEmpty(existsSession)) { - return { phone, session_id: phone, ...existsSession, stauts: 'open', wai_server: domain }; - } const whatsApp1 = await createWhatsApp(phone); ctx.assert(whatsApp1, 503, 'No available connections'); whatsApp1.start();