接口修改
This commit is contained in:
1 parent
4452435ecf
commit
7ba2bfce2b
5 files changed
+6022
-4833
No files matched your search
+29
-10
@@ -1,9 +1,21 @@
|
||||
import request from "@/sheep/utils/request"
|
||||
import { encryption } from "@/sheep/utils/encryption"
|
||||
|
||||
const basicAuth = "Basic " + window.btoa(import.meta.env.VITE_OAUTH2_APP_CLIENT)
|
||||
// 将 Basic Auth 字符串提取为常量
|
||||
const BASIC_AUTH = "Basic " + window.btoa(import.meta.env.VITE_OAUTH2_APP_CLIENT)
|
||||
|
||||
// 定义接口类型
|
||||
interface LoginParams {
|
||||
username: string
|
||||
password: string
|
||||
randomStr: string
|
||||
code: string
|
||||
grant_type: string
|
||||
scope: string
|
||||
}
|
||||
|
||||
export default {
|
||||
// 获取用户信息
|
||||
userInfo: () =>
|
||||
request({
|
||||
url: "/admin/user/info",
|
||||
@@ -14,17 +26,19 @@ export default {
|
||||
},
|
||||
}),
|
||||
|
||||
auth: (str: any) =>
|
||||
// 浙政钉授权
|
||||
auth: (token: string) =>
|
||||
request({
|
||||
// url: `/sys/auth/zzdsso/${str}`,
|
||||
url: `/thirdparty/thirdPartyOAth2/zzdsso/${str}`,
|
||||
url: `/thirdparty/thirdPartyOAth2/zzdsso/${token}`,
|
||||
method: "GET",
|
||||
custom: {
|
||||
showLoading: false,
|
||||
loadingMsg: "授权中",
|
||||
},
|
||||
}),
|
||||
authsh: (params: any) =>
|
||||
|
||||
// 诗画授权
|
||||
authsh: (params: { accountId: string; sessionId: string }) =>
|
||||
request({
|
||||
url: `/sys/auth/shjnsso`,
|
||||
method: "POST",
|
||||
@@ -34,7 +48,9 @@ export default {
|
||||
},
|
||||
data: params,
|
||||
}),
|
||||
refreshToken: (params: any) =>
|
||||
|
||||
// 刷新token
|
||||
refreshToken: (params: { refreshToken: string }) =>
|
||||
request({
|
||||
url: `/sys/auth/refresh-token`,
|
||||
method: "POST",
|
||||
@@ -43,24 +59,27 @@ export default {
|
||||
showLoading: false,
|
||||
},
|
||||
}),
|
||||
login: (params: any): any => {
|
||||
|
||||
// 登录
|
||||
login: (params: LoginParams) => {
|
||||
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,
|
||||
password,
|
||||
randomStr,
|
||||
code,
|
||||
grant_type,
|
||||
scope,
|
||||
},
|
||||
data: { password: password },
|
||||
data: { password },
|
||||
header: {
|
||||
skipToken: true,
|
||||
Authorization: basicAuth,
|
||||
Authorization: BASIC_AUTH,
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
custom: {
|
||||
|
||||
Reference in new issue
Block a user