更新移动端认证API,新增地理位置参数支持,优化登录逻辑以处理位置获取失败的情况,提升用户体验和代码可维护性。
This commit is contained in:
@@ -40,7 +40,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 +54,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