-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
05b961a
commit c51b352
Showing
9 changed files
with
1,217 additions
and
78 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import request from '@/util/request'; | ||
|
||
// 登录 | ||
export async function login(code:string,email:string):Promise<any>{ | ||
try { | ||
const response = await request({ | ||
url: '/user/login', | ||
method: "post", | ||
params: { | ||
code:code, | ||
email:email | ||
} | ||
}) | ||
return response; | ||
} catch (error) { | ||
console.error('登录请求失败:', error); | ||
} | ||
} | ||
// 登出 | ||
export async function logout(code:string,email:string):Promise<any>{ | ||
try { | ||
const response = await request({ | ||
url: '/user/logout', | ||
method: "post", | ||
}) | ||
return response; | ||
} catch (error) { | ||
console.error('登出请求失败:', error); | ||
} | ||
} | ||
// 发送图片验证码 | ||
export async function captcha():Promise<any>{ | ||
try { | ||
const response = await request({ | ||
url: '/user/captcha', | ||
method: "get", | ||
}) | ||
return response; | ||
} catch (error) { | ||
console.error('发送图片验证码请求失败:', error); | ||
} | ||
} | ||
// 发送邮箱验证码 | ||
export async function sendCaptcha(email:string,pid:string,code:string):Promise<any>{ | ||
try { | ||
const response = await request({ | ||
url: '/user/sendCaptcha', | ||
method: "get", | ||
data:{ | ||
email: email, | ||
pid:pid, | ||
code:code | ||
} | ||
}) | ||
return response; | ||
} catch (error) { | ||
console.error('发送邮箱验证码请求失败:', error); | ||
} | ||
} | ||
// 获取当前登录用户信息 | ||
export async function getInfo(code:string,email:string):Promise<any>{ | ||
try { | ||
const response = await request({ | ||
url: '/user/getInfo', | ||
method: "get", | ||
}) | ||
return response; | ||
} catch (error) { | ||
console.error('获取用户信息请求失败:', error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface UserInfo { | ||
id: string; | ||
name: string; | ||
avatar: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { defineStore } from "pinia"; | ||
|
||
import router from "@/router"; | ||
import type {UserInfo} from "@/api/login/type.ts"; | ||
|
||
export const useAuthStore = defineStore("auth", { | ||
state: () => ({ | ||
isLoggedIn: false, | ||
user: null as UserInfo | null | ||
}), | ||
|
||
persist: { | ||
enabled: true, | ||
strategies: [{ storage: localStorage, paths: ["isLoggedIn"] }], | ||
}, | ||
|
||
getters: {}, | ||
|
||
actions: { | ||
setLoggedIn(user: UserInfo) { | ||
this.isLoggedIn = true; | ||
this.user = user; | ||
router.push("/"); | ||
}, | ||
|
||
logout() { | ||
this.isLoggedIn = false; | ||
router.push("/"); | ||
}, | ||
}, | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters