本教程均在handsome 8.4.1主题版本和Typecho V1.2.0中测试通过,不保证兼容其他版本,请自行修改相应步骤。

心知天气是在顶部边栏位置,顶部左右位置可以自行更改。

获取心知天气代码

在心知天气网站https://www.seniverse.com 注册然后点击免费试用,根据个人喜好设置样式,然后获得心知天气提供的代码。

心知天气配置代码

将获取的心知天气的代码添加到 handsome 模板component文件夹headnav.php中想要添加的位置添加时钟挂件引用代码

心知天气配置代码

                <!-- 知心天气-->
                <?php if(@in_array('weather',$this->options->featuresetup)): ?>
        <div id="tp-weather-widget" class="navbar-form navbar-form-sm navbar-left shift"></div>
<script>(function(T,h,i,n,k,P,a,g,e){g=function(){P=h.createElement(i);a=h.getElementsByTagName(i)[0];P.src=k;P.charset="utf-8";P.async=1;a.parentNode.insertBefore(P,a)};T["ThinkPageWeatherWidgetObject"]=n;T[n]||(T[n]=function(){(T[n].q=T[n].q||[]).push(arguments)});T[n].l=+new Date();if(T.attachEvent){T.attachEvent("onload",g)}else{T.addEventListener("load",g,false)}}(window,document,"script","tpwidget","//widget.seniverse.com/widget/chameleon.js"))</script>
<script>tpwidget("init",{"flavor":"slim","location":"WX4FBXXFKE4F","geolocation":"enabled","language":"auto","unit":"c","theme":"chameleon","container":"tp-weather-widget","bubble":"enabled","alarmType":"badge","color":"#C6C6C6","uid":"PNsgfUOMYQo2UwCy8","hash":"Soh-I2TA1g-jUP-G6"
});tpwidget("show");</script>
<?php endif; ?>
<!-- 知心结束-->
  

心知天气控制代码

handsome 模板functions_mine.php文件中382行添加如下代码,就可以在后台控制天气是否显示。

心知天气控制代码

'weather' => _t('启用心知天气'),

这样这个心知天气的挂件就完成了,如果不喜欢放置在左侧,还可以自行调整位置。

最后修改:2022 年 05 月 23 日
如果觉得我的文章对你有用,请随意赞赏