← 返回列表

handsome主题美化记录

·服务器与项目部署

logo扫光效果

[scode type="share"]自定义css[/scode]

/* logo扫光 */
.navbar-brand {
  position: relative;
  overflow: hidden;
  margin: 0;
}

.navbar-brand:before {
  content: "";
  position: absolute;
  left: -665px;
  top: -460px;
  width: 200px;
  height: 15px;
  background: linear-gradient(45deg, #b8b8b8, #f5f5f5, #d0d0d0);
  background-size: 400% 400%;
  border-radius: 50%;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.6), 0 0 40px rgba(255, 255, 255, 0.3);
  transform: rotate(-45deg);
  animation: searchLights 6s ease-in-out infinite, metalShine 3s linear infinite;
}

/* 使光束动画更流畅,并带有金属反射效果 */
@keyframes searchLights {
  0% {
    left: -665px;
    top: -460px;
  }
  50% {
    left: -100px;
    top: 0;
  }
  65% {
    left: 120px;
    top: 100px;
  }
  80% {
    left: -100px;
    top: 0;
  }
  100% {
    left: -665px;
    top: -460px;
  }
}

/* 金属光泽闪动效果 */
@keyframes metalShine {
  0% {
    background-position: 0% 0%;
  }
  50% {
    background-position: 100% 100%;
  }
  100% {
    background-position: 0% 0%;
  }
}

自定义滚动条

[scode type="share"]自定义css[/scode]

/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/ 
::-webkit-scrollbar {
    width: 8px;
    height: 6px
}
/*定义滚动条轨道*/ 
::-webkit-scrollbar-track {
    background-color: transparent;
    -webkit-border-radius: 2em;
    -moz-border-radius: 2em;
    border-radius: 2em
}
/*定义滑块 内阴影+圆角*/ 
::-webkit-scrollbar-thumb {
    background-color: #30B07F;
    background-image: -webkit-linear-gradient(45deg,rgba(255,255,255,.4) 100%,transparent 100%,transparent 50%,rgba(255,255,255,.4) 50%,rgba(255,255,255,.4) 75%,transparent 75%,transparent);
    -webkit-border-radius: 2em;
    -moz-border-radius: 2em;
    border-radius: 2em
}

点赞按钮跳动

[scode type="share"]自定义css[/scode]

/*赞赏按钮跳动开始*/
.btn-pay {
    animation: star 0.5s ease-in-out infinite alternate;
}
@keyframes star {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.1);
    }
}
/*赞赏按钮跳动结束*/

两侧留白间距

[scode type="share"]自定义css[/scode]
/两侧框架留白间距/
@media (min-width:1700px) {
.app.container {
width: 95%
}

    .app.container .app-aside,
    .app.container .app-header {
        max-width: 95%
    }
}

@media (min-width:2048px) {
    .app.container {
        width: 93%
    }

    .app.container .app-aside,
    .app.container .app-header {
        max-width: 93%
    }
}

@media (min-width:1200px) {
    .app.container {
        width: 90%
    }

    .app.container .app-aside,
    .app.container .app-header {
        max-width: 100%
    }

    .app.container .app-footer-fixed {
        max-width: 970px
    }

    .app.container.app-aside-folded .app-footer-fixed {
        max-width: 1110px
    }

    .app.container.app-aside-dock .app-footer-fixed {
        max-width: 90%
    }
}
/*两侧框架留白间距结束*/

文章一二三四级目录美化
[scode type="share"]自定义css[/scode]

/*文章一二三四级标题美化 开始*/
#post-content h1 {font-size: 30px}
#post-content h2 {position: relative;margin: 36px 0 20px!important;font-size: 1.55em;display: inline-block;}
#post-content h3 {font-size: 20px}
#post-content h4 {font-size: 15px}
#post-content h2::after {transition:all .35s;content:"";position:absolute;background:linear-gradient(#3c67bd8c 30%,#3c67bd 70%);width:1em;left:0;box-shadow:0 3px 3px rgba(32,160,255,.4);height:3px;bottom:-8px;}
#post-content h2::before {content:"";width:100%;border-bottom:1px solid #eee;bottom:-7px;position:absolute}
#post-content h2:hover::after {width: 2.5em;}
#post-content h1,#post-content h2,#post-content h3,#post-content h4,#post-content h5,#post-content h6 {color:#666;line-height:1.4;font-weight:700;margin:30px 0 10px 0}
/*文章一二三四级标题美化 结束*/

复制弹窗

[scode type="share"]自定义JS[/scode]

//复制弹框
$("body").bind('copy',
        function(e) {
            copytips()
        })
//禁用F12
document.onkeydown = function(){
    if(window.event && window.event.keyCode == 123) {
        event.keyCode=0;
        event.returnValue=false;
    }

}           
 function copytips() {
      var sitesurl=window.location.href;
        $.message({
            message: "尊重原创,转载请注明出处!<br> 本文作者:富强<br>原文链接:" + sitesurl,
            title: "复制成功",
            type: "warning",
            autoHide: !1,
            time: "3500"
        })
    }

点击特效(富强民主...)

[scode type="share"]自定义JS[/scode]

var a_idx = 0;
jQuery(document).ready(function($) {
    $("body").click(function(e) {
        var a = new Array("富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信", "友善");
        var \(i = \)("<span/>").text(a[a_idx]);
        a_idx = (a_idx + 1) % a.length;
        var x = e.pageX,
        y = e.pageY;
        $i.css({
            "z-index": 100000000,
            "top": y - 20,
            "left": x,
            "position": "absolute",
            "font-weight": "bold",
            "color": "#ff6651"
        });
        \(("body").append(\)i);
        $i.animate({
            "top": y - 180,
            "opacity": 0
        },
        1500,
        function() {
            $i.remove();
        });
    });
});

自定义右键

[scode type="share"]尾部body HTML[/scode]

<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(88,130,238,0.88)}
    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://hittlrw.top"><i class="fontello fontello-home"></i><span>首页</span></a></li>
        <li><a href="javascript:void(0);" onclick="getSelect();"><i class="fontello fontello-pencil"></i><span>复制</span></a></li>
        <li><a href="javascript:void(0);" onclick="baiduSearch();"><i class="fontello fontello-search"></i><span>搜索</span></a></li>
        <li><a href="javascript:history.go(1);"><i class="fontello fontello-chevron-right"></i><span>前进</span></a></li>
        <li><a href="javascript:history.go(-1);"><i class="fontello fontello-chevron-left"></i><span>后退</span></a></li>
        <li style="border-bottom:1px solid gray"><a href="javascript:window.location.reload();"><i class="fontello fontello-refresh"></i><span>重载网页</span></a></li>
        <li><a href="https://hittlrw.top/index.php/start-page.html"><i class="fontello fontello-emo-tongue"></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>

</body>
</html>

添加刚刚做了什么

[login]
用appuptimer向搭建的n8n服务发送webhook,n8n处理后添加进另外的数据库内,博客再调用数据库的数据显示出来。

先在config.inc.php文件中配置额外的数据库信息

// 外部活动数据库配置
define('EXT_DB_HOST', '127.0.0.1');      // 数据库地址
define('EXT_DB_PORT', '3306');           // 端口(可选)
define('EXT_DB_USER', 'xxxxx');
define('EXT_DB_PASS', 'xxxxx');
define('EXT_DB_NAME', 'xxxxx');

在主题的functions.php文件中添加下面的代码

function get_activity_data() {
        // --- 检查必要常量是否已定义 ---
        $required = ['EXT_DB_HOST', 'EXT_DB_USER', 'EXT_DB_PASS', 'EXT_DB_NAME'];
        foreach (\(required as \)const) {
            if (!defined($const)) {
                error_log("get_activity_data: 常量 {$const} 未定义,请在 config.inc.php 中设置");
                return null;
            }
        }

        // --- 缓存设置 ---
        $cacheFile = dirname(__FILE__) . '/activity_cache.php';
        $cacheLifetime = 3600; // 1小时

        // 尝试读取缓存
        if (file_exists(\(cacheFile) && (time() - filemtime(\)cacheFile)) < $cacheLifetime) {
            \(cached = include \)cacheFile;
            if (is_array(\(cached) && isset(\)cached['name'])) {
                return $cached;
            }
        }

        // --- 连接外部数据库 ---
        try {
            $mysqli = new mysqli(
                EXT_DB_HOST,
                EXT_DB_USER,
                EXT_DB_PASS,
                EXT_DB_NAME,
                defined('EXT_DB_PORT') ? EXT_DB_PORT : 3306
            );

            if ($mysqli->connect_error) {
                throw new Exception('数据库连接失败: ' . $mysqli->connect_error);
            }
            $mysqli->set_charset('utf8mb4');

            // 直接使用表名 `day`
            $sql = "SELECT `start`, `end`, `name` FROM `day` LIMIT 1";
            \(result = \)mysqli->query($sql);

            $data = null;
            if (\(result && \)row = $result->fetch_assoc()) {
                $data = [
                    'name'  => $row['name'],
                    'start' => $row['start'],
                    'end'   => $row['end']
                ];
                // 写入缓存
                file_put_contents(\(cacheFile, '<?php return ' . var_export(\)data, true) . ';');
            }

            $mysqli->close();
            return $data;

        } catch (Exception $e) {
            error_log('活动数据查询失败: ' . $e->getMessage());
            return null;
        }
    }

在sadebar中合适的位置添加下面的代码

<section id="what_i_did" class="widget widget_categories wrapper-md padder-v-none clear">
    <h5 class="widget-title m-t-none"><?php _me("刚刚做了什么?") ?></h5>
    <ul class="list-group box-shadow-wrap-normal">
        <?php
        $activity = get_activity_data();
        if (\(activity && !empty(\)activity['name'])) {
            \(name = htmlspecialchars(\)activity['name']);
            \(start = htmlspecialchars(\)activity['start']);
            \(end = htmlspecialchars(\)activity['end']);
            echo '<li class="list-group-item text-second">🎯 <strong>' . $name . '</strong></li>';
            echo '<li class="list-group-item text-second">🚀' . $start . '</li>';
            echo '<li class="list-group-item text-second">🏁' . $end . '</li>';
        } else {
            echo '<li class="list-group-item text-second" style="color:#999;">' . _me("暂无活动记录") . '</li>';
        }
        ?>
    </ul>
</section>

[/login]

本文作者:富强

文章标题:handsome主题美化记录

本文地址:https://hittlrw.top/index.php/archives/42/

版权说明:本文皆富强原创,转载请保留文章出处。

发表评论

42 ITEMS 关于