♻️ refactored login-related code
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
import {service} from "@/utils/alova/service.ts";
|
||||
|
||||
/**
|
||||
* 获取Gitee登录链接
|
||||
*/
|
||||
export const getGiteeUrl = () => {
|
||||
return service.Get('/api/oauth/gitee/url',
|
||||
{
|
||||
meta: {
|
||||
ignoreToken: true,
|
||||
},
|
||||
cacheFor: {
|
||||
mode: "restore",
|
||||
expire: 1000 * 60 * 60 * 24
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
@@ -1,21 +0,0 @@
|
||||
import {service} from "@/utils/alova/service.ts";
|
||||
|
||||
/**
|
||||
* Get Github OAuth URL
|
||||
*/
|
||||
export const getGithubUrl = (state: string) => {
|
||||
return service.Get('/api/oauth/github/url',
|
||||
{
|
||||
params: {
|
||||
state: state
|
||||
},
|
||||
meta: {
|
||||
ignoreToken: true,
|
||||
},
|
||||
cacheFor: {
|
||||
mode: "restore",
|
||||
expire: 1000 * 60 * 60 * 24
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
57
src/api/oauth/index.ts
Normal file
57
src/api/oauth/index.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import {service} from "@/utils/alova/service.ts";
|
||||
|
||||
/**
|
||||
* 获取Gitee登录链接
|
||||
*/
|
||||
export const getGiteeUrl = () => {
|
||||
return service.Get('/api/oauth/gitee/url',
|
||||
{
|
||||
meta: {
|
||||
ignoreToken: true,
|
||||
},
|
||||
cacheFor: {
|
||||
mode: "restore",
|
||||
expire: 1000 * 60 * 60 * 24
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get Github OAuth URL
|
||||
*/
|
||||
export const getGithubUrl = (state: string) => {
|
||||
return service.Get('/api/oauth/github/url',
|
||||
{
|
||||
params: {
|
||||
state: state
|
||||
},
|
||||
meta: {
|
||||
ignoreToken: true,
|
||||
},
|
||||
cacheFor: {
|
||||
mode: "restore",
|
||||
expire: 1000 * 60 * 60 * 24
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
export const getQQUrl = (state: string) => {
|
||||
return service.Get('/api/oauth/qq/url',
|
||||
{
|
||||
params: {
|
||||
state: state
|
||||
},
|
||||
meta: {
|
||||
ignoreToken: true,
|
||||
},
|
||||
cacheFor: {
|
||||
mode: "restore",
|
||||
expire: 1000 * 60 * 60 * 24
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
@@ -1,18 +0,0 @@
|
||||
import {service} from "@/utils/alova/service.ts";
|
||||
|
||||
export const getQQUrl = (state: string) => {
|
||||
return service.Get('/api/oauth/qq/url',
|
||||
{
|
||||
params: {
|
||||
state: state
|
||||
},
|
||||
meta: {
|
||||
ignoreToken: true,
|
||||
},
|
||||
cacheFor: {
|
||||
mode: "restore",
|
||||
expire: 1000 * 60 * 60 * 24
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
@@ -1,20 +0,0 @@
|
||||
import {service} from "@/utils/alova/service.ts";
|
||||
|
||||
/**
|
||||
* 获取临时二维码
|
||||
* @param clientId
|
||||
*/
|
||||
export const generateQrCode = (clientId: string) => {
|
||||
return service.Get('/api/oauth/wechat/qrcode',
|
||||
{
|
||||
params: {
|
||||
client_id: clientId
|
||||
},
|
||||
cacheFor: null,
|
||||
meta: {
|
||||
ignoreToken: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
};
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import {service} from "@/utils/alova/service.ts";
|
||||
import {AccountLogin, PhoneLogin, ResetPassword} from "@/types/user";
|
||||
import {AccountLogin, PhoneLogin, ResetPassword, WechatOffiaccountLogin} from "@/types/user";
|
||||
|
||||
/**
|
||||
* 刷新token
|
||||
@@ -8,7 +8,7 @@ export const refreshToken = () => {
|
||||
return service.Post('/api/auth/token/refresh', {}, {
|
||||
meta: {
|
||||
authRole: 'refreshToken',
|
||||
ignoreToken: true,
|
||||
ignoreToken: false,
|
||||
signature: true
|
||||
}
|
||||
});
|
||||
@@ -89,16 +89,14 @@ export const resetPasswordApi = (param: ResetPassword) => {
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户设备信息
|
||||
* @param access_token
|
||||
* 微信扫码登录
|
||||
* @param param
|
||||
*/
|
||||
export const getUserDevice = (access_token: string) => {
|
||||
return service.Post('/api/user/device',
|
||||
{
|
||||
access_token: access_token,
|
||||
export const wechatOffiaccountLoginApi = (param: WechatOffiaccountLogin) => {
|
||||
return service.Post('/api/user/wechat/offiaccount/login', {
|
||||
openid: param.openid,
|
||||
client_id: param.client_id,
|
||||
},
|
||||
{
|
||||
meta: {
|
||||
@@ -108,3 +106,21 @@ export const getUserDevice = (access_token: string) => {
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 获取临时二维码
|
||||
* @param clientId
|
||||
*/
|
||||
export const generateQrCode = (clientId: string) => {
|
||||
return service.Post('/api/user/wechat/offiaccount/qrcode', {
|
||||
client_id: clientId
|
||||
}, {
|
||||
cacheFor: 60 * 60 * 24,
|
||||
meta: {
|
||||
ignoreToken: true,
|
||||
signature: true
|
||||
},
|
||||
}
|
||||
);
|
||||
};
|
||||
|
Reference in New Issue
Block a user