liuyib / hexo-theme-stun

🦄 An elegant theme for Hexo

Home Page:https://theme-stun.github.io/docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

如何在网站底部添加浏览人数和运行时间

Keafmd opened this issue · comments

我想创建一个新的 issue

  • [] 是的,我已经阅读了 常见问题
  • [] 是的,我搜索并阅读了 Issues 列表(包括关闭的),但是没有帮助到我。
  • [] 是的,我是第一次使用 Stun 主题。
  • [] 是的,我之前用过 Stun 主题,并且可以正常运行。但是当我做了一些更改后,主题就无法正常运行了。
  • [] 是的,我使用了 平滑升级 的特性,并且阅读了其文档。

环境信息

Stun 版本:

Hexo 版本:

平台信息:

浏览器信息:

Node.js 和 NPM 版本:

NPM 依赖信息:

Hexo 配置信息:

查看代码 ...

Stun 配置信息:

查看代码 ...

预期行为

实际行为

重现步骤

  1. xxx
  2. xxx
  3. xxx

其他信息


可以引入自定义js文件如下:

function createtime() {
    var now = new Date();
    calculate();
    function calculate() {
        // 修改为你的起始时间
        var grt= new Date("03/30/2020 12:00:00");
        now.setTime(now.getTime()+250);
        days = (now - grt ) / 1000 / 60 / 60 / 24; dnum = Math.floor(days);
        hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum); hnum = Math.floor(hours);
        if(String(hnum).length ==1 ){hnum = "0" + hnum;} minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum);
        mnum = Math.floor(minutes); if(String(mnum).length ==1 ){mnum = "0" + mnum;}
        seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum);
        snum = Math.round(seconds); if(String(snum).length ==1 ){snum = "0" + snum;}
        document.getElementById("timeDate").innerHTML = "本站已运行 "+dnum+" 天 ";
        document.getElementById("times").innerHTML = hnum + " 小时 " + mnum + " 分 " + snum + " 秒";
    }}
setInterval("createtime()",250);

然后在配置文件中的footer.custom.text添加:

<span id="timeDate">载入天数...</span><span id="times">载入时分秒...</span><script type="text/javascript" src="https://asset.foolishfox.cn/files/js/_common.js"></script>