在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: "WS36TH3V9370",
      geolocation: true,
      language: "auto",
      unit: "c",
      theme: "light",
      token: "57f2d718-da81-4fed-98ee-bd019756d0fa",
      hover: "enabled",
      container: "tp-weather-widget"
    })
  </script>
  <!-- 知心天气-->
最后修改:2020 年 02 月 08 日 01 : 39 PM
如果觉得我的文章对你有用,请随意赞赏