mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-01 22:53:29 +08:00
65 lines
2.7 KiB
HTML
65 lines
2.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
<title><%= title %></title>
|
|
<!-- <script src="/assets/lib/jquery/3.6.0/jquery.min.js"></script> -->
|
|
<script src="/assets/lib/axios/0.26.1/axios.min.js"></script>
|
|
<script src="/assets/javascripts/httpRequest.js"></script>
|
|
<script src="/assets/javascripts/localStorageUtils.js"></script>
|
|
<script>
|
|
// API地址
|
|
const APIHOST = '<%= global.site.api.prefix %>';
|
|
axios.defaults.baseURL = APIHOST;
|
|
</script>
|
|
</head>
|
|
|
|
<body>
|
|
<p id="displayText">
|
|
正在跳转中,请稍候...
|
|
</p>
|
|
<script>
|
|
// 带 token 的为绑定第三方账号,不带 token 的为第三方登录
|
|
var token = localStorageUtils.getToken();
|
|
getRequest("/third-party/callback/<%=platform%>" + location.search + (token ? ("&token=" + token) : ""))
|
|
.then(function (response) {
|
|
var axiosData = response.data;
|
|
var status = axiosData.status;
|
|
var data = axiosData.data;
|
|
if (status === "success") {
|
|
console.log(data)
|
|
// 默认直接跳转 user 后台,如果是管理员则由 user 后台跳转
|
|
if (token) {
|
|
// 绑定第三方账号
|
|
|
|
// 绑定第三方账号成功
|
|
alert("绑定成功");
|
|
location.href = "/dashboard/user/myAccount";
|
|
} else {
|
|
// 第三方登录成功
|
|
localStorageUtils.userLogin({
|
|
token: data.token,
|
|
is_admin: data.group === "ADMIN",
|
|
});
|
|
if (localStorageUtils.getIsAdmin()) {
|
|
window.location.href = "/dashboard/admin/index";
|
|
} else {
|
|
window.location.href = "/dashboard/user/index";
|
|
}
|
|
}
|
|
} else {
|
|
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
|
|
location.replace("/login");
|
|
}
|
|
}).catch(function (error) {
|
|
console.log(error);
|
|
document.getElementById("displayText").innerHTML = "系统错误,请稍后再试!";
|
|
document.getElementById("displayText").style.color = "red";
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html> |