|
@@ -1,7 +1,7 @@
|
|
|
import React, { useState, useEffect, useRef } from "react";
|
|
|
import http from '@src/http';
|
|
|
import { Modal, Image, message, Input, Button, Skeleton } from "antd";
|
|
|
-import { qwGetQrCode, qwCheckLogin, qwCheckQRCode } from '@src/http/api';
|
|
|
+import { qwGetQrCode, qwCheckLogin, qwCheckQRCode, qwSecondaryValidation } from '@src/http/api';
|
|
|
|
|
|
interface QrCodeData {
|
|
|
qrcode: string;
|
|
@@ -21,6 +21,7 @@ interface QrCodeModalProps {
|
|
|
onClose: () => void;
|
|
|
title: string;
|
|
|
vid?: string; // 可选参数,用于登录时传入
|
|
|
+ loginStatus?: number; // 添加账号状态参数
|
|
|
onSuccess?: (data: QrCodeData) => void; // 可选回调,用于处理成功获取二维码后的操作
|
|
|
onLoginSuccess?: () => void; // 登录成功后的回调
|
|
|
}
|
|
@@ -30,6 +31,7 @@ const QrCodeModal: React.FC<QrCodeModalProps> = ({
|
|
|
onClose,
|
|
|
title,
|
|
|
vid,
|
|
|
+ loginStatus,
|
|
|
onSuccess,
|
|
|
onLoginSuccess
|
|
|
}) => {
|
|
@@ -52,7 +54,33 @@ const QrCodeModal: React.FC<QrCodeModalProps> = ({
|
|
|
setLoginMessage("");
|
|
|
setVerifyCode("");
|
|
|
|
|
|
- // 根据是否有 vid 参数决定是添加账号还是登录
|
|
|
+ // 如果状态是-5,先调用二次验证接口
|
|
|
+ if (loginStatus === -5 && vid) {
|
|
|
+ try {
|
|
|
+ const secondaryRes = await http.post<QrCodeData>(qwSecondaryValidation, { vid });
|
|
|
+ // 如果二次验证成功且返回了qrcode_data字段,直接使用该结果
|
|
|
+ if (secondaryRes.success && secondaryRes.data?.qrcode_data) {
|
|
|
+ setQrCodeData(secondaryRes.data);
|
|
|
+ // 设置倒计时初始值
|
|
|
+ setCountdown(secondaryRes.data.ttl);
|
|
|
+ // 如果有成功回调,则调用
|
|
|
+ if (onSuccess) {
|
|
|
+ onSuccess(secondaryRes.data);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 开始轮询登录状态
|
|
|
+ startPollingLoginStatus(secondaryRes.data.uuid);
|
|
|
+ setLoading(false);
|
|
|
+ return; // 提前返回,不执行后续的qwGetQrCode调用
|
|
|
+ }
|
|
|
+ // 如果二次验证失败或没有返回qrcode_data字段,继续执行原有逻辑
|
|
|
+ } catch (error) {
|
|
|
+ console.error('二次验证失败:', error);
|
|
|
+ // 出错时继续执行原有逻辑
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 原有逻辑:调用qwGetQrCode接口
|
|
|
const res = await http.post<QrCodeData>(qwGetQrCode, { vid });
|
|
|
|
|
|
if (res.success) {
|