From 2963c6ea56f903dc26e08a2643a79b3fb1832205 Mon Sep 17 00:00:00 2001 From: yelan Date: Tue, 1 Sep 2026 14:50:29 +0800 Subject: [PATCH] feat(auth): support captcha login --- clinical-web/src/api/auth.ts | 6 ++ clinical-web/src/types/auth.ts | 8 ++ clinical-web/src/views/auth/LoginView.vue | 111 +++++++++++++++++++++- 3 files changed, 121 insertions(+), 4 deletions(-) diff --git a/clinical-web/src/api/auth.ts b/clinical-web/src/api/auth.ts index 5c49c91..e5fb7dd 100644 --- a/clinical-web/src/api/auth.ts +++ b/clinical-web/src/api/auth.ts @@ -4,6 +4,7 @@ import { ApiResponseError, unwrapApiResponse } from '@/utils/api-response' import { request } from '@/utils/request' import type { AuthenticatedUser, + CaptchaResponse, CurrentUserResponse, LoginRequest, LoginResponse, @@ -12,6 +13,11 @@ import type { ApiResponse } from '@/types/common' export { ApiResponseError } from '@/utils/api-response' +export async function getCaptcha(): Promise { + const response = await request.get>('/v1/auth/captcha') + return unwrapApiResponse(response) +} + function normalizePermissions(value: unknown): string[] { if (Array.isArray(value)) { return value.filter((item): item is string => typeof item === 'string') diff --git a/clinical-web/src/types/auth.ts b/clinical-web/src/types/auth.ts index 362e811..9b1362f 100644 --- a/clinical-web/src/types/auth.ts +++ b/clinical-web/src/types/auth.ts @@ -5,6 +5,14 @@ export type AuthUserStatus = 'ENABLED' | 'DISABLED' export interface LoginRequest { username: string password: string + captchaId?: string + captchaCode?: string +} + +export interface CaptchaResponse { + captchaId: string + imageBase64: string + expiresAt: string } export interface AuthenticatedUser { diff --git a/clinical-web/src/views/auth/LoginView.vue b/clinical-web/src/views/auth/LoginView.vue index b830604..3027d68 100644 --- a/clinical-web/src/views/auth/LoginView.vue +++ b/clinical-web/src/views/auth/LoginView.vue @@ -1,8 +1,9 @@