完成管理员user-list

This commit is contained in:
2025-05-12 10:27:50 +08:00
parent ecc6307266
commit 53a0f4456b
16 changed files with 648 additions and 41 deletions

View File

@@ -1,4 +1,4 @@
import fetcher, { StanderResponse } from "../fetcher"
import fetcher, { ApiError } from "../fetcher"
interface LoginParams {
type: 'password' | 'phone' | 'email';
@@ -9,39 +9,39 @@ interface LoginParams {
code?: string;
}
export const login = async (data: LoginParams): Promise<StanderResponse<{ token: string }>> => {
export const login = async (data: LoginParams): Promise<{ token: string }> => {
if (data.type === 'password') {
if (!data.account || !data.password) {
return { statusCode: 400, message: '请输入账户和密码' }
throw new ApiError(400, '请输入账户和密码')
}
if (data.account.length < 1 || data.account.length > 254) {
return { statusCode: 400, message: '请输入正确的账户' }
throw new ApiError(400, '请输入正确的账户')
}
if (data.password.length < 6 || data.password.length > 32) {
return { statusCode: 400, message: '请输入正确的密码' }
throw new ApiError(400, '请输入正确的密码')
}
} else if (data.type === 'phone') {
if (!data.phone || !data.code) {
return { statusCode: 400, message: '请输入手机号和验证码' }
throw new ApiError(400, '请输入手机号和验证码')
}
if (data.phone.length !== 11) {
return { statusCode: 400, message: '请输入正确的手机号' }
throw new ApiError(400, '请输入正确的手机号')
}
if (data.code.length != 6) {
return { statusCode: 400, message: '请输入正确的验证码' }
throw new ApiError(400, '请输入正确的验证码')
}
} else if (data.type === 'email') {
if (!data.email || !data.code) {
return { statusCode: 400, message: '请输入邮箱和验证码' }
throw new ApiError(400, '请输入邮箱和验证码')
}
if (data.email.length < 1 || data.email.length > 254) {
return { statusCode: 400, message: '请输入正确的邮箱' }
throw new ApiError(400, '请输入正确的邮箱')
}
if (data.code.length != 6) {
return { statusCode: 400, message: '请输入正确的验证码' }
throw new ApiError(400, '请输入正确的验证码')
}
} else {
return { statusCode: 400, message: '登录方式异常' }
throw new ApiError(400, '登录方式异常')
}
return fetcher<{