• 目标:网站头部

方法

  1. 心知天气官网申请秘钥并生成天气插件代码
  2. 将生成的以下代码放入/usr/themes/handsome/component/headnav.php的注释<!-- / search form -->之后并更换你的token即可

研究一下源码,再换token

<!-- 知心天气-->
    <ul class="nav navbar-nav" style="height:50px;">
<div id="tp-weather-widget" style="line-height: 50px;"></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: "WS0E9D8WN298",
    geolocation: true,
    language: "zh-Hans",
    unit: "c",
    theme: "dark",
    token: "20f97289-5d56-4879-805d-c4df5408b7d9",
    hover: "enabled",
    container: "tp-weather-widget"
  })
</script>
    </ul>

<!-- 知心结束-->
Last modification:June 24, 2024
If you think my article is useful to you, please feel free to appreciate