打开谷歌登录
This commit is contained in:
@@ -27,10 +27,10 @@
|
|||||||
<div v-show="!userDetail.accountExtendList?.Google" id="g_id_bind"></div>
|
<div v-show="!userDetail.accountExtendList?.Google" id="g_id_bind"></div>
|
||||||
<div v-if="userDetail.accountExtendList?.Google" class="gallery_btn" @click="ungroupGoogleModel">{{ $t('frontPage.Unbind') }}</div>
|
<div v-if="userDetail.accountExtendList?.Google" class="gallery_btn" @click="ungroupGoogleModel">{{ $t('frontPage.Unbind') }}</div>
|
||||||
</div> -->
|
</div> -->
|
||||||
<div class="gmail_btn" @click="toGmailLogin">
|
<div class="gmail_btn">
|
||||||
<div v-if="!userDetail.accountExtendList?.Google" class="gallery_btn forbidden">{{ $t('frontPage.BindNow') }}</div>
|
<div v-if="!userDetail.accountExtendList?.Google" class="gallery_btn">{{ $t('frontPage.BindNow') }}</div>
|
||||||
<!-- <div v-show="!userDetail.accountExtendList?.Google" id="g_id_bind"></div> -->
|
<div v-show="!userDetail.accountExtendList?.Google" id="g_id_bind"></div>
|
||||||
<div v-if="userDetail.accountExtendList?.Google" class="gallery_btn forbidden" @click="ungroupGoogleModel">{{ $t('frontPage.Unbind') }}</div>
|
<div v-if="userDetail.accountExtendList?.Google" class="gallery_btn" @click="ungroupGoogleModel">{{ $t('frontPage.Unbind') }}</div>
|
||||||
<!-- <div v-if="userDetail.accountExtendList?.Google" class="gallery_btn" @click="ungroupGoogleModel">{{ $t('frontPage.Unbind') }}</div> -->
|
<!-- <div v-if="userDetail.accountExtendList?.Google" class="gallery_btn" @click="ungroupGoogleModel">{{ $t('frontPage.Unbind') }}</div> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -138,12 +138,13 @@ export default defineComponent({
|
|||||||
bindPageDom.bindEmail.init('Modify')
|
bindPageDom.bindEmail.init('Modify')
|
||||||
|
|
||||||
}
|
}
|
||||||
const toGmailLogin = ()=>{
|
|
||||||
message.info(t('account.canNotUtilize'))
|
|
||||||
}
|
|
||||||
onMounted(async ()=>{
|
onMounted(async ()=>{
|
||||||
return
|
let GOOGLE_CLIENT_ID
|
||||||
let GOOGLE_CLIENT_ID = '29310152396-nnsd3h533fld665oguu8ovrt1nukmt46.apps.googleusercontent.com'
|
if(import.meta.env.VITE_USER_NODE_ENV == 'development'){
|
||||||
|
GOOGLE_CLIENT_ID = '157095842121-kdd1fdf8m8nudvj9sprstb2k2prnf9e4.apps.googleusercontent.com'
|
||||||
|
}else{
|
||||||
|
GOOGLE_CLIENT_ID = '29310152396-nnsd3h533fld665oguu8ovrt1nukmt46.apps.googleusercontent.com'
|
||||||
|
}
|
||||||
var existingScript = document.querySelector(`script[src="${data.scriptSrc}"]`);
|
var existingScript = document.querySelector(`script[src="${data.scriptSrc}"]`);
|
||||||
if(!window.isAddGmail){
|
if(!window.isAddGmail){
|
||||||
if(!existingScript){
|
if(!existingScript){
|
||||||
@@ -206,7 +207,6 @@ export default defineComponent({
|
|||||||
ungroupGoogleModel,
|
ungroupGoogleModel,
|
||||||
ungroupWeiXinModel,
|
ungroupWeiXinModel,
|
||||||
modifyEmail,
|
modifyEmail,
|
||||||
toGmailLogin,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data(){
|
data(){
|
||||||
@@ -271,14 +271,21 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
>.gmail_btn{
|
>.gmail_btn{
|
||||||
position: relative;
|
position: relative;
|
||||||
|
border-radius: 4rem;
|
||||||
|
overflow: hidden;
|
||||||
|
> .gallery_btn{
|
||||||
|
position: relative;
|
||||||
|
z-index: 2;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
#g_id_bind{
|
#g_id_bind{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
opacity: 0;
|
// opacity: 0;
|
||||||
z-index: 2;
|
z-index: 1;
|
||||||
:deep(.nsm7Bb-HzV7m-LgbsSe.Bz112c-LgbsSe){
|
:deep(.nsm7Bb-HzV7m-LgbsSe.Bz112c-LgbsSe){
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="Container">
|
<div class="Container">
|
||||||
<!-- 谷歌登录 -->
|
<!-- 谷歌登录 -->
|
||||||
<!-- <div class="g_id_signin" id="g_id_signin">
|
<div class="g_id_signin" id="g_id_signin">
|
||||||
</div> -->
|
</div>
|
||||||
<div class="icon" @click="toGmailLogin" style="opacity: .7;">
|
<!-- <div class="icon" @click="toGmailLogin"> -->
|
||||||
|
<div class="icon">
|
||||||
<img src="@/assets/images/loginPage/gmailIcon.svg" alt="">
|
<img src="@/assets/images/loginPage/gmailIcon.svg" alt="">
|
||||||
<span>{{ $props.text }}</span>
|
<span>{{ $props.text }}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -25,8 +26,33 @@
|
|||||||
},
|
},
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const {t} = useI18n()
|
const {t} = useI18n()
|
||||||
|
function decodeJWT(token) {
|
||||||
|
|
||||||
|
let base64Url = token.split(".")[1];
|
||||||
|
let base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
||||||
|
let jsonPayload = decodeURIComponent(
|
||||||
|
atob(base64)
|
||||||
|
.split("")
|
||||||
|
.map(function (c) {
|
||||||
|
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
|
||||||
|
})
|
||||||
|
.join("")
|
||||||
|
);
|
||||||
|
return JSON.parse(jsonPayload);
|
||||||
|
}
|
||||||
const handleCredentialResponse = async (response) => {
|
const handleCredentialResponse = async (response) => {
|
||||||
// 获取回调响应的凭证数据 然后拿这个凭证给后台,后台jwt进行解析获取登录信息
|
// 获取回调响应的凭证数据 然后拿这个凭证给后台,后台jwt进行解析获取登录信息
|
||||||
|
console.log("Encoded JWT ID token: " + response.credential);
|
||||||
|
const responsePayload = decodeJWT(response.credential);
|
||||||
|
console.log("Decoded JWT ID token fields:");
|
||||||
|
console.log(" Full Name: " + responsePayload.name);
|
||||||
|
console.log(" Given Name: " + responsePayload.given_name);
|
||||||
|
console.log(" Family Name: " + responsePayload.family_name);
|
||||||
|
console.log(" Unique ID: " + responsePayload.sub);
|
||||||
|
console.log(" Profile image URL: " + responsePayload.picture);
|
||||||
|
console.log(" Email: " + responsePayload.email);
|
||||||
|
|
||||||
|
|
||||||
let code = response.credential
|
let code = response.credential
|
||||||
emit('googelLogin',code)
|
emit('googelLogin',code)
|
||||||
window.isAddGmail = false
|
window.isAddGmail = false
|
||||||
@@ -36,10 +62,10 @@
|
|||||||
scriptSrc:'https://accounts.google.com/gsi/client',
|
scriptSrc:'https://accounts.google.com/gsi/client',
|
||||||
script:null
|
script:null
|
||||||
})
|
})
|
||||||
console.log()
|
console.log(import.meta.env.VITE_USER_NODE_ENV)
|
||||||
let GOOGLE_CLIENT_ID
|
let GOOGLE_CLIENT_ID
|
||||||
if(import.meta.env.VITE_USER_NODE_ENV == 'development'){
|
if(import.meta.env.VITE_USER_NODE_ENV == 'development'){
|
||||||
GOOGLE_CLIENT_ID = '29310152396-c44dcsoksjirhn7vbo29p8u8n0sg4qps.apps.googleusercontent.com'
|
GOOGLE_CLIENT_ID = '157095842121-kdd1fdf8m8nudvj9sprstb2k2prnf9e4.apps.googleusercontent.com'
|
||||||
}else{
|
}else{
|
||||||
GOOGLE_CLIENT_ID = '29310152396-nnsd3h533fld665oguu8ovrt1nukmt46.apps.googleusercontent.com'
|
GOOGLE_CLIENT_ID = '29310152396-nnsd3h533fld665oguu8ovrt1nukmt46.apps.googleusercontent.com'
|
||||||
}
|
}
|
||||||
@@ -51,11 +77,11 @@
|
|||||||
window.isAddGmail = true
|
window.isAddGmail = true
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
const script = document.createElement("script");
|
const script = document.createElement("script");
|
||||||
script.src = data.scriptSrc
|
|
||||||
script.onload=()=>{
|
script.onload=()=>{
|
||||||
resolve()
|
resolve()
|
||||||
}
|
}
|
||||||
document.body.appendChild(script);
|
document.body.appendChild(script);
|
||||||
|
script.src = data.scriptSrc
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
window.google.accounts.id.initialize({
|
window.google.accounts.id.initialize({
|
||||||
@@ -67,19 +93,19 @@
|
|||||||
ux_mode:"popup",
|
ux_mode:"popup",
|
||||||
itp_support:true,
|
itp_support:true,
|
||||||
});
|
});
|
||||||
|
console.log(document.querySelector('.Container #g_id_signin'))
|
||||||
window.google.accounts.id.renderButton(
|
window.google.accounts.id.renderButton(
|
||||||
document.querySelector('.Container #g_id_signin'),
|
document.querySelector('.Container #g_id_signin'),
|
||||||
{
|
{
|
||||||
type:"standard",//icon为只有一个icon
|
type:"standard",//icon为只有一个icon
|
||||||
shape:"circle",
|
shape:"circle",
|
||||||
theme:"outline",
|
theme:"outline",
|
||||||
size:"large",
|
size:"large",
|
||||||
logo_alignment:"center",
|
logo_alignment:"center",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const toGmailLogin = ()=>{
|
const toGmailLogin = ()=>{
|
||||||
console.log(12312)
|
|
||||||
message.info(t('account.canNotUtilize'))
|
message.info(t('account.canNotUtilize'))
|
||||||
}
|
}
|
||||||
onBeforeUnmount(()=>{
|
onBeforeUnmount(()=>{
|
||||||
@@ -90,7 +116,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
onMounted(()=>{
|
onMounted(()=>{
|
||||||
// createGmailLogin()
|
createGmailLogin()
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
toGmailLogin,
|
toGmailLogin,
|
||||||
@@ -121,7 +147,6 @@
|
|||||||
// width: 100%;
|
// width: 100%;
|
||||||
// height: 100%;
|
// height: 100%;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// }
|
// }
|
||||||
.icon{
|
.icon{
|
||||||
// width: 40px;
|
// width: 40px;
|
||||||
@@ -135,7 +160,7 @@
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
position: relative;
|
position: relative;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
// pointer-events: none;
|
pointer-events: none;
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
border-radius: 2.5rem;
|
border-radius: 2.5rem;
|
||||||
@@ -165,15 +190,20 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: hidden;
|
// overflow: hidden;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
opacity: 0;
|
// opacity: 0;
|
||||||
.S9gUrf-YoZ4jf{
|
.S9gUrf-YoZ4jf{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
:deep(.S9gUrf-YoZ4jf){
|
:deep(.S9gUrf-YoZ4jf){
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
iframe{
|
||||||
|
zoom: 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&:hover{
|
&:hover{
|
||||||
|
|||||||
Reference in New Issue
Block a user