From b20ee4c46be869dc41345534659f9456ebdcc4af Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Tue, 29 Oct 2024 14:53:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E9=92=89=E9=92=89aut?= =?UTF-8?q?hcode=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