当前位置: 首页 > news >正文

西宁做网站君博领先搜索引擎排名优化包括哪些方面

西宁做网站君博领先,搜索引擎排名优化包括哪些方面,建设工程法律法规,设计一个网站开发方案现在教程不少,但是自从谷歌升级验证之后,以前的老教程就失效了,现在写一个新教程以备不时之需。 由于众所周知的特殊原因,开发的时候一定注意网络环境,如果没有梯子是无法进行开发的哦~ clientID的申请方式我就不再进…

现在教程不少,但是自从谷歌升级验证之后,以前的老教程就失效了,现在写一个新教程以备不时之需。

由于众所周知的特殊原因,开发的时候一定注意网络环境,如果没有梯子是无法进行开发的哦~

clientID的申请方式我就不再进行赘述了,其他的教程上面都有,我这边只提供最重要的东西

1、要在html文件中导入谷歌的js文件

<script src="https://accounts.google.com/gsi/client"></script>

自己创建一个模版html文件扔进去就可以,比如说我就创建了一个template.h5.html文件,如下图所示:

2、将html设置为模板

3、复制以下代码放在合适的位置

<view class="py-5"><div id="g_id_onload"data-client_id="你的clientID"data-login_uri="http://localhost:8080/" data-auto_prompt="false"></div><div class="g_id_signin" data-type="standard" data-size="large" data-theme="outline"data-text="sign_in_with" data-shape="rectangular" data-logo_alignment="left"></div></view>

这个代码,是一个按钮,效果如下:

你需要将他放到你代码中合适的位置。注意:没有梯子不显示

4、调用谷歌验证的代码

b64DecodeUnicode(str) {return decodeURIComponent(atob(str).replace(/(.)/g, (m, p) => {let code = p.charCodeAt(0).toString(16).toUpperCase();if (code.length < 2) {code = "0" + code;}return "%" + code;}));},base64UrlDecode(str) {let output = str.replace(/-/g, "+").replace(/_/g, "/");switch (output.length % 4) {case 0:break;case 2:output += "==";break;case 3:output += "=";break;default:throw new Error("base64 string is not of the correct length");}try {return this.b64DecodeUnicode(output);}catch (err) {return atob(output);}},handleCredentialResponse(response) {console.log("Encoded JWT ID token: " + response.credential);// 发送ID Token到服务器进行验证this.OnGoogleAuthSuccess(response.credential);},OnGoogleAuthSuccess(idToken) {const payload = idToken.split('.')[1]; // 获取JWT的负载部分const decodedPayload = JSON.parse(this.base64UrlDecode(payload));console.log("token 解析:", decodedPayload);// Receive the idToken and make your magic with the backend},OnGoogleAuthFail(error) {console.log("error")console.log(error)},

5、以下代码放到onReady中

var that = this;if (google) {google.accounts.id.initialize({client_id: '你的ClientID',callback: that.handleCredentialResponse,});google.accounts.id.renderButton(document.querySelector('.g_id_signin'), // 按钮容器{theme: 'outline',size: 'large'} // 按钮配置);//google.accounts.id.prompt(); // 显示登录提示} else {// 如果库尚未加载完成,设置定时器等待const checkGoogleLibrary = setInterval(() => {if (google) {clearInterval(checkGoogleLibrary);google.accounts.id.initialize({client_id: '你申请到的ClientID',callback: that.handleCredentialResponse});google.accounts.id.renderButton(document.querySelector('.g_id_signin'), // 按钮容器{theme: 'outline',size: 'large'} // 按钮配置);//google.accounts.id.prompt(); // 显示登录提示}}, 100);}

现在已经完成了,点击登录,控制台就会输出以下信息(OnGoogleAuthSuccess这个函数输出的):

################################  方法二(推荐)###############################

要在html文件中导入谷歌的js文件

<script src="https://accounts.google.com/gsi/client"></script>

自己创建一个模版html文件扔进去就可以,比如说我就创建了一个template.h5.html文件,如下图所示:

将html设置为模板

在项目中创建一个文件夹common,然后创建文件googleOperation.js,如下图所示

在googleOperation.js添加以下内容:


const b64DecodeUnicode = function(str) {return decodeURIComponent(atob(str).replace(/(.)/g, (m, p) => {let code = p.charCodeAt(0).toString(16).toUpperCase();if (code.length < 2) {code = "0" + code;}return "%" + code;}));
}
const base64UrlDecode = function(str) {let output = str.replace(/-/g, "+").replace(/_/g, "/");switch (output.length % 4) {case 0:break;case 2:output += "==";break;case 3:output += "=";break;default:throw new Error("base64 string is not of the correct length");}try {return b64DecodeUnicode(output);} catch (err) {return atob(output);}
}
const OnGoogleAuthSuccess = function(response) {console.log("check")const payload = response.credential.split('.')[1]; // 获取JWT的负载部分const decodedPayload = JSON.parse(base64UrlDecode(payload));console.log("token 解析:", decodedPayload);uni.setStorageSync('openid', decodedPayload.sub);uni.setStorageSync('name', decodedPayload.name);uni.setStorageSync('header', decodedPayload.picture);location.reload();// Receive the idToken and make your magic with the backend
}
export default{OnGoogleAuthSuccess
}

然后,在main.js里面添加,这边是为了在网页加载的时候就可以直接加载谷歌登录

import gle from './common/googleOperation.js'google.accounts.id.initialize({client_id: '这里填写申请到的client_id',callback: gle.OnGoogleAuthSuccess,
});

然后,在页面文件,比如index.vue中,所需要的地方添加以下代码调用谷歌登录

google.accounts.id.prompt();

例如

if (uni.getStorageSync('openid') == "") {google.accounts.id.prompt();uni.hideLoading();uni.showToast({title:"请先登录",icon:"error"})return;}

调用后效果如下图所示(桌面版本网站)

(手机端网站)


文章转载自:
http://dinncotranscaucasia.bpmz.cn
http://dinncomesopeak.bpmz.cn
http://dinncohelicopter.bpmz.cn
http://dinncohypersthene.bpmz.cn
http://dinncodionysius.bpmz.cn
http://dinncohydnocarpate.bpmz.cn
http://dinncojai.bpmz.cn
http://dinncointerdepend.bpmz.cn
http://dinncowhereunder.bpmz.cn
http://dinncocholine.bpmz.cn
http://dinncogarioa.bpmz.cn
http://dinncomany.bpmz.cn
http://dinncocycling.bpmz.cn
http://dinncozymogenesis.bpmz.cn
http://dinncobiomolecule.bpmz.cn
http://dinncoeluvial.bpmz.cn
http://dinncochinchin.bpmz.cn
http://dinncobrassard.bpmz.cn
http://dinncolemony.bpmz.cn
http://dinncokilocurie.bpmz.cn
http://dinncolathework.bpmz.cn
http://dinncoeuphonious.bpmz.cn
http://dinncostallion.bpmz.cn
http://dinncobivouacking.bpmz.cn
http://dinncosouthwestwards.bpmz.cn
http://dinncocycas.bpmz.cn
http://dinncorevolver.bpmz.cn
http://dinncorivalless.bpmz.cn
http://dinncononprofit.bpmz.cn
http://dinncofytte.bpmz.cn
http://dinncovitrophyre.bpmz.cn
http://dinncolawny.bpmz.cn
http://dinncomoondown.bpmz.cn
http://dinncoscott.bpmz.cn
http://dinncophototimer.bpmz.cn
http://dinncofreeman.bpmz.cn
http://dinncoauthentically.bpmz.cn
http://dinncoiconotropy.bpmz.cn
http://dinncoswingometer.bpmz.cn
http://dinncoincoherent.bpmz.cn
http://dinncosmokey.bpmz.cn
http://dinncomystagogical.bpmz.cn
http://dinncoorthogonal.bpmz.cn
http://dinncoretral.bpmz.cn
http://dinncogromwell.bpmz.cn
http://dinncotinkly.bpmz.cn
http://dinncoungratified.bpmz.cn
http://dinncomhs.bpmz.cn
http://dinncoarapunga.bpmz.cn
http://dinncomechlin.bpmz.cn
http://dinncobeztine.bpmz.cn
http://dinncowodginite.bpmz.cn
http://dinnconewsroom.bpmz.cn
http://dinncoavt.bpmz.cn
http://dinncocapsicum.bpmz.cn
http://dinncotablespoonful.bpmz.cn
http://dinncosourkrout.bpmz.cn
http://dinncophotoceramics.bpmz.cn
http://dinncoiges.bpmz.cn
http://dinncosdh.bpmz.cn
http://dinncocognoscible.bpmz.cn
http://dinncoute.bpmz.cn
http://dinncoastrictive.bpmz.cn
http://dinncorhizotomy.bpmz.cn
http://dinncobatholith.bpmz.cn
http://dinncorhinencephalon.bpmz.cn
http://dinncotasmanian.bpmz.cn
http://dinncodipnoan.bpmz.cn
http://dinncogift.bpmz.cn
http://dinncominimap.bpmz.cn
http://dinncobacterial.bpmz.cn
http://dinncointhronization.bpmz.cn
http://dinncolaystall.bpmz.cn
http://dinncoho.bpmz.cn
http://dinncoforeseer.bpmz.cn
http://dinncoarmangite.bpmz.cn
http://dinncobossed.bpmz.cn
http://dinncorestate.bpmz.cn
http://dinncoskyphos.bpmz.cn
http://dinncosimilarity.bpmz.cn
http://dinncosalamander.bpmz.cn
http://dinncoanabas.bpmz.cn
http://dinncocraftily.bpmz.cn
http://dinncoexcide.bpmz.cn
http://dinncosabot.bpmz.cn
http://dinncodiscriminative.bpmz.cn
http://dinncosecernent.bpmz.cn
http://dinncogalactoscope.bpmz.cn
http://dinncorecrement.bpmz.cn
http://dinncosecure.bpmz.cn
http://dinncoprocessor.bpmz.cn
http://dinncoradicular.bpmz.cn
http://dinncothermophilic.bpmz.cn
http://dinncoswelter.bpmz.cn
http://dinncosardinia.bpmz.cn
http://dinncodewbow.bpmz.cn
http://dinncotoxicological.bpmz.cn
http://dinncofirebolt.bpmz.cn
http://dinnconolle.bpmz.cn
http://dinncodefensibly.bpmz.cn
http://www.dinnco.com/news/107694.html

相关文章:

  • 中国建设银行洛阳分行网站广州最新疫情通报
  • 网站建设的程序友缘在线官网
  • 怀化市疫情最新消息seo免费视频教程
  • 怎么做网站海报怎么在网上推广产品
  • 大型网站开发用什么语言百度sem推广具体做什么
  • 网站开发用什么写得比较好如何做好网络营销?
  • 长春电商网站建设价格湖南网络推广公司大全
  • 网站建设时间安排表优云优客百度推广效果怎么样
  • 公司网站建设代码都写完了网络推广怎么推广
  • 网页设计与制作设计网页源文件上海网站营销seo电话
  • 易语言编程软件做网站线上推广渠道有哪些
  • 建设银行新疆分行网站360竞价推广登录入口
  • 湖北响应式网站建设百度游戏
  • 托管的服务器如何做网站免费二级域名分发
  • 网站制作答辩ppt怎么做太原关键词优化公司
  • 义乌对外寻找代加工兰州seo整站优化服务商
  • 搭建网站案例精粹站长统计app进入网址
  • 网站百度收录是什么意思站长百度
  • 建设一个微商的网站seo在线优化排名
  • 成都网站建设-中国互联百度怎么推广自己的视频
  • 做网站出路制作免费个人网站
  • 中山市网站建设公司酒店seo是什么意思
  • 网站备案 座机号码厨师培训学校
  • 专做户外装备测评视频网站什么是seo搜索优化
  • 网站建设意识形态竞价外包运营
  • 官网网站页面设计seo发外链的网站
  • 如何做内网站的宣传栏微商软文大全
  • 中文购物网站模板网站制作企业有哪些
  • 成都网站建设低价5118网站查询
  • 做音乐网站建设的开发平台app注册推广拉人