feat(project): init
This commit is contained in:
66
components/login/api/index.ts
Normal file
66
components/login/api/index.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import httpFetch from "@/api/fetch"
|
||||
import { ResultData } from "@/api/typing"
|
||||
import { Login } from "./types"
|
||||
|
||||
const BASE_PATH =
|
||||
process.env.NEXT_PUBLIC_ENV === "production"
|
||||
? "https://basis.soft.cowarobot.com"
|
||||
: "https://basis.softtest.cowarobot.com"
|
||||
|
||||
// 获取验证码
|
||||
export const getVerifyCode = (params: { phone: string }) => {
|
||||
return httpFetch<ResultData<{}>>({
|
||||
url: BASE_PATH + `/api/v1/basis/login/get_verify_code`,
|
||||
method: "POST",
|
||||
body: JSON.stringify(params),
|
||||
})
|
||||
}
|
||||
|
||||
// 账户登录
|
||||
export const passwdLogin = (params: Login.ReqPasswdLogin) => {
|
||||
return httpFetch<ResultData<Login.ResLogin>>({
|
||||
url: BASE_PATH + `/api/v1/basis/login/passwd`,
|
||||
method: "POST",
|
||||
body: JSON.stringify(params),
|
||||
isLogin: true,
|
||||
})
|
||||
}
|
||||
|
||||
// 验证码登录
|
||||
export const verificationLogin = (params: Login.ReqVerificationLogin) => {
|
||||
return httpFetch<ResultData<Login.ResLogin>>({
|
||||
url: BASE_PATH + `/api/v1/basis/login/verification`,
|
||||
method: "POST",
|
||||
body: JSON.stringify(params),
|
||||
isLogin: true,
|
||||
})
|
||||
}
|
||||
|
||||
// 飞书登录
|
||||
export const fetchFeishuLogin = (params: Login.ReqFeishuLogin) => {
|
||||
return httpFetch<ResultData<Login.ResLogin>>({
|
||||
url: BASE_PATH + `/api/v1/basis/login/feishu`,
|
||||
method: "POST",
|
||||
body: JSON.stringify(params),
|
||||
isLogin: true,
|
||||
})
|
||||
}
|
||||
|
||||
// 刷新token
|
||||
export const refreshKey = (params: { token: string }) => {
|
||||
return httpFetch<ResultData<Login.ResRefreshKey>>({
|
||||
url: BASE_PATH + `/api/v1/basis/key/refresh`,
|
||||
method: "POST",
|
||||
body: JSON.stringify(params),
|
||||
isRefresh: true,
|
||||
})
|
||||
}
|
||||
|
||||
// 删除cookie
|
||||
export const deleteCookie = () => {
|
||||
return httpFetch<ResultData<string>>({
|
||||
url: `/api/session`,
|
||||
method: "DELETE",
|
||||
isDeleteCookie: true,
|
||||
})
|
||||
}
|
||||
65
components/login/api/types.ts
Normal file
65
components/login/api/types.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
export namespace Login {
|
||||
export interface ReqPasswdLogin {
|
||||
account?: string
|
||||
phone?: string
|
||||
password: string
|
||||
tenant: string
|
||||
platform: string
|
||||
app: string
|
||||
fingerprint: string
|
||||
}
|
||||
|
||||
export interface ReqVerificationLogin {
|
||||
phone: string
|
||||
verify_code: string
|
||||
tenant: string
|
||||
platform: string
|
||||
app: string
|
||||
fingerprint: string
|
||||
}
|
||||
|
||||
export interface ReqFeishuLogin {
|
||||
code: string
|
||||
redirect_uri: string
|
||||
tenant: string
|
||||
platform: string
|
||||
app: string
|
||||
app_id: string
|
||||
app_secret: string
|
||||
fingerprint: string
|
||||
}
|
||||
|
||||
export interface RbacDataItem {
|
||||
app: string
|
||||
cat: string
|
||||
platform: string
|
||||
tenant: string
|
||||
permission: {
|
||||
[x: string]: {
|
||||
[y: string]: [boolean, any, string]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface ResLogin {
|
||||
access_token: string
|
||||
cats: Array<{
|
||||
cat: string
|
||||
cat_id: number
|
||||
}>
|
||||
is_super: boolean
|
||||
tenant: string
|
||||
user_info: {
|
||||
[x: string]: string
|
||||
}
|
||||
rbac: {
|
||||
data: RbacDataItem[]
|
||||
}
|
||||
refresh_token: string
|
||||
}
|
||||
|
||||
export interface ResRefreshKey {
|
||||
access: string
|
||||
refresh: string
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user