From d3b39a7fbda9639c6b15ac993f59db75dae3b296 Mon Sep 17 00:00:00 2001 From: LiaoYijun Date: Mon, 23 Dec 2024 14:24:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81=E5=8A=9F=E8=83=BD=EF=BC=9B=E6=9C=89?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=89=8D=E8=83=BD=E4=BD=BF=E7=94=A8=EF=BC=9B?= =?UTF-8?q?=20fix:=20=E6=8E=A5=E6=94=B6=E5=9B=BE=E7=89=87=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/AuthStore.js | 5 ++++ src/views/accounts/Profile.jsx | 44 +++++++++++++++++++++++++------- wai-server/core/baileys/index.js | 2 +- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/stores/AuthStore.js b/src/stores/AuthStore.js index 9b842cf..62394e7 100644 --- a/src/stores/AuthStore.js +++ b/src/stores/AuthStore.js @@ -30,6 +30,10 @@ const useAuthStore = create(devtools((set, get) => ({ isPermitted: (perm) => { const { loginUser } = get() + if (perm === PERM_USE_WHATSAPP) { + return ['404', '383', '227'].includes(loginUser.userId) + } + if (perm === PERM_USE_EMAL) { return true//['501', '466', '599', '495', '143', '370', '639', '513', '654', '404', '383', '227'].includes(loginUser.userId) } @@ -79,6 +83,7 @@ const useAuthStore = create(devtools((set, get) => ({ } }), whatsAppBusiness: json.result.whatsappinfo.length > 0 ? json.result.whatsappinfo[0].whatsapp_waba : '', + whatsAppNo: json.result.whatsappinfo.length > 0 ? json.result.whatsappinfo[0].whatsapp_wa : '', accountName: json.result.opicode, username: json.result.nick, avatarUrl: json.result.avatarUrl, diff --git a/src/views/accounts/Profile.jsx b/src/views/accounts/Profile.jsx index 452c144..e33d750 100644 --- a/src/views/accounts/Profile.jsx +++ b/src/views/accounts/Profile.jsx @@ -2,14 +2,19 @@ import { useEffect, useCallback, useState } from 'react' import { Row, Col, Space, Input, Descriptions, Avatar, Tag, Divider, List, App, Button, Flex, Select, Spin, Form, Typography, QRCode, Tooltip } from 'antd' import { UserOutlined, InfoCircleOutlined, ReloadOutlined, CheckCircleFilled } from '@ant-design/icons' import useAuthStore from '@/stores/AuthStore' +import { fetchJSON } from '@/utils/request' +import { Conditional } from '@/components/Conditional' +import { PERM_USE_WHATSAPP } from '@/stores/AuthStore' function Profile() { const { notification } = App.useApp() const [wabaForm] = Form.useForm() - const [loginUser, setWhatsAppBusiness] = useAuthStore((state) => [state.loginUser, state.setWhatsAppBusiness]) + const [loginUser, setWhatsAppBusiness, isPermitted] = useAuthStore((state) => [ + state.loginUser, state.setWhatsAppBusiness, state.isPermitted + ]) - const [text, setText] = useState('') + const [qrCode, setQRCode] = useState('') useEffect(() => { // 测试错误捕获: @@ -36,6 +41,21 @@ function Profile() { }) }, []) + const handelGernaterQR = useCallback(() => { + const phone = loginUser.whatsAppNo + + fetchJSON( + 'http://localhost:3031/api/v1/whatsapp/channels/qrcode', + { phone }) + .then(r => { + console.info(r) + setQRCode(r.result.qr) + }) + .catch(ex => { + console.error(ex) + }) + }, []) + const customStatusRender = (info) => { switch (info.status) { case 'expired': @@ -107,7 +127,7 @@ function Profile() { 商业号身份 }> -
+ + } + /> + diff --git a/wai-server/core/baileys/index.js b/wai-server/core/baileys/index.js index 4e550f6..025afea 100644 --- a/wai-server/core/baileys/index.js +++ b/wai-server/core/baileys/index.js @@ -118,7 +118,7 @@ const createWhatsApp = async (phone) => { logger, // pass this so that baileys can request a reupload of media // that has been deleted - reuploadRequest: sock.updateMediaMessage + reuploadRequest: waSocket.updateMediaMessage } ) // save to file