更新认证API,新增地理位置参数支持,优化登录逻辑以处理位置获取,提升用户体验和代码可维护性。
This commit is contained in:
@@ -2,9 +2,8 @@ import axios from 'axios';
|
||||
import type { MinioUploadPolicy, OSSUploadPolicy } from '@d8d-appcontainer/types';
|
||||
import 'dayjs/locale/zh-cn';
|
||||
import type {
|
||||
User, FileLibrary, FileCategory, KnowInfo,
|
||||
AuthContextType, ThemeContextType, Attachment, ThemeSettings,
|
||||
SystemSetting, SystemSettingGroupData
|
||||
User, FileLibrary, FileCategory, ThemeSettings,
|
||||
SystemSetting, SystemSettingGroupData, LoginLocation, LoginLocationDetail
|
||||
} from '../share/types.ts';
|
||||
|
||||
|
||||
@@ -40,7 +39,7 @@ interface AuthResponse {
|
||||
|
||||
// 定义Auth API接口类型
|
||||
interface AuthAPIType {
|
||||
login: (username: string, password: string) => Promise<AuthLoginResponse>;
|
||||
login: (username: string, password: string, latitude?: number, longitude?: number) => Promise<AuthLoginResponse>;
|
||||
register: (username: string, email: string, password: string) => Promise<AuthResponse>;
|
||||
logout: () => Promise<AuthResponse>;
|
||||
getCurrentUser: () => Promise<User>;
|
||||
@@ -54,9 +53,14 @@ interface AuthAPIType {
|
||||
// Auth相关API
|
||||
export const AuthAPI: AuthAPIType = {
|
||||
// 登录API
|
||||
login: async (username: string, password: string) => {
|
||||
login: async (username: string, password: string, latitude?: number, longitude?: number) => {
|
||||
try {
|
||||
const response = await axios.post(`${API_BASE_URL}/auth/login`, { username, password });
|
||||
const response = await axios.post(`${API_BASE_URL}/auth/login`, {
|
||||
username,
|
||||
password,
|
||||
latitude,
|
||||
longitude
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user