Files
labelmain/components/login/api/index.ts

76 lines
2.0 KiB
TypeScript

import httpFetch from "@/api/fetch"
import { ResultData } from "@/api/typing"
import { BASE_LABEL_API } from "@/components/label/api/const"
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,
})
}
// /api/v1/label_server/user/permission
export const getUserPermission = () => {
return httpFetch<any>({
url: BASE_LABEL_API + `/api/v1/label_server/user/permission`,
method: "GET",
})
}