Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Keafmd opened this issue Oct 25, 2021 · 2 comments
Open

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

Keafmd opened this issue Oct 25, 2021 · 2 comments

Comments

@Keafmd
Copy link

Keafmd commented Oct 25, 2021

我想创建一个新的 issue

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

环境信息

Stun 版本:

Hexo 版本:

平台信息:

浏览器信息:

Node.js 和 NPM 版本:

NPM 依赖信息:

Hexo 配置信息:

查看代码 ...

Stun 配置信息:

查看代码 ...

预期行为

实际行为

重现步骤

  1. xxx
  2. xxx
  3. xxx

其他信息


@YiHui-Liu
Copy link
Contributor

可以引入自定义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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants