mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-23 23:45:08 +08:00
接入第三方登录(已接入Gitee[理论justAuth支持都可以接入]--抢先预览版
This commit is contained in:
@ -45,6 +45,11 @@
|
||||
<span v-else>登 录 中...</span>
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item style="width:100%;">
|
||||
<el-button @click="doAuth2Login" title="使用 Gitee 帐号登录">
|
||||
<span class="gitee-login-title">使用 Gitee 帐号登录</span>
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<!-- 底部 -->
|
||||
<div class="el-login-footer">
|
||||
@ -54,7 +59,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getCodeImg } from "@/api/login";
|
||||
import { getCodeImg,giteeLogin } from "@/api/login";
|
||||
import Cookies from "js-cookie";
|
||||
import { encrypt, decrypt } from '@/utils/jsencrypt'
|
||||
|
||||
@ -135,6 +140,14 @@ export default {
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
doAuth2Login() {
|
||||
console.log("开始Oauth登录...");
|
||||
this.loading = true;
|
||||
giteeLogin().then((res) => {
|
||||
console.log(res.url);
|
||||
window.location.href = res.url;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
27
yudao-admin-ui/src/views/oauthLogin.vue
Normal file
27
yudao-admin-ui/src/views/oauthLogin.vue
Normal file
@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<div>登录成功!</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getToken, setToken, removeToken } from '@/utils/auth'
|
||||
|
||||
export default {
|
||||
created() {
|
||||
var token = this.getOauthToken();
|
||||
setToken(token);
|
||||
this.$router.push({ path: this.redirect || "/" }).catch(() => {});
|
||||
},
|
||||
methods: {
|
||||
getOauthToken() {
|
||||
console.log(this);
|
||||
var h = window.location.href;
|
||||
var token = "token=";
|
||||
return h.substring(h.indexOf(token)+token.length);
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
Reference in New Issue
Block a user