From 78266378ff6ef668299456b53bd4fff47b9088c2 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Mon, 28 Oct 2024 10:19:18 +0800 Subject: [PATCH 01/10] =?UTF-8?q?feat:=20DefaultValuePlugin=20=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BC=E5=8F=AA=E7=94=A8=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=EF=BC=9BOnChangePlugin=20=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E5=BF=BD=E7=95=A5=E9=80=89=E6=8B=A9=E6=96=87=E6=9C=AC=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/LexicalEditor/Index.jsx | 64 +++++++++++++++++--------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/src/components/LexicalEditor/Index.jsx b/src/components/LexicalEditor/Index.jsx index 5ec8e92..2e4312c 100644 --- a/src/components/LexicalEditor/Index.jsx +++ b/src/components/LexicalEditor/Index.jsx @@ -43,6 +43,7 @@ import {useLexicalEditable} from '@lexical/react/useLexicalEditable'; import { $getRoot, $getSelection, $createParagraphNode } from 'lexical'; import { $generateHtmlFromNodes, $generateNodesFromDOM, } from '@lexical/html'; // import { } from '@lexical/clipboard'; +import { isEmpty } from '@/utils/commons'; import './styles.css'; @@ -87,7 +88,9 @@ function LexicalDefaultValuePlugin({ value = "" }= {}) { if (clear) { root.clear(); } - // console.log(nodes); + console.log('default value:'); + console.log(value); + console.log(isEmpty(value)) const p = $createParagraphNode(); const _p = nodes.filter(n => n).forEach((n) => { @@ -100,41 +103,56 @@ function LexicalDefaultValuePlugin({ value = "" }= {}) { // root.append(...nodes.filter(n => n)); }; + // 默认值设置只用初始化一次; + // 空值不更新 HTML; useEffect(() => { - if (editor && value) { + if (editor && !isEmpty(value)) { editor.update(() => { updateHTML(editor, value, true); }); } - }, [value]); + }, []); return null; } -function MyOnChangePlugin({ onChange }) { +function MyOnChangePlugin({ ignoreHistoryMergeTagChange = true, ignoreSelectionChange = true, onChange }) { const [editor] = useLexicalComposerContext(); useEffect(() => { - return editor.registerUpdateListener(({ editorState }) => { - // const editorStateJSON = editorState.toJSON(); - let html; - let textContent; - editorState.read(() => { - const root = $getRoot(); - const textContent = root.getTextContent(); - // console.log('textContent', textContent); - - const html = $generateHtmlFromNodes(editor); - // console.log('html', html); - - // setEditorContent(content); - if (typeof onChange === 'function') { - onChange({ editorState, html, textContent }); + if (onChange) { + return editor.registerUpdateListener(({editorState, dirtyElements, dirtyLeaves, prevEditorState, tags}) => { + + if ( + (ignoreSelectionChange && + dirtyElements.size === 0 && + dirtyLeaves.size === 0) || + (ignoreHistoryMergeTagChange && tags.has('history-merge')) || + prevEditorState.isEmpty() + ) { + return; } + // const editorStateJSON = editorState.toJSON(); + let html; + let textContent; + editorState.read(() => { + const root = $getRoot(); + const textContent = root.getTextContent(); + // console.log('textContent', textContent); + + const html = $generateHtmlFromNodes(editor); + // console.log('html', html); + + // setEditorContent(content); + if (typeof onChange === 'function') { + onChange({ editorState, editor, tags, html, textContent }); + } + }); }); - }); - }, [editor, onChange]); + } + }, [editor, ignoreHistoryMergeTagChange, ignoreSelectionChange, onChange]); + return null; } -export default function Editor({ isRichText, editorRef, onChange, initialValue, ...props }) { +export default function Editor({ isRichText, isDebug, editorRef, onChange, initialValue, ...props }) { return (
@@ -147,7 +165,7 @@ export default function Editor({ isRichText, editorRef, onChange, initialValue, } ErrorBoundary={LexicalErrorBoundary} /> )} - {import.meta.env.DEV && } + {(import.meta.env.DEV && isDebug) && } From a0b30071c0061e5a350b2cb454eed60f2044ce7b Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Mon, 28 Oct 2024 10:51:39 +0800 Subject: [PATCH 02/10] =?UTF-8?q?feat:=20=E5=B0=81=E8=A3=85=20LexicalEdito?= =?UTF-8?q?rInput?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/LexicalEditor/Index.jsx | 3 - src/views/accounts/LexicalEditorInput.jsx | 27 +++ src/views/accounts/SnippetList.jsx | 248 +++++++++++++++------- 3 files changed, 199 insertions(+), 79 deletions(-) create mode 100644 src/views/accounts/LexicalEditorInput.jsx diff --git a/src/components/LexicalEditor/Index.jsx b/src/components/LexicalEditor/Index.jsx index 2e4312c..26bc9c9 100644 --- a/src/components/LexicalEditor/Index.jsx +++ b/src/components/LexicalEditor/Index.jsx @@ -88,9 +88,6 @@ function LexicalDefaultValuePlugin({ value = "" }= {}) { if (clear) { root.clear(); } - console.log('default value:'); - console.log(value); - console.log(isEmpty(value)) const p = $createParagraphNode(); const _p = nodes.filter(n => n).forEach((n) => { diff --git a/src/views/accounts/LexicalEditorInput.jsx b/src/views/accounts/LexicalEditorInput.jsx new file mode 100644 index 0000000..96bf222 --- /dev/null +++ b/src/views/accounts/LexicalEditorInput.jsx @@ -0,0 +1,27 @@ +import LexicalEditor from '@/components/LexicalEditor' + +const LexicalEditorInput = (props) => { + const { id, value = {}, onChange } = props + + const triggerChange = (changedValue) => { + onChange?.({ + ...value, + ...changedValue, + }) + } + + return ( + { + triggerChange({ + html: val.html, + }) + }} + initialValue={value} + /> + ) +} + +export default LexicalEditorInput diff --git a/src/views/accounts/SnippetList.jsx b/src/views/accounts/SnippetList.jsx index f7d3232..e0683b0 100644 --- a/src/views/accounts/SnippetList.jsx +++ b/src/views/accounts/SnippetList.jsx @@ -1,94 +1,190 @@ -import { Conditional } from '@/components/Conditional' -import useAuthStore from '@/stores/AuthStore' -import useFormStore from '@/stores/FormStore' -import { useOrderStore } from '@/stores/OrderStore' -import { copy, isNotEmpty, isEmpty } from '@/utils/commons' -import { WhatsAppOutlined } from '@ant-design/icons' -import { Row, Col, Tag, List, Form, Input, Button, Space } from 'antd' -import dayjs from 'dayjs' -import { useCallback, useEffect, useState, useRef } from 'react' -import { Link } from 'react-router-dom' +import { Row, Col, Tag, List, Form, Input, Button, Space, Modal } from 'antd' +import { useState, useRef } from 'react' import LexicalEditor from '@/components/LexicalEditor' -import {$generateNodesFromDOM} from '@lexical/html' +import LexicalEditorInput from './LexicalEditorInput' function SnippetList() { const [form] = Form.useForm() + const [snippetForm] = Form.useForm() const editorRef = useRef(null) - const [editorContent, setEditorContent] = useState('initialContent') + + const [isSnippetModalOpen, setSnippetModalOpen] = useState(false) + const [editorContent, setEditorContent] = useState("

Discover the best of the world with one of the best-rated tour companies for personalized travel. With over 10,000+ reviews and a 98.8% 5-star rating, we focus on streamlining your planning and ensuring joyful travels. Whether it's a milestone celebration or a relaxing getaway, let us help create your beautiful journey.

") + + + + const onSnippetFinish = (values) => { + console.log('onSnippetFinish:', values) + + // console.info(JSON.stringify(editorRef.current.getEditorState())) + } + + const onSnippetFailed = (error) => { + console.log('Failed:', error) + // form.resetFields() + } return ( <> - -
- - - - - + setSnippetModalOpen(false)} + destroyOnClose + forceRender + modalRender={(dom) => ( + + {dom} + + )} + > + + + - - + + {/* { + console.info('onChange') + }} + initialValue={editorContent} + /> */} + - - - - - - - - - - - - - ( - { - console.info(item) - setEditorContent('' + item + '') + +
+ + + + + + + + + + + + + + + + + + +
+ + + ( + { + console.info(item) + setEditorContent('' + item + '') + }}> + + + 类型 + {item} + + +
王静
+ +
+
+ )} + /> + + + +
+
           

Discover China with the award-winning and best-rated tour company for personalized travel in China. Honored as China's Leading Tour Operator by the World Travel Awards, we boast 10,000+ reviews and a remarkable 98.8% 5-star rating. Our expertise in customizing personalized China explorations is backed by our company-managed local services across China. Explore and kickstart your personalized travel experience with just a click!

- {console.info('onChange')}} initialValue={editorContent} /> - - +
+ +
+ +
) From 378da335d0a407e5eed7dc88db7ba98639c6c7bb Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Mon, 28 Oct 2024 14:14:05 +0800 Subject: [PATCH 03/10] =?UTF-8?q?fix:=E8=A7=A3=E5=86=B3=20EditorInput=20?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=98=BE=E7=A4=BA=20[object]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/accounts/LexicalEditorInput.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/accounts/LexicalEditorInput.jsx b/src/views/accounts/LexicalEditorInput.jsx index 96bf222..1eb7d26 100644 --- a/src/views/accounts/LexicalEditorInput.jsx +++ b/src/views/accounts/LexicalEditorInput.jsx @@ -19,7 +19,7 @@ const LexicalEditorInput = (props) => { html: val.html, }) }} - initialValue={value} + initialValue={value.html} /> ) } From 5ec4720c1e80d853abdba6e6a0ab160e8d599e0c Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Mon, 28 Oct 2024 15:18:36 +0800 Subject: [PATCH 04/10] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=20Ant=20Modal?= =?UTF-8?q?=20=E4=BD=BF=E7=94=A8=20Lexical=20Editor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/LexicalEditor/styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/LexicalEditor/styles.css b/src/components/LexicalEditor/styles.css index b06cd5b..e71578c 100644 --- a/src/components/LexicalEditor/styles.css +++ b/src/components/LexicalEditor/styles.css @@ -568,7 +568,7 @@ i.chevron-down { } .dropdown { - z-index: 5; + z-index: 1001; /* Ant Modal z-index: 1000, 大于它才能使用在 Modal */ display: block; position: absolute; box-shadow: 0 12px 28px 0 rgba(0, 0, 0, 0.2), 0 2px 4px 0 rgba(0, 0, 0, 0.1), From e37a454fcf8e64ee3431f50e22ee4676b9b54592 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Tue, 29 Oct 2024 11:44:58 +0800 Subject: [PATCH 05/10] =?UTF-8?q?feat:=20=E5=9B=BE=E6=96=87=E9=9B=86?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=93=8D=E4=BD=9C=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/accounts/Profile.jsx | 14 ++-- src/views/accounts/SnippetList.jsx | 128 ++++++++++++++++++++--------- 2 files changed, 94 insertions(+), 48 deletions(-) diff --git a/src/views/accounts/Profile.jsx b/src/views/accounts/Profile.jsx index f1dae12..8e20cf7 100644 --- a/src/views/accounts/Profile.jsx +++ b/src/views/accounts/Profile.jsx @@ -56,35 +56,35 @@ function Profile() {
+ )}> + + + + ]}> + + + - {/* { - console.info('onChange') - }} - initialValue={editorContent} - /> */} - + ]}> +
@@ -165,24 +183,52 @@ function SnippetList() { )} /> - + +
-
-
-          

Discover China with the award-winning and best-rated tour company for personalized travel in China. Honored as China's Leading Tour Operator by the World Travel Awards, we boast 10,000+ reviews and a remarkable 98.8% 5-star rating. Our expertise in customizing personalized China explorations is backed by our company-managed local services across China. Explore and kickstart your personalized travel experience with just a click!

-
+ direction='vertical' + size='middle' + style={{ + display: 'flex', + }}> +
+                  

+ Discover China with the award-winning and{' '} + best-rated tour company for{' '} + personalized travel in China. Honored as{' '} + China is Leading Tour Operator by the{' '} + World Travel Awards, we boast{' '} + 10,000+ reviews and a remarkable{' '} + 98.8% 5-star rating. Our expertise in + customizing personalized China explorations is backed by our + company-managed local services across China. Explore and + kickstart your personalized travel experience with just a + click! +

+
+ + + + + +
- - -
From b20ee4c46be869dc41345534659f9456ebdcc4af Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Tue, 29 Oct 2024 14:53:35 +0800 Subject: [PATCH 06/10] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E9=92=89?= =?UTF-8?q?=E9=92=89authcode=E8=B0=83=E8=AF=95=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.jsx | 3 ++ src/views/dingding/QRCode.jsx | 65 +++++++++++------------------------ 2 files changed, 24 insertions(+), 44 deletions(-) diff --git a/src/main.jsx b/src/main.jsx index 3680e42..6a963a6 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -24,6 +24,7 @@ import Unassign from '@/views/ChatUnassign'; import ChatAssign from '@/views/Conversations/ChatAssign'; import DingdingLogin from '@/views/dingding/Login' +import DingdingQRCode from '@/views/dingding/QRCode' import useAuthStore from '@/stores/AuthStore' import '@/assets/index.css' @@ -80,10 +81,12 @@ const router = createBrowserRouter([ { path: '/p', element: , + errorElement: , children: [ { path: 'dingding/login', element: }, { path: 'dingding/logout', element: }, { path: 'dingding/callback', element: }, + { path: 'dingding/qr-code', element: }, ], }, ]); diff --git a/src/views/dingding/QRCode.jsx b/src/views/dingding/QRCode.jsx index 6a6c77e..6687d65 100644 --- a/src/views/dingding/QRCode.jsx +++ b/src/views/dingding/QRCode.jsx @@ -1,6 +1,6 @@ import useAuthStore from '@/stores/AuthStore' import { Flex, Result, Spin, Typography } from 'antd' -import { useEffect } from 'react' +import { useEffect, useState } from 'react' import { useNavigate } from 'react-router-dom' const { Title } = Typography @@ -10,16 +10,18 @@ const { Title } = Typography function QRCode() { const navigate = useNavigate() - - const loginStatus = useAuthStore((state) => state.loginStatus) - const setLoginStatus = useAuthStore((state) => state.setLoginStatus) - const loginUser = useAuthStore((state) => state.loginUser) - const login = useAuthStore((state) => state.login) + + const [result, setResult] = useState('') + + // const loginStatus = useAuthStore((state) => state.loginStatus) + // const setLoginStatus = useAuthStore((state) => state.setLoginStatus) + // const loginUser = useAuthStore((state) => state.loginUser) + // const login = useAuthStore((state) => state.login) useEffect(() => { - if (loginUser.userId > 0) { - navigate('/') - } + // if (loginUser.userId > 0) { + // navigate('/') + // } }, []) useEffect(() => { @@ -40,49 +42,24 @@ function QRCode() { }, (loginResult) => { const { authCode } = loginResult - login(authCode) + // login(authCode) + setResult(authCode) }, (errorMsg) => { - setLoginStatus(403) + // setLoginStatus(403) console.error(`Login Error: ${errorMsg}`) }, ) }) }, []) - if (loginStatus === 200) { - return ( - - - ]} - /> - - ) - } else if (loginStatus === 302) { - navigate('/') - } else if (loginStatus === 403) { - return ( - - - - ) - } else { - return ( - - 使用钉钉扫码 -
-
- ) - } + return ( + + 使用钉钉扫码 +
+ 钉钉 authCode: {result} +
+ ) } export default QRCode \ No newline at end of file From 85c089cf7045d7141a4d3cfc98e4b12dc22026b6 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Wed, 30 Oct 2024 16:55:18 +0800 Subject: [PATCH 07/10] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E7=99=BB=E5=BD=95=E5=8A=9F=E8=83=BD=EF=BC=9B=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=95=86=E4=B8=9A=E5=8F=B7=E3=80=81=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=20WA=20=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 16 ++- src/views/accounts/Profile.jsx | 201 +++++++++++++++++++++------------ src/views/dingding/QRCode.jsx | 37 ++++-- 3 files changed, 170 insertions(+), 84 deletions(-) diff --git a/README.md b/README.md index 34fd7e8..5cd22a9 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,17 @@ # Global sales -聊天式销售平台 + +销售平台 2.0 ## 开发设置 +所有命令都在 cmd 目录, + 1. 安装组件:npm install -2. 运行开发环境:npm run dev 或者 start.bat -3. 打包代码:npm run build 或者 build.bat +2. 运行开发环境:dev.bat +3. 打包代码:build.bat ## 版本设置 + npm version [ | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git] npm version premajor --no-git-tag-version @@ -22,5 +26,11 @@ npm version patch --no-git-tag-version [聊天式销售平台需求文档](https://www.kdocs.cn/l/calaUjgmCmDA?from=docs&reqtype=kdocs&startTime=1703645330177&createDirect=true&newFile=true) ## vonage语音视频 + 安装模块 npm i @vonage/client-sdk +## 本机测试账号 + +GLOBAL_SALES_LOGIN_USER +{"userId":"383","userIdStr":"383,609","username":"廖一军","avatarUrl":"https://static-legacy.dingtalk.com/media/lALPBDDrhXr716HNAoDNAoA_640_640.png","mobile":"+86-18777396951","email":"lyj@hainatravel.com","openId":"iioljiPmZ4RPoOYpkFiSn7IKAiEiE","accountList":[{"OPI_SN":383,"OPI_Code":"LYJ","OPI_NameCN":"廖一军","OPI_DEI_SN":7,"OPI_NameEN":"Jimmy Liow"},{"OPI_SN":609,"OPI_Code":"LYJAH","OPI_NameCN":"廖一军(ah)","OPI_DEI_SN":28,"OPI_NameEN":"Jimmy Liow"}],"emailList":["lyj@hainatravel.com","lyj@asiahighlights.com","lyj@chinahighlights.net","lyj@globalhighlights.com"],"whatsappinfo": {"whatsapp_wa": "8617607730395","whatsapp_waba": "8618174165365"}} + diff --git a/src/views/accounts/Profile.jsx b/src/views/accounts/Profile.jsx index 8e20cf7..c092608 100644 --- a/src/views/accounts/Profile.jsx +++ b/src/views/accounts/Profile.jsx @@ -10,25 +10,78 @@ import { List, Result, Button, - Image, + Flex, Select, + Spin, + Form, + Typography, + QRCode, } from 'antd' -import { UserOutlined } from '@ant-design/icons' +import { + UserOutlined, + InfoCircleOutlined, + CloseCircleFilled, + ReloadOutlined, + CheckCircleFilled, +} from '@ant-design/icons' import useAuthStore from '@/stores/AuthStore' function Profile() { const loginUser = useAuthStore((state) => state.loginUser) useEffect(() => { + console.info(loginUser) // 测试错误捕获: // throw new Error('💥 CABOOM 💥') + // eslint-disable-next-line react-hooks/exhaustive-deps }, []) + const customStatusRender = (info) => { + switch (info.status) { + case 'expired': + return ( +
+ {' '} + {info.locale?.expired} +

+ +

+
+ ) + case 'loading': + return ( + + +

Loading...

+
+ ) + case 'scanned': + return ( +
+ {' '} + {info.locale?.scanned} +
+ ) + default: + return null + } + } + return ( <> - - + + @@ -49,84 +102,90 @@ function Profile() { ) })} - - {loginUser.mobile} - - - + + + + + - - - - - {/* {loginUser.email} */} + 邮箱
} - dataSource={[ - loginUser.email, - 'christyluo@chinahighlights.com', - 'christyluo@chinahighlights.net', - 'christyluo@asiahighlights.com', - 'christyluo@asiahighlights.net', - 'christyluo@globalhighlights.com', - 'christyluo@globalhighlights.net', - 'christyluo@163.com', - ]} + dataSource={loginUser.emailList} renderItem={(item) => {item}} /> + + + + + + 在系统上使用 WhatsApp + +
    +
  • 在手机上打开 WhatsApp
  • +
  • 点击“已关联的设备”,然后点击“关联新设备”
  • +
  • 将手机对准屏幕扫描二维码
  • +
+
+
+ - - } - title='登录成功' - extra={} - /> + + + WhatsApp:8618754124786 + +
diff --git a/src/views/dingding/QRCode.jsx b/src/views/dingding/QRCode.jsx index 6687d65..4b5e12a 100644 --- a/src/views/dingding/QRCode.jsx +++ b/src/views/dingding/QRCode.jsx @@ -1,6 +1,6 @@ import useAuthStore from '@/stores/AuthStore' -import { Flex, Result, Spin, Typography } from 'antd' -import { useEffect, useState } from 'react' +import { Flex, Input, Button, Typography } from 'antd' +import { useEffect, useState, useRef } from 'react' import { useNavigate } from 'react-router-dom' const { Title } = Typography @@ -8,7 +8,6 @@ const { Title } = Typography // 钉钉扫码开发文档:https://open.dingtalk.com/document/orgapp/tutorial-obtaining-user-personal-information#title-qpi-0qv-anm function QRCode() { - const navigate = useNavigate() const [result, setResult] = useState('') @@ -16,16 +15,19 @@ function QRCode() { // const loginStatus = useAuthStore((state) => state.loginStatus) // const setLoginStatus = useAuthStore((state) => state.setLoginStatus) // const loginUser = useAuthStore((state) => state.loginUser) - // const login = useAuthStore((state) => state.login) + const login = useAuthStore((state) => state.login) + const codeRef = useRef() useEffect(() => { // if (loginUser.userId > 0) { // navigate('/') // } - }, []) + }, []) useEffect(() => { - import('https://g.alicdn.com/dingding/h5-dingtalk-login/0.21.0/ddlogin.js').then(() => { + import( + 'https://g.alicdn.com/dingding/h5-dingtalk-login/0.21.0/ddlogin.js' + ).then(() => { window.DTFrameLogin( { id: 'qrCodeContainer', @@ -33,7 +35,9 @@ function QRCode() { height: 300, }, { - redirect_uri: encodeURIComponent('https://sales.mycht.cn/p/dingding/callback'), + redirect_uri: encodeURIComponent( + 'https://sales.mycht.cn/p/dingding/callback', + ), client_id: 'dingwgdx6emlxr3fcrg8', scope: 'openid', response_type: 'code', @@ -42,7 +46,6 @@ function QRCode() { }, (loginResult) => { const { authCode } = loginResult - // login(authCode) setResult(authCode) }, (errorMsg) => { @@ -56,10 +59,24 @@ function QRCode() { return ( 使用钉钉扫码 -
+
钉钉 authCode: {result} + +
) } -export default QRCode \ No newline at end of file +export default QRCode From bb96b04cd7248f8391b922e784919537deee64cc Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Thu, 31 Oct 2024 15:42:13 +0800 Subject: [PATCH 08/10] =?UTF-8?q?feat:=20=E9=A1=BE=E9=97=AE=E9=82=AE?= =?UTF-8?q?=E7=AE=B1=E5=88=97=E8=A1=A8=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E3=80=81=E5=A4=87=E7=94=A8=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +-- src/config.js | 1 + src/stores/AuthStore.js | 12 +++++++++++- src/views/accounts/Profile.jsx | 9 ++++++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5cd22a9..a5635bb 100644 --- a/README.md +++ b/README.md @@ -32,5 +32,4 @@ npm version patch --no-git-tag-version ## 本机测试账号 GLOBAL_SALES_LOGIN_USER -{"userId":"383","userIdStr":"383,609","username":"廖一军","avatarUrl":"https://static-legacy.dingtalk.com/media/lALPBDDrhXr716HNAoDNAoA_640_640.png","mobile":"+86-18777396951","email":"lyj@hainatravel.com","openId":"iioljiPmZ4RPoOYpkFiSn7IKAiEiE","accountList":[{"OPI_SN":383,"OPI_Code":"LYJ","OPI_NameCN":"廖一军","OPI_DEI_SN":7,"OPI_NameEN":"Jimmy Liow"},{"OPI_SN":609,"OPI_Code":"LYJAH","OPI_NameCN":"廖一军(ah)","OPI_DEI_SN":28,"OPI_NameEN":"Jimmy Liow"}],"emailList":["lyj@hainatravel.com","lyj@asiahighlights.com","lyj@chinahighlights.net","lyj@globalhighlights.com"],"whatsappinfo": {"whatsapp_wa": "8617607730395","whatsapp_waba": "8618174165365"}} - +{"userId":"383","userIdStr":"383,609","emailList":[{"opi_sn":383,"email":"lyj@asiahighlights.com","default":false,"backup":false},{"opi_sn":383,"email":"lyj@chinahighlights.com","default":false,"backup":true},{"opi_sn":383,"email":"lyj@hainatravel.com","default":true,"backup":false}],"username":"廖一军","avatarUrl":"https://static-legacy.dingtalk.com/media/lALPBDDrhXr716HNAoDNAoA_640_640.png","mobile":"+86-18777396951","email":"lyj@hainatravel.com","whatsAppBusiness":"8617458471254","openId":"iioljiPmZ4RPoOYpkFiSn7IKAiEiE","accountList":[{"OPI_SN":383,"OPI_Code":"LYJ","OPI_NameCN":"廖一军","OPI_DEI_SN":7,"OPI_NameEN":"Jimmy Liow"},{"OPI_SN":609,"OPI_Code":"LYJAH","OPI_NameCN":"廖一军(ah)","OPI_DEI_SN":28,"OPI_NameEN":"Jimmy Liow"}]} \ No newline at end of file diff --git a/src/config.js b/src/config.js index 93b0e51..5bba1ca 100644 --- a/src/config.js +++ b/src/config.js @@ -1,3 +1,4 @@ +/* eslint-disable no-undef */ // export const API_HOST = 'https://p9axztuwd7x8a7.mycht.cn/whatsapp_qqs' // export const WS_URL = 'wss://p9axztuwd7x8a7.mycht.cn/whatsapp_qqs'; // test: // diff --git a/src/stores/AuthStore.js b/src/stores/AuthStore.js index 9888c29..cde12ab 100644 --- a/src/stores/AuthStore.js +++ b/src/stores/AuthStore.js @@ -49,7 +49,8 @@ const useAuthStore = create((set, get) => ({ setLoginStatus(200) const json = await fetchJSON( - `https://p9axztuwd7x8a7.mycht.cn/dingtalk/dingtalkwork/WhatsAppAuth`, + 'http://202.103.68.157:889/dingtalk/dingtalkwork/WhatsAppAuth', + //`https://p9axztuwd7x8a7.mycht.cn/dingtalk/dingtalkwork/WhatsAppAuth`, { authCode }, ) @@ -62,6 +63,15 @@ const useAuthStore = create((set, get) => ({ return acc.OPI_SN }) .join(','), + emailList: json.result?.emaillist.map(item => { + return { + opi_sn: item.opi_sn, + email: item.email, + default: item.Isdefaultemail == 1, + backup: item.Isbakemail == 1, + } + }), + // whatsAppBusiness: json.result.opicode, 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 c092608..5244f98 100644 --- a/src/views/accounts/Profile.jsx +++ b/src/views/accounts/Profile.jsx @@ -157,7 +157,14 @@ function Profile() { 邮箱
} dataSource={loginUser.emailList} - renderItem={(item) => {item}} + renderItem={(item) => { + const isDefault = item.default ? 默认 : null + const isBackup = item.backup ? 备用 : null + return ( + {item.email} {isDefault}{isBackup} + ) + } + } /> From 55c9a186998fba7073910b7724b58ba3f2b12c3d Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Fri, 1 Nov 2024 14:36:05 +0800 Subject: [PATCH 09/10] =?UTF-8?q?feat:=20=E9=A1=BE=E9=97=AE=E9=82=AE?= =?UTF-8?q?=E7=AE=B1=E5=8A=A0=E4=B8=8A=20mat=5Fsn=EF=BC=9B=E5=9B=BE?= =?UTF-8?q?=E6=96=87=E9=9B=86=E4=BD=BF=E7=94=A8=20Drawer=20=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/stores/AuthStore.js | 1 + src/views/DesktopApp.jsx | 63 ++++++++++++++++++------------ src/views/accounts/Profile.jsx | 26 ++++++------ src/views/accounts/SnippetList.jsx | 8 ++-- 5 files changed, 60 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index a5635bb..b09aa7f 100644 --- a/README.md +++ b/README.md @@ -32,4 +32,4 @@ npm version patch --no-git-tag-version ## 本机测试账号 GLOBAL_SALES_LOGIN_USER -{"userId":"383","userIdStr":"383,609","emailList":[{"opi_sn":383,"email":"lyj@asiahighlights.com","default":false,"backup":false},{"opi_sn":383,"email":"lyj@chinahighlights.com","default":false,"backup":true},{"opi_sn":383,"email":"lyj@hainatravel.com","default":true,"backup":false}],"username":"廖一军","avatarUrl":"https://static-legacy.dingtalk.com/media/lALPBDDrhXr716HNAoDNAoA_640_640.png","mobile":"+86-18777396951","email":"lyj@hainatravel.com","whatsAppBusiness":"8617458471254","openId":"iioljiPmZ4RPoOYpkFiSn7IKAiEiE","accountList":[{"OPI_SN":383,"OPI_Code":"LYJ","OPI_NameCN":"廖一军","OPI_DEI_SN":7,"OPI_NameEN":"Jimmy Liow"},{"OPI_SN":609,"OPI_Code":"LYJAH","OPI_NameCN":"廖一军(ah)","OPI_DEI_SN":28,"OPI_NameEN":"Jimmy Liow"}]} \ No newline at end of file +{"userId":"383","userIdStr":"383,609","emailList":[{"opi_sn":383,"mat_sn":760,"email":"lyj@asiahighlights.com","default":false,"backup":false},{"opi_sn":383,"mat_sn":759,"email":"lyj@chinahighlights.com","default":false,"backup":true},{"opi_sn":383,"mat_sn":758,"email":"lyj@hainatravel.com","default":true,"backup":false}],"username":"廖一军","avatarUrl":"https://static-legacy.dingtalk.com/media/lALPBDDrhXr716HNAoDNAoA_640_640.png","mobile":"+86-18777396951","email":"lyj@hainatravel.com","whatsAppBusiness":"8617458471254","openId":"iioljiPmZ4RPoOYpkFiSn7IKAiEiE","accountList":[{"OPI_SN":383,"OPI_Code":"LYJ","OPI_NameCN":"廖一军","OPI_DEI_SN":7,"OPI_NameEN":"Jimmy Liow"},{"OPI_SN":609,"OPI_Code":"LYJAH","OPI_NameCN":"廖一军(ah)","OPI_DEI_SN":28,"OPI_NameEN":"Jimmy Liow"}]} diff --git a/src/stores/AuthStore.js b/src/stores/AuthStore.js index cde12ab..c93f20a 100644 --- a/src/stores/AuthStore.js +++ b/src/stores/AuthStore.js @@ -66,6 +66,7 @@ const useAuthStore = create((set, get) => ({ emailList: json.result?.emaillist.map(item => { return { opi_sn: item.opi_sn, + mat_sn: item.mat_sn, email: item.email, default: item.Isdefaultemail == 1, backup: item.Isbakemail == 1, diff --git a/src/views/DesktopApp.jsx b/src/views/DesktopApp.jsx index dfb8203..9bb5774 100644 --- a/src/views/DesktopApp.jsx +++ b/src/views/DesktopApp.jsx @@ -13,6 +13,7 @@ import { Typography, theme, Badge, + Drawer, } from 'antd' import 'dayjs/locale/zh-cn' import { useEffect, useState } from 'react' @@ -24,6 +25,8 @@ import 'react-chat-elements/dist/main.css' import ReloadPrompt from './ReloadPrompt' import ClearCache from './ClearCache' +import SnippetList from './accounts/SnippetList' + import { BUILD_VERSION, BUILD_DATE } from '@/config' const { Header, Footer, Content } = Layout @@ -37,6 +40,14 @@ function DesktopApp() { const totalNotify = useConversationStore((state) => state.totalNotify) + const [drawerOpen, setDrawerOpen] = useState(false) + + const onClick = ({ key }) => { + if (key === 'snippet-list') { + setDrawerOpen(true) + } + } + let defaultPath = '/order/follow' if (href !== '/') { @@ -78,35 +89,42 @@ function DesktopApp() { return (
- - - - App logo + }}> + setDrawerOpen(false)} + open={drawerOpen}> + + + + + + App logo 销售平台 订单跟踪, + label: 订单跟踪, }, { key: '/order/chat', label: ( - + 在线聊天 0 ? totalNotify : undefined} @@ -119,34 +137,33 @@ function DesktopApp() { }, { key: '/callcenter/call', - label: 语音通话, + label: 语音通话, }, { key: '/chat/history', - label: 聊天记录, + label: 聊天记录, }, ]} /> + }}> 个人资料, + label: 个人资料, key: 'profile', }, { - label: 图文集管理, + label: '图文集管理', key: 'snippet-list', }, { type: 'divider' }, @@ -155,17 +172,16 @@ function DesktopApp() { { label: , key: 'clearcache' }, { type: 'divider' }, { - label: 退出, + label: 退出, key: 'logout', }, ], + onClick, }} - trigger={['click']} - > + trigger={['click']}> e.preventDefault()} - style={{ color: colorPrimary }} - > + style={{ color: colorPrimary }}> {loginUser?.username?.substring(1)} @@ -185,8 +201,7 @@ function DesktopApp() { margin: 0, minHeight: 280, background: colorBgContainer, - }} - > + }}> diff --git a/src/views/accounts/Profile.jsx b/src/views/accounts/Profile.jsx index 5244f98..7c2a116 100644 --- a/src/views/accounts/Profile.jsx +++ b/src/views/accounts/Profile.jsx @@ -8,7 +8,7 @@ import { Tag, Divider, List, - Result, + Alert, Button, Flex, Select, @@ -158,13 +158,17 @@ function Profile() { header={
邮箱
} dataSource={loginUser.emailList} renderItem={(item) => { - const isDefault = item.default ? 默认 : null - const isBackup = item.backup ? 备用 : null + const isDefault = item.default ? ( + 默认 + ) : null + const isBackup = item.backup ? 备用 : null return ( - {item.email} {isDefault}{isBackup} + + {item.email} {isDefault} + {isBackup} + ) - } - } + }} /> @@ -183,16 +187,16 @@ function Profile() { - + - WhatsApp:8618754124786 - - + + + diff --git a/src/views/accounts/SnippetList.jsx b/src/views/accounts/SnippetList.jsx index 31bb53b..aac0eef 100644 --- a/src/views/accounts/SnippetList.jsx +++ b/src/views/accounts/SnippetList.jsx @@ -142,10 +142,10 @@ function SnippetList() {