添加扫码登录功能 (#601)

* feat: 添加扫码登录功能,支持生成二维码并轮询登录状态

* feat: 增强扫码登录功能的测试,完善二维码生成与状态轮询的文档注释

* refactor: 后端改动之:1)拆分 login 到 credential 中;2)扫码登录和刷新凭据时复用相同的 extract 函数;3)精简注释。

* refactor: 前端改动之:1)扫码在单独的弹窗页处理;2)不同 status 下采用相同布局,避免状态变化导致布局跳动

* format

---------

Co-authored-by: zkl <i@zkl2333.com>
This commit is contained in:
ᴀᴍᴛᴏᴀᴇʀ
2026-01-11 12:59:48 +08:00
committed by GitHub
parent 64eecaa822
commit 5944298f10
15 changed files with 5915 additions and 50 deletions

View File

@@ -26,7 +26,9 @@ import type {
Notifier,
UpdateFilteredVideoStatusRequest,
UpdateFilteredVideoStatusResponse,
ResetFilteredVideoStatusRequest
ResetFilteredVideoStatusRequest,
QrcodeGenerateResponse as GenerateQrcodeResponse,
QrcodePollResponse as PollQrcodeResponse
} from './types';
import { wsManager } from './ws';
@@ -266,6 +268,14 @@ class ApiClient {
return this.post<boolean>('/task/download');
}
async generateQrcode(): Promise<ApiResponse<GenerateQrcodeResponse>> {
return this.post<GenerateQrcodeResponse>('/login/qrcode/generate');
}
async pollQrcode(qrcodeKey: string): Promise<ApiResponse<PollQrcodeResponse>> {
return this.get<PollQrcodeResponse>('/login/qrcode/poll', { qrcode_key: qrcodeKey });
}
subscribeToLogs(onMessage: (data: string) => void) {
return wsManager.subscribeToLogs(onMessage);
}
@@ -313,6 +323,8 @@ const api = {
updateConfig: (config: Config) => apiClient.updateConfig(config),
getDashboard: () => apiClient.getDashboard(),
triggerDownloadTask: () => apiClient.triggerDownloadTask(),
generateQrcode: () => apiClient.generateQrcode(),
pollQrcode: (qrcodeKey: string) => apiClient.pollQrcode(qrcodeKey),
subscribeToSysInfo: (onMessage: (data: SysInfo) => void) =>
apiClient.subscribeToSysInfo(onMessage),