修改源码记录(方便后续升级)

隐藏友链页面全部友链按钮

  1. 注释无用代码
    打开[Blogroot]/themes/anzhiyu/layout/includes/page/flink.pug,注释全部友链代码
    查看代码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    .title-h2-a
    .title-h2-a-left
    h2(style='padding-top:0;margin:.6rem 0 .6rem') 🎣 钓鱼
    a.random-post-start.no-text-decoration(href='javascript:fetchRandomPost();')
    i.anzhiyufont.anzhiyu-icon-arrow-rotate-right
    //.title-h2-a-right
    // a.random-post-all.no-text-decoration(href='/link/') 全部友链
    #random-post

    include ../anzhiyu/random-friends-post-js.pug

修改footer样式

  1. 新增底部样式
    打开[Blogroot]/themes/anzhiyu/layout/includes/footer.pug,在底部新增代码

    查看代码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    #footer-banner
    .footer-banner-links
    .footer-banner-left
    #footer-banner-tips
    script.
    var typed = new Typed("#footer-banner-tips", {
    strings: ["最好的地方,是没去过的地方。最好的时光,是回不来的时光。", "The best place is a place you've never been to. The best time is the time that can't come back."],
    startDelay: 200,
    backDelay: 2000,
    typeSpeed: 100,
    loop: true,
    backSpeed: 20
    })

    .footer-banner-right
    #runtimeTextFoot
  2. 打开[Blogroot]/_config.anzhiyu.yml,引入typed.min.js

    查看代码
    1
    2
    3
    inject:
    head:
    - <script data-pjax src="/js/typed.min.js"></script>
  3. 修改站点运行时间逻辑
    打开[Blogroot]/themes/anzhiyu/layout/includes/third-party/runtime/runtime-js.pug,并修改

    查看代码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    // 更新网页中显示的网站运行时间
    function updateHtml() {
    const footer = document.getElementById("footer");
    if (!footer) return
    let currentTimeHtml = "";
    if (nowHour < 18 && nowHour >= 9) {
    // 如果是上班时间,默认就是"安知鱼-上班摸鱼中.svg"图片,不需要更改
    //currentTimeHtml = `本站居然运行了 ${dnum} 天<span id='runtime'> ${hnum} 小时 ${mnum}${snum} 秒 </span><i class='anzhiyufont anzhiyu-icon-heartbeat' style='color:red'></i>`;
    currentTimeHtml = `本站居然运行了 ${dnum} 天<span id='runtime'> ${hnum} 小时 ${mnum}${snum} 秒 </span>`;
    } else {
    // 如果是下班时间,插入"安知鱼-下班啦.svg"图片
    let img = document.querySelector("#workboard .workSituationImg");
    img.src = "#{offduty_img}";
    img.title = "#{offduty_description}";
    img.alt = "#{offduty_description}";

    currentTimeHtml = `本站居然运行了 ${dnum} 天<span id='runtime'> ${hnum} 小时 ${mnum}${snum} 秒 </span>`;
    }

    // if (document.getElementById("runtimeTextTip")) {
    // document.getElementById("runtimeTextTip").innerHTML = currentTimeHtml;
    // }
    if (document.getElementById("runtimeTextFoot")) {
    document.getElementById("runtimeTextFoot").innerHTML = currentTimeHtml;
    }
    }
  4. 新增底部样式
    新增公共css,如果是第一次修改记得引入该css(升级跳过该步)

    查看代码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    /*自定义页脚*/
    #footer-banner {
    padding: 1rem;
    margin-top: 1rem;
    display: flex;
    overflow: hidden;
    z-index: 1002;
    transition: .3s;
    /*border-top: var(--style-border)*/
    }

    #footer-banner .footer-banner-links {
    display: flex;
    justify-content: space-between;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    flex-wrap: wrap;
    align-items: center;
    white-space: nowrap;
    }

    #footer-banner .footer-banner-left {
    display: flex;
    flex-wrap: wrap;
    min-height: 32px
    }

    .footer-banner-right {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap
    }
    /*自定义页脚*/

pwa配置

  1. 图标存在[Blogroot]/source/img/siteicon/下(升级跳过该步)

  2. 迁移[Blogroot]/source/pwa/manifest.json到新版本项目(升级跳过该步)

  3. 安装必要插件(升级跳过该步)

    查看代码
    1
    2
    npm install --global gulp-cli # 全局安装gulp命令集
    npm install workbox-build gulp --save # 安装workbox和gulp插件
  4. 迁移gulpfile.js到新版本项目根目录(升级跳过该步)

    查看代码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    const gulp = require("gulp");
    const workbox = require("workbox-build");

    gulp.task('generate-service-worker', () => {
    return workbox.injectManifest({
    swSrc: './sw-template.js',
    swDest: './public/sw.js',
    globDirectory: './public',
    globPatterns: [
    // 缓存所有以下类型的文件,极端不推荐
    // "**/*.{html,css,js,json,woff2,xml}"
    // 推荐只缓存404,主页和主要样式和脚本。
    "404.html","index.html","js/main.js","css/index.css"
    ],
    modifyURLPrefix: {
    "": "./"
    }
    });
    });
    gulp.task("default", gulp.series("generate-service-worker"));
  5. 迁移sw-template.js到新版本项目根目录(升级跳过该步)

    查看代码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    const workboxVersion = '5.1.3';

    importScripts(`https://storage.googleapis.com/workbox-cdn/releases/${workboxVersion}/workbox-sw.js`);

    workbox.core.setCacheNameDetails({
    prefix: "your name"
    });

    workbox.core.skipWaiting();

    workbox.core.clientsClaim();

    // 注册成功后要立即缓存的资源列表
    // 具体缓存列表在gulpfile.js中配置,见下文
    workbox.precaching.precacheAndRoute(self.__WB_MANIFEST,{
    directoryIndex: null
    });

    // 清空过期缓存
    workbox.precaching.cleanupOutdatedCaches();

    // 图片资源(可选,不需要就注释掉)
    workbox.routing.registerRoute(
    /\.(?:png|jpg|jpeg|gif|bmp|webp|svg|ico)$/,
    new workbox.strategies.CacheFirst({
    cacheName: "images",
    plugins: [
    new workbox.expiration.ExpirationPlugin({
    maxEntries: 1000,
    maxAgeSeconds: 60 * 60 * 24 * 30
    }),
    new workbox.cacheableResponse.CacheableResponsePlugin({
    statuses: [0, 200]
    })
    ]
    })
    );

    // 字体文件(可选,不需要就注释掉)
    workbox.routing.registerRoute(
    /\.(?:eot|ttf|woff|woff2)$/,
    new workbox.strategies.CacheFirst({
    cacheName: "fonts",
    plugins: [
    new workbox.expiration.ExpirationPlugin({
    maxEntries: 1000,
    maxAgeSeconds: 60 * 60 * 24 * 30
    }),
    new workbox.cacheableResponse.CacheableResponsePlugin({
    statuses: [0, 200]
    })
    ]
    })
    );

    // 谷歌字体(可选,不需要就注释掉)
    workbox.routing.registerRoute(
    /^https:\/\/fonts\.googleapis\.com/,
    new workbox.strategies.StaleWhileRevalidate({
    cacheName: "google-fonts-stylesheets"
    })
    );
    workbox.routing.registerRoute(
    /^https:\/\/fonts\.gstatic\.com/,
    new workbox.strategies.CacheFirst({
    cacheName: 'google-fonts-webfonts',
    plugins: [
    new workbox.expiration.ExpirationPlugin({
    maxEntries: 1000,
    maxAgeSeconds: 60 * 60 * 24 * 30
    }),
    new workbox.cacheableResponse.CacheableResponsePlugin({
    statuses: [0, 200]
    })
    ]
    })
    );

    // jsdelivr的CDN资源(可选,不需要就注释掉)
    workbox.routing.registerRoute(
    /^https:\/\/cdn\.jsdelivr\.net/,
    new workbox.strategies.CacheFirst({
    cacheName: "static-libs",
    plugins: [
    new workbox.expiration.ExpirationPlugin({
    maxEntries: 1000,
    maxAgeSeconds: 60 * 60 * 24 * 30
    }),
    new workbox.cacheableResponse.CacheableResponsePlugin({
    statuses: [0, 200]
    })
    ]
    })
    );

    workbox.googleAnalytics.initialize();
  6. 迁移pwanotice.pug
    迁移[Blogroot]/themes/anzhiyu/layout/includes/third-party/pwanotice.pug到新版本项目

    查看代码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    #app-refresh.app-refresh(style='position: fixed;top: -2.2rem;left: 0;right: 0;z-index: 99999;padding: 0 1rem;font-size: 15px;height: 2.2rem;transition: all 0.3s ease;')
    .app-refresh-wrap(style=' display: flex;color: #fff;height: 100%;align-items: center;justify-content: center;')
    label ✨ 有新文章啦! 👉
    a(href='javascript:void(0)' onclick='location.reload()')
    span(style='color: #fff;text-decoration: underline;cursor: pointer;') 🍗点击食用🍔
    script.
    if ('serviceWorker' in navigator) {
    if (navigator.serviceWorker.controller) {
    navigator.serviceWorker.addEventListener('controllerchange', function() {
    showNotification()
    })
    }
    window.addEventListener('load', function() {
    navigator.serviceWorker.register('/sw.js')
    })
    }
    function showNotification() {
    if (GLOBAL_CONFIG.Snackbar) {
    var snackbarBg =
    document.documentElement.getAttribute('data-theme') === 'light' ?
    GLOBAL_CONFIG.Snackbar.bgLight :
    GLOBAL_CONFIG.Snackbar.bgDark
    var snackbarPos = GLOBAL_CONFIG.Snackbar.position
    Snackbar.show({
    text: '✨ 有新文章啦! 👉',
    backgroundColor: snackbarBg,
    duration: 500000,
    pos: snackbarPos,
    actionText: '🍗点击食用🍔',
    actionTextColor: '#fff',
    onActionClick: function(e) {
    location.reload()
    },
    })
    } else {
    var showBg =
    document.documentElement.getAttribute('data-theme') === 'light' ?
    '#3b70fc' :
    '#1f1f1f'
    var cssText = `top: 0; background: ${showBg};`
    document.getElementById('app-refresh').style.cssText = cssText
    }
    }

  7. 修改additional-js.pug
    打开[Blogroot]/themes/anzhiyu/layout/includes/additional-js.pug,在底部新增代码

    查看代码
    1
    2
    if theme.pwa.enable
    !=partial('includes/third-party/pwanotice', {}, {cache: theme.fragment_cache})
  8. 注释代码
    打开[Blogroot]/themes/anzhiyu/layout/includes/head/pwa.pug,注释底部代码

    查看代码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    //script.
    // if ('serviceWorker' in navigator) {
    // if (navigator.serviceWorker.controller) {
    // navigator.serviceWorker.addEventListener('controllerchange', function() {
    // location.reload()
    // })
    // }
    // window.addEventListener('load', function() {
    // navigator.serviceWorker.register('/service-worker.js')
    // })
    // }
  9. 打开pwa

    查看代码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    pwa:
    enable: true
    startup_image_enable: true
    manifest: /pwa/manifest.json
    theme_color: var(--anzhiyu-main)
    mask_icon: /img/siteicon/safari-pinned-tab.svg
    apple_touch_icon: /img/siteicon/apple-touch-icon.png
    bookmark_icon: /img/siteicon/apple-icon-180.png
    favicon_32_32: /img/siteicon/favicon-32x32.png
    favicon_16_16: /img/siteicon/favicon-16x16.png

侧边栏欢迎小窗口

  1. 新建[Blogroot]/source/js/welcome.js(升级跳过该步)

    查看代码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    //get请求,修改你的key和经纬度
    $.ajax({
    type: 'get',
    url: 'https://apis.map.qq.com/ws/location/v1/ip',
    data: {
    key: '你申请的腾讯位置key',
    output: 'jsonp',
    },
    dataType: 'jsonp',
    success: function (res) {
    ipLocation = res;
    }
    })
    function getDistance(e1, n1, e2, n2) {
    const R = 6371
    const { sin, cos, asin, PI, hypot } = Math
    let getPoint = (e, n) => {
    e *= PI / 180
    n *= PI / 180
    return { x: cos(n) * cos(e), y: cos(n) * sin(e), z: sin(n) }
    }

    let a = getPoint(e1, n1)
    let b = getPoint(e2, n2)
    let c = hypot(a.x - b.x, a.y - b.y, a.z - b.z)
    let r = asin(c / 2) * 2 * R
    return Math.round(r);
    }

    function showWelcome() {

    let dist = getDistance(123.44972, 41.71482, ipLocation.result.location.lng, ipLocation.result.location.lat); //这里记得换成自己的经纬度
    let pos = ipLocation.result.ad_info.nation;
    let ip;
    let posdesc;
    //根据国家、省份、城市信息自定义欢迎语
    switch (ipLocation.result.ad_info.nation) {
    case "日本":
    posdesc = "よろしく,一起去看樱花吗";
    break;
    case "美国":
    posdesc = "Let us live in peace!";
    break;
    case "英国":
    posdesc = "想同你一起夜乘伦敦眼";
    break;
    case "俄罗斯":
    posdesc = "干了这瓶伏特加!";
    break;
    case "法国":
    posdesc = "C'est La Vie";
    break;
    case "德国":
    posdesc = "Die Zeit verging im Fluge.";
    break;
    case "澳大利亚":
    posdesc = "一起去大堡礁吧!";
    break;
    case "加拿大":
    posdesc = "拾起一片枫叶赠予你";
    break;
    case "中国":
    pos = ipLocation.result.ad_info.province + " " + ipLocation.result.ad_info.city + " " + ipLocation.result.ad_info.district;
    ip = ipLocation.result.ip;
    switch (ipLocation.result.ad_info.province) {
    case "北京市":
    posdesc = "北——京——欢迎你~~~";
    break;
    case "天津市":
    posdesc = "讲段相声吧";
    break;
    case "河北省":
    posdesc = "山势巍巍成壁垒,天下雄关铁马金戈由此向,无限江山";
    break;
    case "山西省":
    posdesc = "展开坐具长三尺,已占山河五百余";
    break;
    case "内蒙古自治区":
    posdesc = "天苍苍,野茫茫,风吹草低见牛羊";
    break;
    case "辽宁省":
    posdesc = "我想吃烤鸡架!";
    break;
    case "吉林省":
    posdesc = "状元阁就是东北烧烤之王";
    break;
    case "黑龙江省":
    posdesc = "很喜欢哈尔滨大剧院";
    break;
    case "上海市":
    posdesc = "众所周知,中国只有两个城市";
    break;
    case "江苏省":
    switch (ipLocation.result.ad_info.city) {
    case "南京市":
    posdesc = "这是我挺想去的城市啦";
    break;
    case "苏州市":
    posdesc = "上有天堂,下有苏杭";
    break;
    default:
    posdesc = "散装是必须要散装的";
    break;
    }
    break;
    case "浙江省":
    posdesc = "东风渐绿西湖柳,雁已还人未南归";
    break;
    case "河南省":
    switch (ipLocation.result.ad_info.city) {
    case "郑州市":
    posdesc = "豫州之域,天地之中";
    break;
    case "南阳市":
    posdesc = "臣本布衣,躬耕于南阳此南阳非彼南阳!";
    break;
    case "驻马店市":
    posdesc = "峰峰有奇石,石石挟仙气嵖岈山的花很美哦!";
    break;
    case "开封市":
    posdesc = "刚正不阿包青天";
    break;
    case "洛阳市":
    posdesc = "洛阳牡丹甲天下";
    break;
    default:
    posdesc = "可否带我品尝河南烩面啦?";
    break;
    }
    break;
    case "安徽省":
    posdesc = "蚌埠住了,芜湖起飞";
    break;
    case "福建省":
    posdesc = "井邑白云间,岩城远带山";
    break;
    case "江西省":
    posdesc = "落霞与孤鹜齐飞,秋水共长天一色";
    break;
    case "山东省":
    posdesc = "遥望齐州九点烟,一泓海水杯中泻";
    break;
    case "湖北省":
    switch (ipLocation.result.ad_info.city) {
    case "黄冈市":
    posdesc = "红安将军县!辈出将才!";
    break;
    default:
    posdesc = "来碗热干面~";
    break;
    }
    break;
    case "湖南省":
    posdesc = "74751,长沙斯塔克";
    break;
    case "广东省":
    switch (ipLocation.result.ad_info.city) {
    case "广州市":
    posdesc = "看小蛮腰,喝早茶了嘛~";
    break;
    case "深圳市":
    posdesc = "今天你逛商场了嘛~";
    break;
    case "阳江市":
    posdesc = "阳春合水!博主家乡~ 欢迎来玩~";
    break;
    default:
    posdesc = "来两斤福建人~";
    break;
    }
    break;
    case "广西壮族自治区":
    posdesc = "桂林山水甲天下";
    break;
    case "海南省":
    posdesc = "朝观日出逐白浪,夕看云起收霞光";
    break;
    case "四川省":
    posdesc = "康康川妹子";
    break;
    case "贵州省":
    posdesc = "茅台,学生,再塞200";
    break;
    case "云南省":
    posdesc = "玉龙飞舞云缠绕,万仞冰川直耸天";
    break;
    case "西藏自治区":
    posdesc = "躺在茫茫草原上,仰望蓝天";
    break;
    case "陕西省":
    posdesc = "来份臊子面加馍";
    break;
    case "甘肃省":
    posdesc = "羌笛何须怨杨柳,春风不度玉门关";
    break;
    case "青海省":
    posdesc = "牛肉干和老酸奶都好好吃";
    break;
    case "宁夏回族自治区":
    posdesc = "大漠孤烟直,长河落日圆";
    break;
    case "新疆维吾尔自治区":
    posdesc = "驼铃古道丝绸路,胡马犹闻唐汉风";
    break;
    case "台湾省":
    posdesc = "我在这头,大陆在那头";
    break;
    case "香港特别行政区":
    posdesc = "永定贼有残留地鬼嚎,迎击光非岁玉";
    break;
    case "澳门特别行政区":
    posdesc = "性感荷官,在线发牌";
    break;
    default:
    posdesc = "带我去你的城市逛逛吧!";
    break;
    }
    break;
    default:
    posdesc = "带我去你的国家逛逛吧";
    break;
    }

    //根据本地时间切换欢迎语
    let timeChange;
    let date = new Date();
    if (date.getHours() >= 5 && date.getHours() < 11) timeChange = "<span>🌤️ 早上好,一日之计在于晨</span>";
    else if (date.getHours() >= 11 && date.getHours() < 13) timeChange = "<span>☀️ 中午好,记得午休喔~</span>";
    else if (date.getHours() >= 13 && date.getHours() < 17) timeChange = "<span>🕞 下午好,饮茶先啦!</span>";
    else if (date.getHours() >= 17 && date.getHours() < 19) timeChange = "<span>🚶‍♂️ 即将下班,记得按时吃饭~</span>";
    else if (date.getHours() >= 19 && date.getHours() < 24) timeChange = "<span>🌙 晚上好,夜生活嗨起来!</span>";
    else timeChange = "夜深了,早点休息,少熬夜";

    try {
    //自定义文本和需要放的位置
    document.getElementById("welcome-info").innerHTML =
    `欢迎来自 <b><span style="color: var(--kouseki-ip-color);font-size: var(--kouseki-gl-size)">${pos}</span></b> 的小友💖<br>${posdesc}🍂<br>当前位置距博主约 <b><span style="color: var(--kouseki-ip-color)">${dist}</span></b> 公里!<br>您的IP地址为:<b><span>${ip}</span></b><br>${timeChange} <br>`;
    } catch (err) {
    console.log("Pjax无法获取元素")
    }
    }
    window.onload = showWelcome;
    // 如果使用了pjax在加上下面这行代码
    document.addEventListener('pjax:complete', showWelcome);
  2. 引入公共css(升级跳过该步)

    查看代码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    /* 欢迎信息 */
    #welcome-info {
    overflow: hidden;
    border-radius: 14px;
    --kouseki-welcome-color: #49B1F5;
    --kouseki-ip-color: #49B1F5;
    --kouseki-gl-size: 16px!important;
    }
    /* 欢迎信息 */
  3. 引入jquery和欢迎js(升级跳过该步)

    查看代码
    1
    2
    3
    bottom:
    - <script src="https://cdn.staticfile.org/jquery/3.6.3/jquery.min.js"></script> # jQuery
    - <script async data-pjax src="/js/welcome.js"></script> # 腾讯位置API
  4. 放入侧边栏公告栏位置
    打开[Blogroot]/_config.anzhiyu.yml,修改以下代码

    查看代码
    1
    2
    3
    card_announcement:
    enable: true
    content: <div id="welcome-info"></div>

我的装备新增价格显示

  1. 创建pug页面文件
    打开[Blogroot]/themes/anzhiyu/layout/includes/page/equipment.pug,新增以下代码

    查看代码
    1
    2
    3
    4
    .equipment-item-content-item
    .equipment-item-content-item-cover
    div.equipment-item-content-item-price=iten.price
    img.equipment-item-content-item-image(data-lazy-src=url_for(iten.image) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt=iten.name)
  2. 引入公共css(升级跳过该步)

    查看代码
    1
    2
    3
    4
    5
    6
    7
    8
    .equipment-item-content-item-price {
    position: absolute;
    right: 10px;
    top: 10px;
    color: red;
    font-size: 14px;

    }

关于页添加个性小标签

  1. 修改about.pug
    打开[Blogroot]/themes/anzhiyu/layout/includes/page/about.pug,在以下位置新增代码

    查看代码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    #about-page
    .author-box
    .author-img
    img.no-lightbox(src=url_for(avatarImg) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar")
    .image-dot
    .author-tag-left
    span.author-tag 🤖️ 数码爱好者
    span.author-tag 🔍 不解决不放弃
    span.author-tag 🏠 智能家居小能手
    span.author-tag 🔨 开发小萌新
    .author-tag-right
    span.author-tag 折腾劲 MAX 🤝
    span.author-tag 脚踏实地行动派 🏃
    span.author-tag 践踏各种困难 🧱
    span.author-tag 话多人不狠 💢
    p.p.center.logo.large 关于我
    p.p.center.small=subtitle
  2. 引入公共css(升级跳过该步)

    查看代码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    @keyframes floating {
    0% {
    transform: translate(0, -4px);
    }
    50% {
    transform: translate(0, 4px);
    }
    100% {
    transform: translate(0, -4px);
    }
    }

    #about-page .author-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 185px;
    }

    #about-page .author-tag-left {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-right: 355px; /* 设置标签与头像之间的水平间距 */
    position: absolute;
    top: 15px;
    }

    #about-page .author-tag-right {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-left: 355px; /* 设置标签与头像之间的水平间距 */
    position: absolute;
    top: 15px;
    }
    /* 移动端隐藏 */
    @media screen and (max-width: 768px) {
    #about-page .author-tag-left, #about-page .author-tag-right {
    display: none;
    }
    }

    #about-page .author-tag-left .author-tag:first-child, #about-page .author-tag-left .author-tag:last-child {
    margin-right: -16px;
    }

    #about-page .author-tag-right .author-tag:first-child, #about-page .author-tag-right .author-tag:last-child {
    margin-left: -16px;
    }

    #about-page .author-tag {
    transform: translate(0, -4px);
    padding: 1px 8px;
    background: #fff;
    border: 1px solid #e3e8f7;
    border-radius: 40px;
    margin-top: 6px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 5px 12px -5px rgba(102, 68, 68, 0.00);
    animation: 4s ease-in-out 0s infinite normal none running floating;
    }
    /* 适配深色模式 */
    [data-theme="dark"] #about-page .author-tag {
    background: #1e1e1e;
    }
    #about-page .author-tag:nth-child(1) {
    animation-delay: 0s;
    }

    #about-page .author-tag:nth-child(2) {
    animation-delay: 0.6s;
    }

    #about-page .author-tag:nth-child(3) {
    animation-delay: 1.2s;
    }

    #about-page .author-tag:nth-child(4) {
    animation-delay: 1.8s;
    }

More info:

主页文章卡片添加擦亮动画效果

  1. 引入公共css(升级跳过该步)
    查看代码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    #recent-posts > .recent-post-item:not(a)::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 200%;
    background: linear-gradient(to right, transparent, white, transparent);
    transform: translateX(-200%);
    transition: transform 0.5s linear;
    z-index: 1;
    }
    #recent-posts > .recent-post-item:not(a):hover::before {
    transform: translateX(100%) skewX(-60deg);
    }

More info: