feat: updates

This commit is contained in:
qier222 2022-08-03 23:48:39 +08:00
parent 47e41dea9b
commit ebebf2a733
No known key found for this signature in database
GPG key ID: 9C85007ED905F14D
160 changed files with 4148 additions and 2001 deletions

View file

@ -1,11 +1,13 @@
import { cx, css } from '@emotion/css'
import { useEffect, useState, useMemo } from 'react'
import qrCode from 'qrcode'
import { useQuery } from 'react-query'
import { useQuery } from '@tanstack/react-query'
import { checkLoginQrCodeStatus, fetchLoginQrCodeKey } from '@/web/api/auth'
import toast from 'react-hot-toast'
import { setCookies } from '@/web/utils/cookie'
import uiStates from '@/web/states/uiStates'
import reactQueryClient from '@/web/utils/reactQueryClient'
import { UserApiNames } from '@/shared/api/User'
const QRCode = ({ className, text }: { className?: string; text: string }) => {
const [image, setImage] = useState<string>('')
@ -40,7 +42,7 @@ const LoginWithQRCode = () => {
status: keyStatus,
refetch: refetchKey,
} = useQuery(
'qrCodeKey',
['qrCodeKey'],
async () => {
const result = await fetchLoginQrCodeKey()
if (result.data.code !== 200) {
@ -58,7 +60,7 @@ const LoginWithQRCode = () => {
)
const { data: status } = useQuery(
'qrCodeStatus',
['qrCodeStatus'],
async () => checkLoginQrCodeStatus({ key: key?.data?.unikey || '' }),
{
refetchInterval: 1000,
@ -80,6 +82,7 @@ const LoginWithQRCode = () => {
break
}
setCookies(status.cookie)
reactQueryClient.refetchQueries([UserApiNames.FetchUserAccount])
uiStates.showLoginPanel = false
break
}
@ -97,7 +100,7 @@ const LoginWithQRCode = () => {
return (
<>
<div className='text-center text-18 font-medium text-night-600'>
<div className='text-center text-18 font-medium text-white/20'>
Log in with NetEase QR
</div>