diff --git a/src/main.jsx b/src/main.jsx index be176f6..3435123 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -26,6 +26,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' @@ -93,6 +94,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..3d5790c --- /dev/null +++ b/src/views/dingding/AuthCode.jsx @@ -0,0 +1,48 @@ +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 + setResult(dingTalkPlatForm) + }, []) + + return ( + + + setClientValue(e.currentTarget.value)} /> + + + ) +} + +export default AuthCode