fix: update home page background image and remove unnecessary redirect code chore: update pnpm lock file with new dependencies for auto-animate and svg spinners delete: remove unused images from public directory refactor: modify course and user types for better clarity and structure feat: implement course API with CRUD operations and teacher team management feat: create user authentication page with login functionality and validation feat: add login state management with Pinia for user session handling style: create reusable UI components for cards and tabs chore: implement HTTP utility for API requests with error handling
38 lines
736 B
TypeScript
38 lines
736 B
TypeScript
import type { IUser, LoginType } from "~/types";
|
|
import { http } from "~/utils/http";
|
|
import type { IResponse } from ".";
|
|
|
|
export interface LoginParams {
|
|
account: string;
|
|
password: string;
|
|
loginType: LoginType;
|
|
}
|
|
|
|
export type LoginResponse = IResponse & {
|
|
loginType: LoginType;
|
|
token: string;
|
|
};
|
|
|
|
export type UserProfileResponse = IResponse & {
|
|
user: IUser;
|
|
};
|
|
|
|
/**
|
|
* 用户登录
|
|
* @param params 登录参数
|
|
*
|
|
* @see {@link LoginParams}
|
|
*/
|
|
export const userLogin = async (params: LoginParams) => {
|
|
return await http<LoginResponse>("/login", {
|
|
method: "POST",
|
|
body: params,
|
|
});
|
|
};
|
|
|
|
export const userProfile = async () => {
|
|
return await http<UserProfileResponse>("/getInfo", {
|
|
method: "GET",
|
|
});
|
|
};
|