From 164d09fc6ddf5b5ffe3da5767d418933bf0e4126 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Tue, 29 Oct 2024 14:54:49 +0800 Subject: [PATCH 1/6] 1.1.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fd5018c..61fc932 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "global-sales", "private": true, - "version": "1.1.3", + "version": "1.1.4", "type": "module", "scripts": { "dev": "vite", From 1ef696cb193cfd91f6fccef3d21528bcc4c5b5fe Mon Sep 17 00:00:00 2001 From: Lei OT Date: Tue, 5 Nov 2024 11:46:49 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix:=20=E5=88=9B=E5=BB=BA=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?,=20=E6=B2=A1=E6=9C=89user=20ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useConversation.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hooks/useConversation.js b/src/hooks/useConversation.js index 7f2c693..d55b92d 100644 --- a/src/hooks/useConversation.js +++ b/src/hooks/useConversation.js @@ -1,3 +1,4 @@ +import useAuthStore from '@/stores/AuthStore'; import useConversationStore from '@/stores/ConversationStore'; import { fetchOrderConversationsList, postNewConversationItem } from '@/actions/ConversationActions'; import { isEmpty } from '@/utils/commons'; @@ -8,6 +9,7 @@ export function useConversationNewItem() { ]); const conversationsList = useConversationStore((state) => state.conversationsList); const addToConversationList = useConversationStore((state) => state.addToConversationList); + const userId = useAuthStore((state) => state.loginUser.userId); /** * 打开订单的会话, 不存在自动新增 */ @@ -42,7 +44,7 @@ export function useConversationNewItem() { const newConversation = async (whatsappID, whatsappName = '') => { const { opi_sn } = currentConversation; const newChat = { phone_number: whatsappID, remark_name: whatsappName }; - const createdNew = await postNewConversationItem({ ...newChat, opi_sn: opi_sn }); + const createdNew = await postNewConversationItem({ ...newChat, opi_sn: opi_sn || userId }); addToConversationList([createdNew]); setCurrentConversation(createdNew); }; From 2c1fd18770c8eb44aa7cc5bacc8503df3ddd65cf Mon Sep 17 00:00:00 2001 From: Lei OT Date: Tue, 5 Nov 2024 11:47:25 +0800 Subject: [PATCH 3/6] 1.1.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 61fc932..c3bf385 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "global-sales", "private": true, - "version": "1.1.4", + "version": "1.1.5", "type": "module", "scripts": { "dev": "vite", From 3cdd7759d199ebf1faba6b335fbea9eb26a7cff5 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Fri, 15 Nov 2024 11:49:26 +0800 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E9=92=89?= =?UTF-8?q?=E9=92=89=E5=85=8D=E7=99=BB=E8=B0=83=E8=AF=95=20auth-code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.jsx | 2 ++ src/views/dingding/AuthCode.jsx | 46 +++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/views/dingding/AuthCode.jsx diff --git a/src/main.jsx b/src/main.jsx index 6a963a6..aa0382c 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -25,6 +25,7 @@ import ChatAssign from '@/views/Conversations/ChatAssign'; import DingdingLogin from '@/views/dingding/Login' import DingdingQRCode from '@/views/dingding/QRCode' +import DingdingAuthCode from '@/views/dingding/AuthCode' import useAuthStore from '@/stores/AuthStore' import '@/assets/index.css' @@ -87,6 +88,7 @@ const router = createBrowserRouter([ { path: 'dingding/logout', element: }, { path: 'dingding/callback', element: }, { path: 'dingding/qr-code', element: }, + { path: 'dingding/auth-code', element: }, ], }, ]); diff --git a/src/views/dingding/AuthCode.jsx b/src/views/dingding/AuthCode.jsx new file mode 100644 index 0000000..f14e1e6 --- /dev/null +++ b/src/views/dingding/AuthCode.jsx @@ -0,0 +1,46 @@ +import { Flex, Result, Spin } from 'antd' +import { useState, useEffect } from 'react' +import { useNavigate } from 'react-router-dom' +import { isNotEmpty } from '@/utils/commons' +import * as dd from 'dingtalk-jsapi' + +// 获取微应用免登授权码 +// https://open.dingtalk.com/document/orgapp/jsapi-request-auth-code +function AuthCode() { + + const [result, setResult] = useState('') + + + useEffect(() => { + const dingTalkPlatForm = dd.env.platform + + if (dingTalkPlatForm === 'notInDingTalk') { + setResult(dingTalkPlatForm) + } else { + dd.requestAuthCode({ + clientId: 'dingwgdx6emlxr3fcrg8', + corpId: 'ding48bce8fd3957c96b', + success: (res) => { + const { code } = res + setResult(code) + }, + fail: (error) => { + setResult(JSON.stringify(error)) + }, + complete: () => {}, + }) + } + }, []) + + return ( + + + + ) +} + +export default AuthCode From ecf39d3da18981076fd5f7165251131d550e3e65 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Fri, 15 Nov 2024 11:50:06 +0800 Subject: [PATCH 5/6] 1.1.6-0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c3bf385..7c76346 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "global-sales", "private": true, - "version": "1.1.5", + "version": "1.1.6-0", "type": "module", "scripts": { "dev": "vite", From 36fbaddf318a3d3582454bdfc898f512cbcfbd2d Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Fri, 15 Nov 2024 14:09:07 +0800 Subject: [PATCH 6/6] =?UTF-8?q?feat:=20=E5=8F=AF=E4=BB=A5=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=20clientId=20=E8=AF=B7=E6=B1=82=20authCode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 ++- src/views/dingding/AuthCode.jsx | 40 +++++++++++++++++---------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 7c76346..7894d79 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "rxjs": "^7.8.1", "uuid": "^9.0.1", "vite-plugin-pwa": "^0.19.6", - "zustand": "^4.5.0" + "zustand": "^4.5.0", + "dingtalk-jsapi": "^3.0.38" }, "devDependencies": { "@types/react": "^18.2.15", diff --git a/src/views/dingding/AuthCode.jsx b/src/views/dingding/AuthCode.jsx index f14e1e6..3d5790c 100644 --- a/src/views/dingding/AuthCode.jsx +++ b/src/views/dingding/AuthCode.jsx @@ -1,44 +1,46 @@ -import { Flex, Result, Spin } from 'antd' +import { Flex, Result, Input, Button } from 'antd' import { useState, useEffect } from 'react' import { useNavigate } from 'react-router-dom' import { isNotEmpty } from '@/utils/commons' import * as dd from 'dingtalk-jsapi' +import { handleNotification } from '@/channel/whatsappUtils' // 获取微应用免登授权码 // https://open.dingtalk.com/document/orgapp/jsapi-request-auth-code function AuthCode() { const [result, setResult] = useState('') + const [clientValue, setClientValue] = useState('dingwgdx6emlxr3fcrg8') + const handleRequest = () => { + dd.requestAuthCode({ + clientId: clientValue, + corpId: 'ding48bce8fd3957c96b', + success: (res) => { + const { code } = res + setResult(code) + }, + fail: (error) => { + setResult(JSON.stringify(error)) + }, + complete: () => {}, + }) + } useEffect(() => { const dingTalkPlatForm = dd.env.platform - - if (dingTalkPlatForm === 'notInDingTalk') { - setResult(dingTalkPlatForm) - } else { - dd.requestAuthCode({ - clientId: 'dingwgdx6emlxr3fcrg8', - corpId: 'ding48bce8fd3957c96b', - success: (res) => { - const { code } = res - setResult(code) - }, - fail: (error) => { - setResult(JSON.stringify(error)) - }, - complete: () => {}, - }) - } + setResult(dingTalkPlatForm) }, []) return ( + setClientValue(e.currentTarget.value)} /> + ) }