fix: #2136 移除废弃接口
This commit removes deprecated QQ quick-login and user-list API calls from the frontend and updates the login page to use the newer quick-login response format. It also fixes the initial loading state by ensuring the spinner is cleared in a finally block and moves QQ list refresh to its own effect so the list loads reliably on first render.
This commit is contained in:
1 parent
49ecfe0f56
commit
c15f149881
3 files changed
+13
-34
No files matched your search
@@ -61,14 +61,6 @@ export default class QQManager {
|
|||||||
return data.data.data.qrcode;
|
return data.data.data.qrcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async getQQQuickLoginList () {
|
|
||||||
const data = await serverRequest.post<ServerResponse<string[]>>(
|
|
||||||
'/QQLogin/GetQuickLoginList'
|
|
||||||
);
|
|
||||||
|
|
||||||
return data.data.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async getQQQuickLoginListNew () {
|
public static async getQQQuickLoginListNew () {
|
||||||
const data = await serverRequest.post<ServerResponse<LoginListItem[]>>(
|
const data = await serverRequest.post<ServerResponse<LoginListItem[]>>(
|
||||||
'/QQLogin/GetQuickLoginListNew'
|
'/QQLogin/GetQuickLoginListNew'
|
||||||
|
|||||||
@@ -185,11 +185,6 @@ export default class WebUIManager {
|
|||||||
return data.data;
|
return data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async getAllUsers (): Promise<any> {
|
|
||||||
const { data } = await serverRequest.get<ServerResponse<any>>('/QQLogin/GetAllUsers');
|
|
||||||
return data.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async getLogList () {
|
public static async getLogList () {
|
||||||
const { data } =
|
const { data } =
|
||||||
await serverRequest.get<ServerResponse<string[]>>('/Log/GetLogList');
|
await serverRequest.get<ServerResponse<string[]>>('/Log/GetLogList');
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import { title } from '@/components/primitives';
|
|||||||
import PasswordLogin from '@/components/password_login';
|
import PasswordLogin from '@/components/password_login';
|
||||||
import QrCodeLogin from '@/components/qr_code_login';
|
import QrCodeLogin from '@/components/qr_code_login';
|
||||||
import QuickLogin from '@/components/quick_login';
|
import QuickLogin from '@/components/quick_login';
|
||||||
import type { QQItem } from '@/components/quick_login';
|
|
||||||
import { ThemeSwitch } from '@/components/theme-switch';
|
import { ThemeSwitch } from '@/components/theme-switch';
|
||||||
import type { CaptchaCallbackData } from '@/components/tencent_captcha';
|
import type { CaptchaCallbackData } from '@/components/tencent_captcha';
|
||||||
|
|
||||||
@@ -60,7 +59,7 @@ export default function QQLoginPage () {
|
|||||||
const isRefreshingQRCodeRef = useRef(false);
|
const isRefreshingQRCodeRef = useRef(false);
|
||||||
const [loginError, setLoginError] = useState<string>('');
|
const [loginError, setLoginError] = useState<string>('');
|
||||||
const lastErrorRef = useRef<string>('');
|
const lastErrorRef = useRef<string>('');
|
||||||
const [qqList, setQQList] = useState<(QQItem | LoginListItem)[]>([]);
|
const [qqList, setQQList] = useState<LoginListItem[]>([]);
|
||||||
const [refresh, setRefresh] = useState<boolean>(false);
|
const [refresh, setRefresh] = useState<boolean>(false);
|
||||||
const [activeTab, setActiveTab] = useState<string>('shortcut');
|
const [activeTab, setActiveTab] = useState<string>('shortcut');
|
||||||
const firstLoad = useRef<boolean>(true);
|
const firstLoad = useRef<boolean>(true);
|
||||||
@@ -213,10 +212,6 @@ export default function QQLoginPage () {
|
|||||||
setIsRecoveringLoginService(true);
|
setIsRecoveringLoginService(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstLoad.current) {
|
|
||||||
setIsLoading(false);
|
|
||||||
firstLoad.current = false;
|
|
||||||
}
|
|
||||||
if (data.isLogin) {
|
if (data.isLogin) {
|
||||||
toast.success('QQ登录成功');
|
toast.success('QQ登录成功');
|
||||||
navigate('/', { replace: true });
|
navigate('/', { replace: true });
|
||||||
@@ -259,6 +254,11 @@ export default function QQLoginPage () {
|
|||||||
if (!isRecoveringLoginService) {
|
if (!isRecoveringLoginService) {
|
||||||
toast.error(`获取二维码失败: ${msg}`);
|
toast.error(`获取二维码失败: ${msg}`);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
if (firstLoad.current) {
|
||||||
|
setIsLoading(false);
|
||||||
|
firstLoad.current = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -267,20 +267,9 @@ export default function QQLoginPage () {
|
|||||||
try {
|
try {
|
||||||
const data = await QQManager.getQQQuickLoginListNew();
|
const data = await QQManager.getQQQuickLoginListNew();
|
||||||
setQQList(data);
|
setQQList(data);
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
try {
|
const msg = (error as Error).message;
|
||||||
const data = await QQManager.getQQQuickLoginList();
|
toast.error(`获取QQ列表失败: ${msg}`);
|
||||||
|
|
||||||
const qqList = data.map((item) => ({
|
|
||||||
uin: item,
|
|
||||||
}));
|
|
||||||
|
|
||||||
setQQList(qqList);
|
|
||||||
} catch (_error) {
|
|
||||||
const msg = (_error as Error).message;
|
|
||||||
|
|
||||||
toast.error(`获取QQ列表失败: ${msg}`);
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
setRefresh(false);
|
setRefresh(false);
|
||||||
}
|
}
|
||||||
@@ -347,11 +336,14 @@ export default function QQLoginPage () {
|
|||||||
}, pollInterval);
|
}, pollInterval);
|
||||||
|
|
||||||
onUpdateQrCode();
|
onUpdateQrCode();
|
||||||
onUpdateQQList();
|
|
||||||
|
|
||||||
return () => clearInterval(timer);
|
return () => clearInterval(timer);
|
||||||
}, [isRefreshingQRCode, loginPhase, isRecoveringLoginService]);
|
}, [isRefreshingQRCode, loginPhase, isRecoveringLoginService]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
onUpdateQQList();
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isRecoveringLoginService) return;
|
if (!isRecoveringLoginService) return;
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
|
|||||||
Reference in new issue
Block a user