修复谷歌登录

This commit is contained in:
X1627315083
2025-09-22 14:09:08 +08:00
parent ab2bdc25f7
commit da241402f2
4 changed files with 62 additions and 26 deletions

3
components.d.ts vendored
View File

@@ -10,10 +10,12 @@ declare module 'vue' {
export interface GlobalComponents {
ABadge: typeof import('ant-design-vue/es')['Badge']
ACheckbox: typeof import('ant-design-vue/es')['Checkbox']
AConfigProvider: typeof import('ant-design-vue/es')['ConfigProvider']
ADrawer: typeof import('ant-design-vue/es')['Drawer']
AImage: typeof import('ant-design-vue/es')['Image']
AInputNumber: typeof import('ant-design-vue/es')['InputNumber']
AModal: typeof import('ant-design-vue/es')['Modal']
APagination: typeof import('ant-design-vue/es')['Pagination']
APopover: typeof import('ant-design-vue/es')['Popover']
ARangePicker: typeof import('ant-design-vue/es')['RangePicker']
ASelect: typeof import('ant-design-vue/es')['Select']
@@ -25,6 +27,7 @@ declare module 'vue' {
ATabPane: typeof import('ant-design-vue/es')['TabPane']
ATabs: typeof import('ant-design-vue/es')['Tabs']
AUpload: typeof import('ant-design-vue/es')['Upload']
ElCascader: typeof import('element-plus/es')['ElCascader']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
}

View File

@@ -27,10 +27,10 @@
<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> -->
<div class="gmail_btn" @click="toGmailLogin">
<div v-if="!userDetail.accountExtendList?.Google" class="gallery_btn forbidden">{{ $t('frontPage.BindNow') }}</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 class="gmail_btn">
<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-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>
@@ -138,12 +138,13 @@ export default defineComponent({
bindPageDom.bindEmail.init('Modify')
}
const toGmailLogin = ()=>{
message.info(t('account.canNotUtilize'))
}
onMounted(async ()=>{
return
let GOOGLE_CLIENT_ID = '29310152396-nnsd3h533fld665oguu8ovrt1nukmt46.apps.googleusercontent.com'
let GOOGLE_CLIENT_ID
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}"]`);
if(!window.isAddGmail){
if(!existingScript){
@@ -206,7 +207,6 @@ export default defineComponent({
ungroupGoogleModel,
ungroupWeiXinModel,
modifyEmail,
toGmailLogin,
}
},
data(){
@@ -271,14 +271,21 @@ export default defineComponent({
}
>.gmail_btn{
position: relative;
border-radius: 4rem;
overflow: hidden;
> .gallery_btn{
position: relative;
z-index: 2;
pointer-events: none;
}
#g_id_bind{
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
opacity: 0;
z-index: 2;
// opacity: 0;
z-index: 1;
:deep(.nsm7Bb-HzV7m-LgbsSe.Bz112c-LgbsSe){
width: 100%;
}

View File

@@ -3,8 +3,8 @@
<!-- 谷歌登录 -->
<div class="g_id_signin" id="g_id_signin">
</div>
<div class="icon">
<!-- <div class="icon" @click="toGmailLogin"> -->
<div class="icon">
<img src="@/assets/images/loginPage/gmailIcon.svg" alt="">
<span>{{ $props.text }}</span>
</div>
@@ -26,6 +26,20 @@
},
setup(props, { emit }) {
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) => {
// 获取回调响应的凭证数据 然后拿这个凭证给后台后台jwt进行解析获取登录信息
console.log("Encoded JWT ID token: " + response.credential);
@@ -63,11 +77,11 @@
window.isAddGmail = true
await new Promise((resolve, reject) => {
const script = document.createElement("script");
script.src = data.scriptSrc
script.onload=()=>{
resolve()
}
document.body.appendChild(script);
script.src = data.scriptSrc
})
}
window.google.accounts.id.initialize({
@@ -79,6 +93,7 @@
ux_mode:"popup",
itp_support:true,
});
console.log(document.querySelector('.Container #g_id_signin'))
window.google.accounts.id.renderButton(
document.querySelector('.Container #g_id_signin'),
{
@@ -132,7 +147,6 @@
// width: 100%;
// height: 100%;
// }
// }
.icon{
// width: 40px;
@@ -176,15 +190,20 @@
position: absolute;
width: 100%;
height: 100%;
overflow: hidden;
// overflow: hidden;
top: 0;
left: 0;
opacity: 0;
// opacity: 0;
.S9gUrf-YoZ4jf{
}
:deep(.S9gUrf-YoZ4jf){
width: 100%;
height: 100%;
iframe{
zoom: 3;
}
}
}
&:hover{

View File

@@ -408,6 +408,7 @@ export default defineComponent({
if(res.errCode == 0){
file.imgUrl = res.data.url;
file.id = res.data.id
data.currentList.forEach((listItem:any)=>listItem.isChecked = false)
data.fileList.forEach((listItem:any)=>{
if(listItem.id == file.id){
listItem.isChecked = true
@@ -415,7 +416,6 @@ export default defineComponent({
listItem.isChecked = false
}
})
data.currentList.forEach((listItem:any)=>listItem.isChecked = false)
file.type = 'ProductElement'
// if(props.productimgMenu.value == 'Relight'){
// file.type = "ToProductImage"
@@ -553,6 +553,13 @@ export default defineComponent({
watch(()=>store.state.HomeStoreModule.uploadElement.length,(newVal,oldVal)=>{
if(props.isDesignPage)return
data.fileList = store.state.HomeStoreModule.uploadElement
data.fileList.forEach((listItem:any)=>{
if(listItem.id == data.selectImg.id){
listItem.isChecked = true
}else{
listItem.isChecked = false
}
})
})
watch(()=>data.noLikeList.length,(newVal,oldVal)=>{
nextTick(()=>{