fix(webui): recover QR login after forced logout (#2030)
This commit is contained in:
1 parent
fa3fe9fdb2
commit
c75d2f7f86
8 files changed
+322
-33
No files matched your search
@@ -7,12 +7,33 @@ interface QrCodeLoginProps {
|
||||
qrcode: string;
|
||||
loginError?: string;
|
||||
onRefresh?: () => void;
|
||||
isRefreshing?: boolean;
|
||||
loginPhase?: string;
|
||||
isRecoveringLoginService?: boolean;
|
||||
}
|
||||
|
||||
const QrCodeLogin: React.FC<QrCodeLoginProps> = ({ qrcode, loginError, onRefresh }) => {
|
||||
const QrCodeLogin: React.FC<QrCodeLoginProps> = ({ qrcode, loginError, onRefresh, isRefreshing = false, loginPhase, isRecoveringLoginService = false }) => {
|
||||
const transitionMessage = loginPhase === 'qrcode_scanned'
|
||||
? '二维码已扫描,等待手机确认…'
|
||||
: loginPhase === 'initializing'
|
||||
? 'QQ 登录成功,正在启动 NapCat…'
|
||||
: loginPhase === 'reconnecting' || isRecoveringLoginService
|
||||
? '正在重新连接 QQ 登录服务…'
|
||||
: undefined;
|
||||
return (
|
||||
<div className='flex flex-col items-center'>
|
||||
{loginError
|
||||
{(isRefreshing || transitionMessage) && (
|
||||
<div className='fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm'>
|
||||
<div className='flex flex-col items-center gap-4 rounded-xl bg-content1 px-10 py-8 shadow-xl'>
|
||||
<Spinner color='primary' size='lg' />
|
||||
<div className='text-lg font-medium'>{transitionMessage || '正在刷新二维码…'}</div>
|
||||
<div className='text-sm text-default-500'>
|
||||
{transitionMessage ? '请不要关闭此页面,最长可能需要 3 分钟' : '正在等待新的二维码,最长 10 秒'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{loginError && !qrcode && !isRecoveringLoginService
|
||||
? (
|
||||
<div className='flex flex-col items-center py-4'>
|
||||
<div className='w-full flex justify-center mb-6'>
|
||||
@@ -34,6 +55,8 @@ const QrCodeLogin: React.FC<QrCodeLoginProps> = ({ qrcode, loginError, onRefresh
|
||||
size='lg'
|
||||
startContent={<IoRefresh />}
|
||||
onPress={onRefresh}
|
||||
isLoading={isRefreshing}
|
||||
isDisabled={isRefreshing}
|
||||
>
|
||||
重新获取二维码
|
||||
</Button>
|
||||
@@ -42,13 +65,18 @@ const QrCodeLogin: React.FC<QrCodeLoginProps> = ({ qrcode, loginError, onRefresh
|
||||
)
|
||||
: (
|
||||
<>
|
||||
{loginError && (
|
||||
<div className='mb-4 w-full max-w-[360px] rounded-lg bg-warning-50 px-4 py-3 text-center text-sm text-warning-700 dark:bg-warning-50/20 dark:text-warning-300'>
|
||||
{loginError}
|
||||
</div>
|
||||
)}
|
||||
<div className='bg-white p-2 rounded-md w-fit mx-auto relative overflow-hidden'>
|
||||
{!qrcode && (
|
||||
<div className='absolute left-0 top-0 right-0 bottom-0 bg-white dark:bg-zinc-900 bg-opacity-90 backdrop-blur-sm flex items-center justify-center z-10'>
|
||||
<Spinner color='primary' />
|
||||
</div>
|
||||
)}
|
||||
<QRCodeSVG size={180} value={qrcode || ' '} />
|
||||
<QRCodeSVG key={qrcode} size={180} value={qrcode || ' '} />
|
||||
</div>
|
||||
<div className='mt-5 text-center text-default-500 text-sm'>请使用QQ或者TIM扫描上方二维码</div>
|
||||
{onRefresh && qrcode && (
|
||||
@@ -59,6 +87,8 @@ const QrCodeLogin: React.FC<QrCodeLoginProps> = ({ qrcode, loginError, onRefresh
|
||||
size='sm'
|
||||
startContent={<IoRefresh />}
|
||||
onPress={onRefresh}
|
||||
isLoading={isRefreshing}
|
||||
isDisabled={isRefreshing}
|
||||
>
|
||||
刷新二维码
|
||||
</Button>
|
||||
|
||||
Reference in new issue
Block a user