Files
pj_h5_cloud/src/sheep/api/user.ts
T
2025-01-10 11:23:54 +08:00

71 lines
1.4 KiB
TypeScript

import request from "@/sheep/utils/request"
import { encryption } from "@/sheep/utils/encryption"
const basicAuth = "Basic " + window.btoa(import.meta.env.VITE_OAUTH2_APP_CLIENT)
export default {
userInfo: () =>
request({
url: "/admin/user/info",
method: "GET",
custom: {
showLoading: false,
loadingMsg: "登录中",
},
}),
auth: (str: any) =>
request({
url: `/sys/auth/zzdsso/${str}`,
method: "GET",
custom: {
showLoading: false,
loadingMsg: "授权中",
},
}),
authsh: (params: any) =>
request({
url: `/sys/auth/shjnsso`,
method: "POST",
custom: {
showLoading: false,
loadingMsg: "授权中",
},
data: params,
}),
refreshToken: (params: any) =>
request({
url: `/sys/auth/refresh-token`,
method: "POST",
params,
custom: {
showLoading: false,
},
}),
login: (params: any): any => {
const { username, password, randomStr, code, grant_type, scope } = params
const encPassword = encryption(password, import.meta.env.VITE_PWD_ENC_KEY)
return request({
url: `/auth/oauth2/token`,
method: "POST",
params: {
username,
password: password,
randomStr,
code,
grant_type,
scope,
},
data: { password: password },
header: {
skipToken: true,
Authorization: basicAuth,
"content-type": "application/x-www-form-urlencoded",
},
custom: {
showLoading: false,
},
})
},
}