复制成功弹窗提示

添加以下代码至设置外观→开发者设置→自定义JavaScript:

kaygb_copy();function kaygb_copy(){$(document).ready(function(){$("body").bind('copy',function(e){hellolayer()})});var sitesurl=window.location.href;function hellolayer(){
$.message({
    message: "复制成功,转载请注明出处!",
    title: "复制成功",
    type: "success",
    autoHide: !1,
    time: "5000"
    })
}}

在主题设置 → PJAX → PJAX回调函数中添加:kaygb_copy();

代码高亮

代码高亮是通过引用Prism.js文件实现的,首先在Prism.js官网根据需求下载相应的js文件和css文件,下载完成后将之上传至jsDelivr上,随后在handsome设置中引入样式文件即可:

在设置→开发者设置→自定义输出head 头部的HTML代码添加下述代码:

<!--引入prism.js实现代码高亮-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/drxs/JsDelivrCDN@master/PrismJs/prism.css">

在设置→开发者设置→自定义输出body尾部的HTML代码添加下述代码:

<!--引入prism.js实现代码高亮-->
<script src="https://cdn.jsdelivr.net/gh/drxs/JsDelivrCDN@master/PrismJs/prism.js"></script>

随后,在PJAX回调函数中添加 Prism.highlightAll();即可。

自定义鼠标右键

在外观设置→开发者设置→自定义输出body尾部的HTML代码中,插入下面的代码:

<!-- 自定义右键 -->
<style type="text/css">
    a {text-decoration: none;}
    div.usercm{background-repeat:no-repeat;background-position:center center;background-size:cover;background-color:#fff;font-size:13px!important;width:130px;-moz-box-shadow:1px 1px 3px rgba
(0,0,0,.3);box-shadow:0px 0px 15px #333;position:absolute;display:none;z-index:10000;opacity:0.9;border-radius: 8px;}
    div.usercm ul{list-style-type:none;list-style-position:outside;margin:0px;padding:0px;display:block}
    div.usercm ul li{margin:0px;padding:0px;line-height:35px;}
    div.usercm ul li a{color:#666;padding:0 15px;display:block}
    div.usercm ul li a:hover{color:#fff;background:rgba(149,200,245,0.92);border-radius: 8px}
    div.usercm ul li a i{margin-right:10px}
    a.disabled{color:#c8c8c8!important;cursor:not-allowed}
    a.disabled:hover{background-color:rgba(255,11,11,0)!important}
    div.usercm{background:#fff !important;}
    </style>
<div class="usercm" style="left: 199px; top: 5px; display: none;">
    <ul>
        <li><a href="https://www.wangyusong.cn/"><i class="fa fa-home fa-fw"></i><span>首页</span></a></li>
        <li><a href="javascript:void(0);" onclick="getSelect();"><i class="fa fa-file fa-fw"></i><span>复制</span></a></li>
        <li><a href="javascript:void(0);" onclick="baiduSearch();"><i class="fa fa-search fa-fw"></i><span>百度</span></a></li>
        <li><a href="javascript:window.location.reload();"><i class="fa fa-refresh fa-fw"></i><span>刷新</span></a></li>
        <li><a href="javascript:window.opener=null;window.open('','_self');window.close();"><i class="fa fa-refresh fa-fw"></i><span>关闭</span></a></li>

    </ul>
</div>
<script type="text/javascript">
    (function(a) {
        a.extend({
            mouseMoveShow: function(b) {
                var d = 0,
                    c = 0,
                    h = 0,
                    k = 0,
                    e = 0,
                    f = 0;
                a(window).mousemove(function(g) {
                    d = a(window).width();
                    c = a(window).height();
                    h = g.clientX;
                    k = g.clientY;
                    e = g.pageX;
                    f = g.pageY;
                    h + a(b).width() >= d && (e = e - a(b).width() - 5);
                    k + a(b).height() >= c && (f = f - a(b).height() - 5);
                    a("html").on({
                        contextmenu: function(c) {
                            3 == c.which && a(b).css({
                                left: e,
                                top: f
                            }).show()
                        },
                        click: function() {
                            a(b).hide()
                        }
                    })
                })
            },
            disabledContextMenu: function() {
                window.oncontextmenu = function() {
                    return !1
                }
            }
        })
    })(jQuery);
   
    function getSelect() {
        "" == (window.getSelection ? window.getSelection() : document.selection.createRange().text) ? layer.msg("请选择需要复制的内容!") : document.execCommand("Copy")
    }
    function baiduSearch() {
        var a = window.getSelection ? window.getSelection() : document.selection.createRange().text;
        "" == a ? layer.msg("请选择需要搜索的内容!") : window.open("https://www.baidu.com/s?wd=" + a)
    }
    $(function() {
        for (var a = navigator.userAgent, b = "Android;iPhone;SymbianOS;Windows Phone;iPad;iPod".split(";"), d = !0, c = 0; c < b.length; c++) if (0 < a.indexOf(b[c])) {
            d = !1;
            break
        }
        d && ($.mouseMoveShow(".usercm"), $.disabledContextMenu())
    });
    </script>

累计访客数量与网站响应耗时

将下述代码添加至themes/handsome/libs/Content.php的上方:

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

/**
 * 响应时间
 */
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;
}

然后在sidebar.php中添加下述代码:

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

全站字数统计

在component/sidebar.php的上方添加下述代码:

<?php
//字数统计
function allOfCharacters() {
    $chars = 0;
    $db = Typecho_Db::get();
    $select = $db ->select('text')->from('table.contents');
    $rows = $db->fetchAll($select);
    foreach ($rows as $row) { $chars += mb_strlen(trim($row['text']), 'UTF-8'); }
    $unit = '';
    if($chars >= 10000)     { $chars /= 10000; $unit = '万'; } 
    else if($chars >= 1000) { $chars /= 1000;  $unit = '千'; }
    $out = sprintf('%.2lf %s',$chars, $unit);
    return $out;
}
?>

在博客信息的相关位置添加下述代码:

<li class="list-group-item text-second"><span class="blog-info-icons"><i data-feather="edit-2"></i></span> <span class="badge pull-right"><?php echo allOfCharacters(); ?></span><?php _me("全站字数") ?></li>

美化插件

AliceStyle

速度优化

handsome主题静态资源:

https://cdn.jsdelivr.net/gh/drxs/JsDelivrCDN@master/handsome/assets/

AliceStyle插件静态资源:

https://cdn.jsdelivr.net/gh/drxs/JsDelivrCDN@master/AliceStyle/static/

最后修改:2020 年 10 月 30 日 09 : 33 PM