在Typecho博客中显示天气,本站以handsome主题为例

首先注册心知天气获取api,注册地址https://www.seniverse.com/

需要修改的文件在网站根目录/usr/themes/handsome/component/headnav.php

在第54行</form>的下面将在心知天气获取到的代码添加进去即可

<!-- 知心天气-->
   <div id="tp-weather-widget" class="navbar-form navbar-form-sm navbar-left shift"></div>
<script>
  (function(a,h,g,f,e,d,c,b){b=function(){d=h.createElement(g);c=h.getElementsByTagName(g)[0];d.src=e;d.charset="utf-8";d.async=1;c.parentNode.insertBefore(d,c)};a["SeniverseWeatherWidgetObject"]=f;a[f]||(a[f]=function(){(a[f].q=a[f].q||[]).push(arguments)});a[f].l=+new Date();if(a.attachEvent){a.attachEvent("onload",b)}else{a.addEventListener("load",b,false)}}(window,document,"script","SeniverseWeatherWidget","//cdn.sencdn.com/widget2/static/js/bundle.js?t="+parseInt((new Date().getTime() / 100000000).toString(),10)));
  window.SeniverseWeatherWidget('show', {
    flavor: "slim",
    location: "WX4FBXXFKE4F",
    geolocation: true,
    language: "zh-Hans",
    unit: "c",
    theme: "auto",
    token: "c9e98fb7-0eaa-4e15-908b-c50d8013333f",
    hover: "enabled",
    container: "tp-weather-widget"
  })
</script>
  <!-- 知心天气-->
最后修改:2021 年 05 月 10 日 09 : 28 PM
如果觉得我的文章对你有用,请随意赞赏