新增加载耗时

在Typecho根目录config.inc.php文件中添加

function timer_start() {
        global $timestart;
        $mtime     = explode( ' ', microtime() );
        $timestart = $mtime[1] + $mtime[0];
        return true;
    }
    timer_start();
    function timer_stop( $display = 0, $precision = 3 ) {
        global $timestart, $timeend;
        $mtime     = explode( ' ', microtime() );
        $timeend   = $mtime[1] + $mtime[0];
        $timetotal = number_format( $timeend - $timestart, $precision );
        $r         = $timetotal < 1 ? $timetotal * 1000 . " ms" : $timetotal . " s";
        if ( $display ) {
            echo $r;
        }
        return $r;
    }

在文件/usr/themes/handsome/component/sidebar.php 中添加

<li class="list-group-item text-second"> <span class="blog-info-icons"><i data-feather="clock"></i></span> <span class="badge pull-right"><?php echo timer_stop();?></span><?php _me("加载耗时") ?></li>

新增访客总数

在Typecho根目录config.inc.php文件中添加

function theAllViews()
    {
        $db = Typecho_Db::get();
        $row = $db->fetchAll('SELECT SUM(VIEWS) FROM `typecho_contents`');
            echo number_format($row[0]['SUM(VIEWS)']);
    }

在文件/usr/themes/handsome/component/sidebar.php 中添加

<li class="list-group-item text-second"> <span class="blog-info-icons"><i data-feather="smile"></i></span> <span class="badge pull-right"><?php echo theAllViews();?></span><?php _me("访客总数") ?></li>

新增评论区一键打卡

主题设置 - 开发者设置 - 自定义JavaScript 和 PJAX回调函数均添加上以下代码

function a(a, b, c) {
        if (document.selection) a.focus(), sel = document.selection.createRange(), c ? sel.text = b + sel.text + c : sel.text = b, a.focus();
        else if (a.selectionStart || "0" == a.selectionStart) {
            var l = a.selectionStart,
                m = a.selectionEnd,
                n = m;
            c ? a.value = a.value.substring(0, l) + b + a.value.substring(l, m) + c + a.value.substring(m, a.value.length) : a.value = a.value.substring(0, l) + b + a.value.substring(m, a.value.length);
            c ? n += b.length + c.length : n += b.length - m + l;
            l == m && c && (n -= c.length);
            a.focus();
            a.selectionStart = n;
            a.selectionEnd = n
        } else a.value += b + c, a.focus()
}
var b = (new Date).toLocaleTimeString(),
        c = document.getElementById("comment") || 0;
window.SIMPALED = {};
window.SIMPALED.Editor = {
    daka: function() {
        a(c, "滴!学生卡!打卡时间:" + b, ",请上车的乘客系好安全带~")
    },
    zan: function() {
        a(c, " 写得好好哟,我要给你生猴子!::funny:04:: ")
    },
    cai: function() {
        a(c, "骚年,我怀疑你写了一篇假的文章!::funny:03:: ")
    }
};

主题目录的component/comments.php里面的130行左右参照下面代码进行修改

<div class="comment-form-comment form-group">

    <label for="comment">
        <?php _me("评论") ?>
        <span class="required text-danger">*</span>
    </label>

    <textarea id="comment" class="textarea form-control OwO-textarea" name="text" rows="5" placeholder="<?php _me("说点什么吧……") ?>" onkeydown="if(event.ctrlKey&&event.keyCode==13){document.getElementById('submit').click();return false};"><?php $this->remember('text'); ?>
    </textarea>

    <div class="OwO" style="display: inline;"></div>

    <div class="OwO" title="打卡" style="display: inline;" onclick="javascript:SIMPALED.Editor.daka();this.style.display='none'">
        <div class="OwO-logo"><i class="fontello-pencil"></i>
            <span class="OwOlogotext">打卡</span>
        </div>
    </div>
                            
    <div class="OwO" title="赞" style="display: inline;" onclick="javascript:SIMPALED.Editor.zan();this.style.display='none'">
    <div class="OwO-logo">
        <i class="glyphicon glyphicon-thumbs-up"></i>
        <span class="OwOlogotext"></span>
    </div>
    </div>

    <div class="OwO" title="踩" style="display: inline;" onclick="javascript:SIMPALED.Editor.cai();this.style.display='none'">
    <div class="OwO-logo">
    <i class="glyphicon glyphicon-thumbs-down"></i>
    <span class="OwOlogotext"></span>
    </div>
    </div>
    
    <div class="secret_comment" id="secret_comment" data-toggle="tooltip" data-original-title="<?php _me("开启该功能,您的评论仅作者和评论双方可见") ?>">
        <label class="secret_comment_label control-label"><?php _me("私密评论") ?></label>
        <div class="secret_comment_check">
            <label class="i-switch i-switch-sm bg-dark m-b-ss m-r">
                <input type="checkbox" id="secret_comment_checkbox">
                <i></i>
            </label>
        </div>
    </div>

</div>

主题设置 - 开发者设置 - 自定义CSS 添加以下代码

.secret_comment {
    top: 5px;
}
.OwO.OwO-open .OwO-body {
    display:table
}

部分来自https://sunpma.com/674.html

新增背景动态蜘蛛网效果

在主题 component/footer.php 中</body>标签之前加上:

<script type="text/javascript" src="https://cdn.bootcss.com/canvas-nest.js/1.0.1/canvas-nest.min.js"></script>

来自我的博客园:https://www.cnblogs.com/qq597585136/p/7019755.html

安装UploadGithubForTypecho插件

这个插件是Typecho文章附件上传Github并使用jsDelivr访问,原文地址在https://qwq.best/dev/152.html

去掉首页中间栏顶部博客名称文字

在主题index.php中注释<h1 class="m-n font-thin text-black l-h"></h>即可

Last modification:April 28th, 2020 at 11:52 pm
如果觉得我的文章对你有用,请随意赞赏