From 0ce81d19f91b24d24dac7037250f75500cfbc157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8D=93Sco?= Date: Wed, 7 Feb 2024 19:46:24 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=90=9Bbug:=20=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=8D=B3=E5=88=BB=E7=9F=AD=E6=96=87=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- languages/en-US.yml | 2 +- languages/zh-CN.yml | 2 +- languages/zh-TW.yml | 2 +- layout/includes/widgets/page/says/json.pug | 1 - layout/includes/widgets/page/says/memos.pug | 3 --- 5 files changed, 3 insertions(+), 7 deletions(-) diff --git a/languages/en-US.yml b/languages/en-US.yml index c2ee4e00..c368eea6 100755 --- a/languages/en-US.yml +++ b/languages/en-US.yml @@ -75,7 +75,7 @@ search: head: noscript: Please enable JavaScript to view the site - console: 'Program: Hexo | Theme: Hexo-Theme-Solitude | Author: WangZhuoSco、YiFeng | Github: https://github.com/wleelw/Hexo-theme-solitude | Version: v1.4.6 😄' + console: 'Program: Hexo | Theme: Hexo-Theme-Solitude | Author: WangZhuoSco、YiFeng | Github: https://github.com/wleelw/Hexo-theme-solitude | Version: v1.4.7 😄' aside: postcount: 'Posts :' diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml index 43f8ec2e..36bd0782 100755 --- a/languages/zh-CN.yml +++ b/languages/zh-CN.yml @@ -75,7 +75,7 @@ search: head: noscript: 开启JavaScript才能访问本站哦~ - console: '程序:Hexo | 主题:Hexo-Theme-Solitude | 作者:王卓Sco、亦封 | Github: https://github.com/wleelw/Hexo-theme-solitude | 版本:v1.4.6 😄' + console: '程序:Hexo | 主题:Hexo-Theme-Solitude | 作者:王卓Sco、亦封 | Github: https://github.com/wleelw/Hexo-theme-solitude | 版本:v1.4.7 😄' aside: postcount: '文章总数 :' diff --git a/languages/zh-TW.yml b/languages/zh-TW.yml index 5c2f6157..4428c45b 100755 --- a/languages/zh-TW.yml +++ b/languages/zh-TW.yml @@ -75,7 +75,7 @@ search: head: noscript: 開啟JavaScript才能訪問本站哦~ - console: '程式:Hexo |主題:Hexo-Theme-Solitude |作者:王卓Sco、亦封 |Github位址: https://github.com/wleelw/Hexo-theme-solitude |版本:v1.4.6 😄' + console: '程式:Hexo |主題:Hexo-Theme-Solitude |作者:王卓Sco、亦封 |Github位址: https://github.com/wleelw/Hexo-theme-solitude |版本:v1.4.7 😄' aside: postcount: '文章數:' diff --git a/layout/includes/widgets/page/says/json.pug b/layout/includes/widgets/page/says/json.pug index c30b3f64..c3f8dbb9 100644 --- a/layout/includes/widgets/page/says/json.pug +++ b/layout/includes/widgets/page/says/json.pug @@ -2,7 +2,6 @@ case theme.says.style when 1 script. !async function () { - document.querySelector('#waterfall').innerHTML = '
  • ' await fetch('!{url_for(theme.says.mode_link)}') .then(res => res.json()) .then(res => { diff --git a/layout/includes/widgets/page/says/memos.pug b/layout/includes/widgets/page/says/memos.pug index 3f8afd6e..e5d831c7 100644 --- a/layout/includes/widgets/page/says/memos.pug +++ b/layout/includes/widgets/page/says/memos.pug @@ -8,9 +8,6 @@ case theme.says.style let playerRegex = /{player,(.*?)}/g; let imageRegex = /!\[\]\((.*?)\)/g; let contentRegex = /#.*?\s([^{\n]*)/g; - - document.querySelector('#waterfall').innerHTML = '' - await fetch("!{url_for(theme.says.mode_link)}") .then(res => res.json()) .then(data => { From 5ded886eb07c23703e5ac6121c29b76e6135ebfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8D=93Sco?= Date: Wed, 7 Feb 2024 22:53:33 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E2=9C=A8feat:=20del=20json=20says?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删除 json 动态即刻 代码优化 --- _config.yml | 428 ++++++++++---------- layout/includes/page/says.pug | 2 - layout/includes/widgets/home/bb/json.pug | 25 -- layout/includes/widgets/home/bb/local.pug | 8 +- layout/includes/widgets/home/bb/memos.pug | 56 +-- layout/includes/widgets/home/bbTimeList.pug | 2 - layout/includes/widgets/page/banner.pug | 21 +- layout/includes/widgets/page/says/json.pug | 81 ---- layout/includes/widgets/page/says/memos.pug | 183 ++++----- scripts/event/init.js | 35 +- scripts/event/welcome.js | 2 +- scripts/generator/gallery.js | 56 +-- source/js/comment/twikoo_commentBarrage.js | 151 +++---- source/js/covercolor/local.js | 21 +- source/js/music.js | 95 ++--- 15 files changed, 522 insertions(+), 644 deletions(-) delete mode 100644 layout/includes/widgets/home/bb/json.pug delete mode 100644 layout/includes/widgets/page/says/json.pug diff --git a/_config.yml b/_config.yml index 4832a515..3c11c6e9 100644 --- a/_config.yml +++ b/_config.yml @@ -1,3 +1,4 @@ +--- #--------------------------- # Hexo Theme Solitude # Author: wleelw(王卓Sco)、yife68(亦封) @@ -45,91 +46,90 @@ nav: # 导航栏显示的内容 # Content displayed in the navigation bar menu: - # # 显示分类名 - # # Display category name - # 项目: - # # 显示子类 - # # Display subcategories - # Solitude: - # # 显示的图标 - # # Displayed icon - # icon: https://bu.dusays.com/2023/11/08/654af68b25bb8.jpg - # # 点击的跳转链接 - # # Click the jump link - # url: https://github.com/wleelw/Hexo-Theme-solitude + # 显示分类名 + # Display category name + 项目: + # # 显示子类 + # # Display subcategories + # Solitude: + # # 显示的图标 + # # Displayed icon + # icon: https://bu.dusays.com/2023/11/08/654af68b25bb8.jpg + # # 点击的跳转链接 + # # Click the jump link + # url: https://github.com/wleelw/Hexo-Theme-solitude # 导航栏内容 # Navigation bar content # tip:此部分内容是顶部导航栏中间菜单区域 # tip: This part of the content is the menu area in the middle of the top navigation bar menu: - # 显示的大分类名称 - # Displayed category name - # 文库: - # # 点击跳转链接 - # # Click the jump link - # # tip:如果没有子类就填跳转链接,例如:/archives,否则填false - # # tip: If there is no subcategory, fill in the jump link, for example: /archives, otherwise fill in false - # url: false - # # 子类数组 - # # Subcategory array - # child: - # # 子类名称 - # # Subcategory name - # 文章列表: - # # 点击跳转链接 - # # Click the jump link - # url: /archives/ - # # 子类名称左侧图标 - # # Subcategory name left icon - # icon: sco-folder-fill - # 全部分类: - # url: /categories/ - # icon: sco-checkbox-multiple-blank-fill - # 全部标签: - # url: /tags/ - # icon: sco-price-tag-fill - # 友链: - # url: false - # child: - # 友情链接: - # url: /links/ - # icon: sco-group-fill - # 宝藏博主: - # url: javascript:travelling() - # icon: sco-gift-fill - # 我的: - # url: false - # child: - # 装备: - # url: /equipment/ - # icon: sco-laptop-line - # 工具箱: - # url: /tlink/ - # icon: sco-tools-fill - # 关于: - # url: false - # child: - # 关于本站: - # url: /about/ - # icon: sco-contacts-fill - + # 显示的大分类名称 + # Displayed category name + # 文库: + # # 点击跳转链接 + # # Click the jump link + # # tip:如果没有子类就填跳转链接,例如:/archives,否则填false + # # tip: If there is no subcategory, fill in the jump link, for example: /archives, otherwise fill in false + # url: false + # # 子类数组 + # # Subcategory array + # child: + # # 子类名称 + # # Subcategory name + # 文章列表: + # # 点击跳转链接 + # # Click the jump link + # url: /archives/ + # # 子类名称左侧图标 + # # Subcategory name left icon + # icon: sco-folder-fill + # 全部分类: + # url: /categories/ + # icon: sco-checkbox-multiple-blank-fill + # 全部标签: + # url: /tags/ + # icon: sco-price-tag-fill + # 友链: + # url: false + # child: + # 友情链接: + # url: /links/ + # icon: sco-group-fill + # 宝藏博主: + # url: javascript:travelling() + # icon: sco-gift-fill + # 我的: + # url: false + # child: + # 装备: + # url: /equipment/ + # icon: sco-laptop-line + # 工具箱: + # url: /tlink/ + # icon: sco-tools-fill + # 关于: + # url: false + # child: + # 关于本站: + # url: /about/ + # icon: sco-contacts-fill # 导航栏右侧按钮 # Button on the right side of the navigation bar # tip:只需填写true和false即可 # tip: Just fill in true and false right: - random: false # 随机文章跳转 true:开启 / false:关闭 : random post jump true: on / false: off - console: false #控制台 true:开启 / false:关闭 : console true: on / false: off + random: false # 随机文章跳转 true:开启 / false:关闭 : random post jump true: on / false: off + console: false #控制台 true:开启 / false:关闭 : console true: on / false: off # 从左至右 # From left to right custom: -# - name: 开往 - 友链接力 # 显示文字 / Displayed text -# url: https://www.travellings.cn/go.html # 跳转链接 / Jump link -# icon: sco-train-line # 图标 / Icon -# onclick: # 点击事件 / Click event -# id: travellings_button # id + # - name: 开往 - 友链接力 # 显示文字 / Displayed text + # url: https://www.travellings.cn/go.html # 跳转链接 / Jump link + # icon: sco-train-line # 图标 / Icon + # onclick: # 点击事件 / Click event + # id: travellings_button # id # 首页顶部样式 # Home top style @@ -151,33 +151,33 @@ hometop: # 轮播icon # Carousel icon icon: - # 名字 / Name - # HTML: - # # 图片 / Image - # img: https://npm.elemecdn.com/wleelw-blog-abs@1.0.0/img/icon/HTML.png - # # 背景色 / Background color - # color: '#e9572b' - # JS: - # img: https://npm.elemecdn.com/wleelw-blog-abs@1.0.0/img/icon/JS.png - # color: '#f7cb4f' - # Kotlin: - # img: https://npm.elemecdn.com/wleelw-blog-abs@1.0.0/img/icon/kotlin-logo.svg - # color: '#ffffff' - # Docker: - # img: https://npm.elemecdn.com/wleelw-blog-abs@1.0.0/img/icon/docker.png - # color: '#57b6e6' - # Flutter: - # img: https://npm.elemecdn.com/wleelw-blog-abs@1.0.0/img/icon/flutter.png - # color: '#ffffff' - # WebPack: - # img: https://npm.elemecdn.com/wleelw-blog-abs@1.0.0/img/icon/webpack.png - # color: '#2e3a41' - # Git: - # img: https://npm.elemecdn.com/wleelw-blog-abs@1.0.0/img/icon/git.png - # color: '#df5b40' - # VS: - # img: https://npm.elemecdn.com/wleelw-blog-abs@1.0.0/img/icon/vs-logo.svg - # color: '#ffffff' + # # 名字 / Name + # HTML: + # # 图片 / Image + # img: https://npm.elemecdn.com/wleelw-blog-abs@1.0.0/img/icon/HTML.png + # # 背景色 / Background color + # color: "#e9572b" + # JS: + # img: https://npm.elemecdn.com/wleelw-blog-abs@1.0.0/img/icon/JS.png + # color: "#f7cb4f" + # Kotlin: + # img: https://npm.elemecdn.com/wleelw-blog-abs@1.0.0/img/icon/kotlin-logo.svg + # color: "#ffffff" + # Docker: + # img: https://npm.elemecdn.com/wleelw-blog-abs@1.0.0/img/icon/docker.png + # color: "#57b6e6" + # Flutter: + # img: https://npm.elemecdn.com/wleelw-blog-abs@1.0.0/img/icon/flutter.png + # color: "#ffffff" + # WebPack: + # img: https://npm.elemecdn.com/wleelw-blog-abs@1.0.0/img/icon/webpack.png + # color: "#2e3a41" + # Git: + # img: https://npm.elemecdn.com/wleelw-blog-abs@1.0.0/img/icon/git.png + # color: "#df5b40" + # VS: + # img: https://npm.elemecdn.com/wleelw-blog-abs@1.0.0/img/icon/vs-logo.svg + # color: "#ffffff" # 顶部三大分类 # Top three categories @@ -224,7 +224,7 @@ hometop: img: /img/default.png # 阴影颜色 # Shadow color - color: '#ff0000' + color: "#ff0000" # -------------------------------------- # Aside Settings @@ -304,15 +304,15 @@ aside: - 💢 壮汉人狠话不多 - 🎮 电竞游戏爱好者 information: - # # 悬停显示文字 - # Github: - # # 图标 - # icon: scoicon sco-github-line - # # 跳转链接 - # url: https://github.com/wleelw/Hexo-Theme-slitude - # Bilibili: - # icon: scoicon sco-bilibili-line - # url: https://space.bilibili.com/1329819902 + # # 悬停显示文字 + # Github: + # # 图标 + # icon: scoicon sco-github-line + # # 跳转链接 + # url: https://github.com/wleelw/Hexo-Theme-slitude + # Bilibili: + # icon: scoicon sco-bilibili-line + # url: https://space.bilibili.com/1329819902 # 二维码 # Official account QR code @@ -358,14 +358,14 @@ aside: # 高亮显示标签列表 # Highlighted tag list list: - - 'Solitude-使用' + - "Solitude-使用" # 侧边栏归档 # aside archive archive: enable: false # 显示类型 - type: 'month' # monthly: 按月 / yearly: 按年 : monthly: by month / yearly: by year + type: "month" # monthly: 按月 / yearly: 按年 : monthly: by month / yearly: by year # 建站信息 # Website information @@ -390,7 +390,7 @@ aside: runtimeenable: true # 格式:yyyy-MM-dd hh-mm-ss # Format: yyyy-MM-dd hh-mm-ss - runtime: '2023-04-20 00:00:00' + runtime: "2023-04-20 00:00:00" # ------------------------- # 文章页、页面配置 @@ -399,7 +399,7 @@ aside: # 页面默认设置 # page default settings page: - error: true # 404页面 / 404 page + error: true # 404页面 / 404 page tags: true # 标签页 / Tags page categories: true # 分类页 / Categories page default: # 默认值 / Default value @@ -476,13 +476,13 @@ post: # -------------------------------------- theme_color: dark: "#ffc848" # 暗色模式 / Dark mode - dark_op: '#f2b94b23' # 暗色模式透明 / Dark mode transparent - dark_op_deep: '#f2b94bdd' # 暗色模式透明深色 / Dark mode transparent dark - dark_none: '#f2b94b00' # 暗色模式透明无色 / Dark mode transparent colorless + dark_op: "#f2b94b23" # 暗色模式透明 / Dark mode transparent + dark_op_deep: "#f2b94bdd" # 暗色模式透明深色 / Dark mode transparent dark + dark_none: "#f2b94b00" # 暗色模式透明无色 / Dark mode transparent colorless light: "#425AEF" # 亮色模式 / Light mode - light_op: '#4259ef23' # 亮色模式透明 / Light mode transparent - light_op_deep: '#4259efdd' # 亮色模式透明深色 / Light mode transparent dark - light_none: '#4259ef01' # 亮色模式透明无色 / Light mode transparent colorless + light_op: "#4259ef23" # 亮色模式透明 / Light mode transparent + light_op_deep: "#4259efdd" # 亮色模式透明深色 / Light mode transparent dark + light_none: "#4259ef01" # 亮色模式透明无色 / Light mode transparent colorless # 主题显示模式调整 # theme display mode adjustment @@ -515,38 +515,40 @@ footer: # 底部上方一排图标 # Bottom row of icons information: - left: # 左侧显示图标 / Left display icon - # Github: - # icon: scoicon sco-bilibili-line - # url: https://github.com/wleelw - # Mail: - # icon: scoicon sco-mail-line - # url: mailto:wleelw@wzsco.top - right: # 右侧显示图标 / Right display icon - # Bilibili: - # icon: scoicon sco-bilibili-line - # url: https://space.bilibili.com/1329819902 - # 抖音: - # icon: scoicon sco-douyin-fill - # url: https://v.douyin.com/iJsLc8jt/ + # 左侧显示图标 / Left display icon + left: + # Github: + # icon: scoicon sco-bilibili-line + # url: https://github.com/wleelw + # Mail: + # icon: scoicon sco-mail-line + # url: mailto:wleelw@wzsco.top + # 右侧显示图标 / Right display icon + right: + # Bilibili: + # icon: scoicon sco-bilibili-line + # url: https://space.bilibili.com/1329819902 + # 抖音: + # icon: scoicon sco-douyin-fill + # url: https://v.douyin.com/iJsLc8jt/ # 底部导航栏 # Bottom navigation bar - group: # 从左至右 / From left to right - # 导航: - # 归档: /archives/ - # 分类: /categories/ - # 标签: /tags/ - # 服务: - # 阿里云: https://aliyun.com/ - # 51la统计: https://v6.51.la/ - # 百度统计: https://tongji.baidu.com/ - # 支持: - # 打赏记录: /about/ - # 协议: - # Cookies: /cookies/ - # 用户协议: /privacy/ - # 版权协议: /copyright/ + group: + # 导航: + # 归档: /archives/ + # 分类: /categories/ + # 标签: /tags/ + # 服务: + # 阿里云: https://aliyun.com/ + # 51la统计: https://v6.51.la/ + # 百度统计: https://tongji.baidu.com/ + # 支持: + # 打赏记录: /about/ + # 协议: + # Cookies: /cookies/ + # 用户协议: /privacy/ + # 版权协议: /copyright/ # 底部随机友链 # Random links at the bottom @@ -605,11 +607,11 @@ says: # 即刻短文仅展示前n条 # Jike short text only shows the first n strip: 30 - # 模式选择。local:本地静态 / json:动态json / memos:动态Memos - # Mode selection. Local: local static/JSON: dynamic JSON/memory: dynamic Memos + # 模式选择。local:本地静态 / memos:动态Memos + # Mode selection. Local: local static/memos: dynamic Memos mode: local - # 动态模式地址。如为json或memos模式,此项为必填。链接获取以及格式可查看主题文档。 - # Dynamic mode address. If it is in JSON or Memos mode, this field is mandatory. The link acquisition and format can be viewed in the theme document. + # 动态模式地址。memos模式,此项为必填。链接获取以及格式可查看主题文档。 + # Dynamic mode address. For memos mode, this item is required. Link acquisition and format can be viewed in the theme documentation. mode_link: # https://example.com/api/v1/memo?creatorId=1&tag=says # ------------------------- @@ -672,28 +674,28 @@ keyboard: # 键盘控制配置 # Keyboard control configuration list: - # name: 按键名称 - # name: Key name - # key: 按键 - # key: Key - # func: 方法 - # func: Function - # sco: sco内置方法 - # sco: sco built-in method - # url: 跳转链接 - # url: Jump link -# - name: 关闭快捷键功能 -# key: K -# func: keyboard -# - name: 打开中控台 -# key: A -# sco: showConsole -# - name: 播放/暂停音乐 -# key: M -# sco: musicToggle -# - name: 打开友情链接 -# key: L -# url: '/links/' + # name: 按键名称 + # name: Key name + # key: 按键 + # key: Key + # func: 方法 + # func: Function + # sco: sco内置方法 + # sco: sco built-in method + # url: 跳转链接 + # url: Jump link + # - name: 关闭快捷键功能 + # key: K + # func: keyboard + # - name: 打开中控台 + # key: A + # sco: showConsole + # - name: 播放/暂停音乐 + # key: M + # sco: musicToggle + # - name: 打开友情链接 + # key: L + # url: "/links/" # 懒加载 # lazyload @@ -760,13 +762,13 @@ translate: opengraph: enable: false options: -# twitter_card: -# twitter_image: -# twitter_id: -# twitter_site: -# google_plus: -# fb_admins: -# fb_app_id: + # twitter_card: + # twitter_image: + # twitter_id: + # twitter_site: + # google_plus: + # fb_admins: + # fb_app_id: # 字数统计 # word count @@ -843,24 +845,24 @@ comment: newComment: false # 最新评论开关 / Latest comment switch # 匿名评论前部分随机信息 / Anonymous comment front random information randomInfoStart: - - '聪敏的' - - '可爱的' - - '美丽的' + - "聪敏的" + - "可爱的" + - "美丽的" # 匿名评论后部分随机信息 / Anonymous comment after random information randomInfoEnd: - - '白菜' - - '小可爱' - - '小仙女' + - "白菜" + - "小可爱" + - "小仙女" # twikoo 配置信息 # twikoo settings twikoo: # https://twikoo.js.org/ envId: # url: https://twikoo.sondy.top/ - lang: 'zh-CN' # 语言 - accessToken: # accessToken + lang: "zh-CN" # 语言 + accessToken: # accessToken # waline 配置信息 # waline settings waline: # https://waline.js.org/ - envId: # url: https://waline.wzsco.top + envId: # url: https://waline.wzsco.top pageview: true # 是否开启页面访问量统计 / Whether to enable page access statistics option: # waline配置项 / waline configuration item @@ -896,7 +898,7 @@ extends: pwa: enable: false manifest: /manifest.json # manifest.json 文件路径 - theme_color: '#ffffff' # 主题颜色 + theme_color: "#ffffff" # 主题颜色 mask_icon: https://cdn.cbd.int/solitude-source/img/pwa/180.png # 遮罩图标 apple_touch_icon: https://cdn.cbd.int/solitude-source/img/pwa/180.png # 苹果触摸图标 bookmark_icon: https://cdn.cbd.int/solitude-source/img/pwa/180.png # 书签图标 @@ -923,27 +925,27 @@ CDN: custom_format: https://cdn.staticfile.org/${cdnjs_name}/${version}/${min_cdnjs_file} option: - scoicon_css: https://cdn.cbd.int/solitude-source/icon/scoicon.min.css - waterfall: https://cdn.cbd.int/solitude-source/js/waterfall.min.js - universe_js: https://cdn.cbd.int/solitude-source/js/universe.min.js -# algolia_search: -# instantsearch: -# pjax: -# twikoo: -# waline_js: -# waline_css: -# sharejs: -# sharejs_css: -# katex: -# katex_copytex: -# lazyload: -# aplayer_css: -# aplayer_js: -# meting_js: -# pace_js: -# lunr_js: -# swiper_css: -# swiper_js: -# busuanzi_js: -# snackbar_css: -# snackbar_js: \ No newline at end of file + scoicon_css: https://cdn.cbd.int/solitude-source/icon/scoicon.min.css + waterfall: https://cdn.cbd.int/solitude-source/js/waterfall.min.js + universe_js: https://cdn.cbd.int/solitude-source/js/universe.min.js + # algolia_search: + # instantsearch: + # pjax: + # twikoo: + # waline_js: + # waline_css: + # sharejs: + # sharejs_css: + # katex: + # katex_copytex: + # lazyload: + # aplayer_css: + # aplayer_js: + # meting_js: + # pace_js: + # lunr_js: + # swiper_css: + # swiper_js: + # busuanzi_js: + # snackbar_css: + # snackbar_js: diff --git a/layout/includes/page/says.pug b/layout/includes/page/says.pug index de004a95..064c565c 100644 --- a/layout/includes/page/says.pug +++ b/layout/includes/page/says.pug @@ -6,8 +6,6 @@ if theme.says.enable case theme.says.mode when 'local' include ../widgets/page/says/local - when 'json' - include ../widgets/page/says/json when 'memos' include ../widgets/page/says/memos #bber-tips diff --git a/layout/includes/widgets/home/bb/json.pug b/layout/includes/widgets/home/bb/json.pug deleted file mode 100644 index 3e6392b2..00000000 --- a/layout/includes/widgets/home/bb/json.pug +++ /dev/null @@ -1,25 +0,0 @@ -script. - async function getSays () { - document.addEventListener('DOMContentLoaded', this) - document.addEventListener('pjax:complete', this) - const htmlTagRegex = /<[^>]+>/g; - document.querySelector('#bber-talk').innerHTML = '
    '; - await fetch('!{theme.says.mode_link}') - .then(res => res.json()) - .then(res => { - let list = res.filter(item => item.content).slice(0, 10); - - document.querySelector('#bber-talk').innerHTML = list.map(item => { - let content = item.content ? item.content.replace(htmlTagRegex, '') : ''; - content += item.image ? '' : ''; - content += item.aplayer ? '' : ''; - content += item.video ? '' : ''; - content += item.bilibili ? '' : ''; - content += item.link ? `` : ''; - return `
    ${content}
    `; - }).join(''); - sco.initbbtalk(); - }).catch(err => console.log('bbtime |', err)); - } - document.addEventListener('DOMContentLoaded', getSays) - document.addEventListener('pjax:complete', getSays) \ No newline at end of file diff --git a/layout/includes/widgets/home/bb/local.pug b/layout/includes/widgets/home/bb/local.pug index 80dcec4d..278f8763 100644 --- a/layout/includes/widgets/home/bb/local.pug +++ b/layout/includes/widgets/home/bb/local.pug @@ -3,13 +3,13 @@ each item, i in site.data.essay.essay_list.slice(0, 10) | #{item.content} if item.image i.scoicon.sco-image-fill - if item.aplayer + else if item.aplayer i.scoicon.sco-disc-fill - if item.video + else if item.video i.scoicon.sco-video-fill - if item.bilibili + else if item.bilibili i.scoicon.sco-bilibili-line - if item.link + else if item.link i.scoicon.sco-links script. document.addEventListener('DOMContentLoaded',()=>{ diff --git a/layout/includes/widgets/home/bb/memos.pug b/layout/includes/widgets/home/bb/memos.pug index d28a6237..4d1770e6 100644 --- a/layout/includes/widgets/home/bb/memos.pug +++ b/layout/includes/widgets/home/bb/memos.pug @@ -1,28 +1,36 @@ script. async function getSays() { - document.querySelector('#bber-talk').innerHTML = '
    ' - await fetch('!{theme.says.mode_link}') - .then(response => response.json()) - .then(data => { - let aplayerRegex = /{aplayer,(.*?),(.*?)}/g; - let bilibiliRegex = /{bilibili,(.*?)}/g; - let playerRegex = /{player,(.*?)}/g; - let linkRegex = /(? { - let content = item.content.match(contentRegex, '$1').map(item => item.replace(contentRegex, '$1')); - let imageBox = item.content.match(imageRegex) ? '' : ''; - let aplayer = item.content.match(aplayerRegex) ? '' : ''; - let video = item.content.match(playerRegex) ? '' : item.content.match(bilibiliRegex) ? '' : ''; - let link = item.content.match(linkRegex) ? `` : ''; + const bberTalk = document.querySelector('#bber-talk'); + if (!bberTalk) return; + else bberTalk.innerHTML = '
    '; - return `
    ${content + aplayer + video + imageBox + link}
    ` - }).join(' ') - sco.initbbtalk(); - }) - .catch(error => console.error('bbtime | ', error)); + try { + const response = await fetch('!{theme.says.mode_link}'); + const data = await response.json(); + + const aplayerRegex = /{aplayer,(.*?),(.*?)}/g; + const bilibiliRegex = /{bilibili,(.*?)}/g; + const playerRegex = /{player,(.*?)}/g; + const linkRegex = /(? { + const content = item.content.match(contentRegex, '$1').map(item => item.replace(contentRegex, '$1')); + const imageBox = item.content.match(imageRegex) ? '' : ''; + const aplayer = item.content.match(aplayerRegex) ? '' : ''; + const video = item.content.match(playerRegex) ? '' : item.content.match(bilibiliRegex) ? '' : ''; + const link = item.content.match(linkRegex) ? `` : ''; + + return `
    ${content + aplayer + video + imageBox + link}
    `; + }).join(' '); + + sco.initbbtalk(); + } catch (error) { + console.error('bbtime | ', error); + } } - document.addEventListener('DOMContentLoaded', getSays) - document.addEventListener('pjax:complete', getSays) \ No newline at end of file + + document.addEventListener('DOMContentLoaded', getSays); + document.addEventListener('pjax:complete', getSays); diff --git a/layout/includes/widgets/home/bbTimeList.pug b/layout/includes/widgets/home/bbTimeList.pug index 0779a5ea..42b6a325 100644 --- a/layout/includes/widgets/home/bbTimeList.pug +++ b/layout/includes/widgets/home/bbTimeList.pug @@ -5,8 +5,6 @@ case theme.says.mode when 'local' include bb/local - when 'json' - include bb/json when 'memos' include bb/memos i.bber-gotobb.scoicon.sco-right-btn-fill(title=_p('home.bbtime.text') onclick=`pjax.loadUrl('/essay/')`) \ No newline at end of file diff --git a/layout/includes/widgets/page/banner.pug b/layout/includes/widgets/page/banner.pug index 6ab0f445..7f7e5075 100644 --- a/layout/includes/widgets/page/banner.pug +++ b/layout/includes/widgets/page/banner.pug @@ -3,18 +3,13 @@ .author-content-item-tips= page.title span.author-content-item-title= page.desc .content-bottom - if (page.leftend) - .tips!= page.leftend - if(page.rightend) - .tips!= page.rightend + if page.leftend + .tips= page.leftend + if page.rightend + .tips= page.rightend if page.rightbtn .banner-button-group - case page.rightbtnlink.startsWith('/') - when true - a.banner-button(onclick="pjax.loadUrl(\"" + page.rightbtnlink + "\")") - i.scoicon.sco-right-btn-fill - span.banner-button-text= page.rightbtn - when false - a.banner-button(href=page.rightbtnlink, target="_blank") - i.scoicon.sco-right-btn-fill - span.banner-button-text= page.rightbtn \ No newline at end of file + - const isInternalLink = page.rightbtnlink.startsWith('/') + a.banner-button(onclick=isInternalLink ? `pjax.loadUrl("${page.rightbtnlink}")` : null, href=isInternalLink ? null : page.rightbtnlink, target=isInternalLink ? null : "_blank") + i.scoicon.sco-right-btn-fill + span.banner-button-text= page.rightbtn diff --git a/layout/includes/widgets/page/says/json.pug b/layout/includes/widgets/page/says/json.pug deleted file mode 100644 index c3f8dbb9..00000000 --- a/layout/includes/widgets/page/says/json.pug +++ /dev/null @@ -1,81 +0,0 @@ -case theme.says.style - when 1 - script. - !async function () { - await fetch('!{url_for(theme.says.mode_link)}') - .then(res => res.json()) - .then(res => { - let list = res.slice(0, !{theme.says.strip}) - let aplayer = null - let video = null - let imageBox = null - - document.querySelector('#waterfall').innerHTML = list.map(item => { - aplayer = item.aplayer ? `
    ` : null - video = item.player ? `
    ` : item.bilibili ? `
    ` : null - imageBox = item.images ? `
    ${item.images.map(img => ``).join('')}
    ` : null - return `
  • -
    -

    ${item.content || ''}

    - ${imageBox || ''} -
    - ${video || ''} - ${aplayer || ''} -
    -
    -
    -
    - - -
    - ${item.link ? `链接` : ''} -
    - ${item.content ? `` : ''} -
    -
  • ` - }).join('') - sco.reflashEssayWaterFall(); - GLOBAL_CONFIG.lazyload.enable && utils.lazyloadImg(); - GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll(".bber-content-img img")); - changeTimeFormat(); - }) - }() - when 2 - script. - !async function () { - document.querySelector('#waterfall').innerHTML = '
  • ' - await fetch('!{url_for(theme.says.mode_link)}') - .then(res => res.json()) - .then(res => { - let list = res.slice(0, !{theme.says.strip}) - let aplayer = null - let video = null - let imageBox = null - - document.querySelector('#waterfall').innerHTML = list.map(item => { - aplayer = item.aplayer ? `
    ` : null - video = item.player ? `
    ` : item.bilibili ? `
    ` : null - imageBox = item.images ? `
    ${item.images.map(img => ``).join('')}
    ` : null - return `
  • -
    - -
    - #{config.author} - -
    - ${item.content ? `` : ''} -
    -
    -

    ${item.content || ''}

    - ${imageBox || ''} -
    - ${video || ''} - ${aplayer || ''} -
  • ` - }).join('') - sco.reflashEssayWaterFall(); - GLOBAL_CONFIG.lazyload.enable && utils.lazyloadImg(); - GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll(".bber-content-img img")); - changeTimeFormat(); - }) - }() \ No newline at end of file diff --git a/layout/includes/widgets/page/says/memos.pug b/layout/includes/widgets/page/says/memos.pug index e5d831c7..45b8df14 100644 --- a/layout/includes/widgets/page/says/memos.pug +++ b/layout/includes/widgets/page/says/memos.pug @@ -2,107 +2,98 @@ case theme.says.style when 1 script. !async function () { - let aplayerRegex = /{aplayer,(.*?),(.*?)}/g; - let linkRegex = /(? res.json()) - .then(data => { - let list = data.slice(0, !{theme.says.strip}); - let aplayer = null; - let video = null; - let imageBox = null; + const aplayerRegex = /{aplayer,(.*?),(.*?)}/g; + const linkRegex = /(? { - aplayer = item.content.match(aplayerRegex); - aplayer = aplayer ? `
    ` : null; - video = item.content.match(playerRegex); - video = video ? `
    ` : item.content.match(bilibiliRegex); - video = item.content.match(bilibiliRegex) ? `
    ` : video; - imageBox = item.content.match(imageRegex); - imageBox = imageBox ? `
    ${imageBox.map(img => ``).join('')}
    ` : ''; - let time = new Date(item.createdTs * 1000).toISOString().replace('Z', '+08:00'); - let content = item.content.match(contentRegex).map(item => item.replace(contentRegex, '$1')); - let link = item.content.match(linkRegex); - link = link ? `链接` : ''; - return `
  • -
    -

    ${content}

    - ${imageBox || ''} + document.querySelector('#waterfall').innerHTML = list.map(item => { + aplayer = item.content.match(aplayerRegex); + aplayer = aplayer ? `
    ` : null; + video = item.content.match(playerRegex); + video = video ? `
    ` : item.content.match(bilibiliRegex); + video = item.content.match(bilibiliRegex) ? `
    ` : video; + imageBox = item.content.match(imageRegex); + imageBox = imageBox ? `
    ${imageBox.map(img => ``).join('')}
    ` : ''; + const time = new Date(item.createdTs * 1000).toISOString().replace('Z', '+08:00'); + const content = item.content.match(contentRegex).map(item => item.replace(contentRegex, '$1')); + const link = item.content.match(linkRegex); + const linkHtml = link ? `链接` : ''; + const replyHtml = content ? `` : ''; + return `
  • +
    +

    ${content}

    + ${imageBox || ''} +
    + ${video || ''} + ${aplayer || ''} +
    +
    +
    +
    + +
    - ${video || ''} - ${aplayer || ''} -
    -
    -
    -
    - - -
    - ${link} -
    - ${content ? `` : ''} -
    -
  • `; - }).join(''); - sco.reflashEssayWaterFall(); - GLOBAL_CONFIG.lazyload.enable && utils.lazyloadImg(); - GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll(".bber-content-img img")); - changeTimeFormat(); - }).catch(error => console.log(error)); + ${linkHtml} + + ${replyHtml} + + `; + }).join(''); + sco.reflashEssayWaterFall(); + GLOBAL_CONFIG.lazyload.enable && utils.lazyloadImg(); + GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll(".bber-content-img img")); + changeTimeFormat(); }(); when 2 script. !async function () { - let aplayerRegex = /{aplayer,(.*?),(.*?)}/g; - let bilibiliRegex = /{bilibili,(.*?)}/g; - let playerRegex = /{player,(.*?)}/g; - let imageRegex = /!\[\]\((.*?)\)/g; - let contentRegex = /#.*?\s([^{\n]*)/g - - document.querySelector('#waterfall').innerHTML = '' - - await fetch("!{url_for(theme.says.mode_link)}") - .then(res => res.json()) - .then(data => { - let list = data.slice(0, !{theme.says.strip}) - let aplayer = null; - let video = null; - let imageBox = null; + const aplayerRegex = /{aplayer,(.*?),(.*?)}/g; + const bilibiliRegex = /{bilibili,(.*?)}/g; + const playerRegex = /{player,(.*?)}/g; + const imageRegex = /!\[\]\((.*?)\)/g; + const contentRegex = /#.*?\s([^{\n]*)/g; + const response = await fetch("!{url_for(theme.says.mode_link)}"); + const data = await response.json(); + const list = data.slice(0, !{theme.says.strip}); + let aplayer, video, imageBox; - document.querySelector('#waterfall').innerHTML = list.map(item => { - aplayer = item.content.match(aplayerRegex); - aplayer = aplayer ? `
    ` : null; - video = item.content.match(playerRegex); - video = video ? `
    ` : item.content.match(bilibiliRegex); - video = item.content.match(bilibiliRegex) ? `
    ` : video; - imageBox = item.content.match(imageRegex); - imageBox = imageBox ? `
    ${imageBox.map(img => ``).join('')}
    ` : ''; - let time = new Date(item.createdTs * 1000).toISOString().replace('Z', '+08:00'); - let content = item.content.match(contentRegex).map(item => item.replace(contentRegex, '$1')); - return `
  • -
    - -
    - #{config.author} - -
    - ${content ? `` : ''} -
    -
    -

    ${content}

    - ${imageBox || ''} -
    - ${video || ''} - ${aplayer || ''} -
  • `; - }).join(''); - sco.reflashEssayWaterFall(); - GLOBAL_CONFIG.lazyload.enable && utils.lazyloadImg(); - GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll(".bber-content-img img")); - changeTimeFormat(); - }).catch(error => console.log(error)); + document.querySelector('#waterfall').innerHTML = list.map(item => { + aplayer = item.content.match(aplayerRegex); + aplayer = aplayer ? `
    ` : null; + video = item.content.match(playerRegex); + video = video ? `
    ` : item.content.match(bilibiliRegex); + video = item.content.match(bilibiliRegex) ? `
    ` : video; + imageBox = item.content.match(imageRegex); + imageBox = imageBox ? `
    ${imageBox.map(img => ``).join('')}
    ` : ''; + const time = new Date(item.createdTs * 1000).toISOString().replace('Z', '+08:00'); + const content = item.content.match(contentRegex).map(item => item.replace(contentRegex, '$1')); + const replyHtml = content ? `` : ''; + return `
  • +
    + +
    + #{config.author} + +
    + ${replyHtml} +
    +
    +

    ${content}

    + ${imageBox || ''} +
    + ${video || ''} + ${aplayer || ''} +
  • `; + }).join(''); + sco.reflashEssayWaterFall(); + GLOBAL_CONFIG.lazyload.enable && utils.lazyloadImg(); + GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll(".bber-content-img img")); + changeTimeFormat(); }(); diff --git a/scripts/event/init.js b/scripts/event/init.js index 4894ad98..53b7f201 100644 --- a/scripts/event/init.js +++ b/scripts/event/init.js @@ -1,21 +1,22 @@ hexo.extend.filter.register('before_generate', () => { - const hexoVer = hexo.version.replace(/(^.*\..*)\..*/, '$1') - const nodeVer = process.version.replace(/^v/, ''); - const [majorVer] = nodeVer.split('.'); - const logger = hexo.log, config = hexo.config + const hexoVer = hexo.version.replace(/(^.*\..*)\..*/, '$1'); + const nodeVer = process.version.replace(/^v/, ''); + const [majorVer] = nodeVer.split('.'); + const logger = hexo.log; + const config = hexo.config; - if (hexoVer < 6.3) { - logger.error('请把 Hexo 升级到 V6.3.0 或更高的版本!') - process.exit(-1) - } + if (hexoVer < 6.3) { + logger.error('请把 Hexo 升级到 V6.3.0 或更高的版本!'); + process.exit(-1); + } + + if (config.prismjs.enable) { + logger.error('主题尚未支持 prismjs 请使用 highlightjs !'); + process.exit(-1); + } - if (config.prismjs.enable) { - logger.error('主题尚未支持 prismjs 请使用 highlightjs !') - process.exit(-1) - } - if (Number(majorVer) < 14) { - logger.error('请将 Node.js 升级到 v14.0.0 或更高的版本!'); - process.exit(-1); - } + if (Number(majorVer) < 14) { + logger.error('请将 Node.js 升级到 v14.0.0 或更高的版本!'); + process.exit(-1); } -) \ No newline at end of file +}); diff --git a/scripts/event/welcome.js b/scripts/event/welcome.js index 8c113d3f..1f03b66b 100644 --- a/scripts/event/welcome.js +++ b/scripts/event/welcome.js @@ -9,6 +9,6 @@ hexo.on('ready', () => { ###### #### ##### ##### # ### ###### ###### ${version} =================================================================== - 主题链接:https://github.com/wleelw/Hexo-theme-solitude + GitHub: https://github.com/wleelw/hexo-theme-solitude `) }) \ No newline at end of file diff --git a/scripts/generator/gallery.js b/scripts/generator/gallery.js index ac141a80..f6fc5568 100644 --- a/scripts/generator/gallery.js +++ b/scripts/generator/gallery.js @@ -6,20 +6,23 @@ hexo.extend.generator.register('gallery', function (locals) { if (!hexo.theme.config.album.enable) return; const album = locals.data.gallery.gallery; if (!album) return; + const { url, cover, comment, title, album_list, descr, rightbtn, rightbtnlink } = album; return { - path: album.url + '/index.html', layout: ['page'], data: { - url: album.url, - cover: album.cover, + path: `${url}/index.html`, + layout: ['page'], + data: { + url, + cover, type: 'gallery', - comment: album.comment, - desc: album.title, - title: album.title, - album: album.album_list, - leftend: album.descr, - rightbtn: album.rightbtn, - rightbtnlink: album.rightbtnlink + comment, + desc: title, + title, + album: album_list, + leftend: descr, + rightbtn, + rightbtnlink } - } + }; }); hexo.extend.generator.register('album', function (locals) { @@ -27,21 +30,20 @@ hexo.extend.generator.register('album', function (locals) { const album = locals.data.gallery.gallery; let back = hexo.config.language === 'zh-CN' ? '返回相册' : hexo.config.language === 'zh-TW' ? '返回相冊' : 'Back to Album'; if (!album) return; - const albumPages = []; - album.album_list.forEach(function (item) { - albumPages.push({ - path: album.url + '/' + item.album + '/index.html', layout: ['page'], data: { - album: item, - type: 'album', - cover: item.cover, - title: item.class_name, - desc: item.class_name, - leftend: item.descr, - rightbtn: back, - rightbtnlink: `/${album.url}/`, - comment: item.comment - } - }); - }); + const albumPages = album.album_list.map(item => ({ + path: `${album.url}/${item.album}/index.html`, + layout: ['page'], + data: { + album: item, + type: 'album', + cover: item.cover, + title: item.class_name, + desc: item.class_name, + leftend: item.descr, + rightbtn: back, + rightbtnlink: `/${album.url}/`, + comment: item.comment + } + })); return albumPages; }); \ No newline at end of file diff --git a/source/js/comment/twikoo_commentBarrage.js b/source/js/comment/twikoo_commentBarrage.js index 9ab106d1..19ff1e09 100644 --- a/source/js/comment/twikoo_commentBarrage.js +++ b/source/js/comment/twikoo_commentBarrage.js @@ -1,117 +1,116 @@ function initializeCommentBarrage() { window.commentBarrageInitialized = !0; - let e = { + const e = { maxBarrage: 1, barrageTime: 8e3, twikooUrl: GLOBAL_CONFIG.comment.twikoo.url, pageUrl: window.location.pathname, accessToken: GLOBAL_CONFIG.comment.twikoo.accessToken, }; - new class { - commentInterval = null - constructor(e) { + class CommentBarrage { + constructor(config) { this.config = { - ...e, + ...config, barrageTimer: [], barrageList: [], barrageIndex: 0, dom: document.querySelector(".comment-barrage") - }, - this.commentInterval = null, - this.hoverOnCommentBarrage = !1, - this.init() + }; + this.commentInterval = null; + this.hoverOnCommentBarrage = false; + this.init(); } async fetchComments() { - return fetch(this.config.twikooUrl, { - method: "POST", - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify({ - event: "COMMENT_GET", - accessToken: this.config.accessToken, - url: this.config.pageUrl - }) - }).then((e => { - if (!e.ok) - throw Error("HTTP error! status: " + e.status); - return e.json() + try { + const response = await fetch(this.config.twikooUrl, { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + event: "COMMENT_GET", + accessToken: this.config.accessToken, + url: this.config.pageUrl + }) + }); + if (!response.ok) { + throw new Error("HTTP error! status: " + response.status); } - )).then((e => e.data)).catch((e => console.error("An error occurred while fetching comments: ", e))) + const data = await response.json(); + return data.data; + } catch (error) { + console.error("An error occurred while fetching comments: ", error); + } } - commentLinkFilter(e) { - e.sort(((e, t) => e.created - t.created)); - let t = []; - return e.forEach((e => { - t.push(...this.getCommentReplies(e)) - } - )), - t + commentLinkFilter(comments) { + comments.sort((a, b) => a.created - b.created); + let filteredComments = []; + comments.forEach(comment => { + filteredComments.push(...this.getCommentReplies(comment)); + }); + return filteredComments; } - getCommentReplies(e) { - if (e.replies) { - let comments = [e]; - e.replies.forEach((reply) => { + getCommentReplies(comment) { + let comments = [comment]; + if (comment.replies) { + comment.replies.forEach(reply => { comments.push(...this.getCommentReplies(reply)); }); - return comments; } - return []; + return comments; } - - processCommentContent(e) { - const t = e.replace(/]*>[\s\S]*?<\/blockquote>/gi, "") - , r = t.replace(/<[^>]*>/g, "").replace(/\n/g, " "); - return "" === t.trim() ? "" : `

    ${r}

    ` + processCommentContent(comment) { + const strippedContent = comment.replace(/]*>[\s\S]*?<\/blockquote>/gi, ""); + const plainText = strippedContent.replace(/<[^>]*>/g, "").replace(/\n/g, " "); + return plainText.trim() !== "" ? `

    ${plainText}

    ` : ""; } - popCommentBarrage(e) { - var commentContent = this.processCommentContent(e.comment); - + popCommentBarrage(comment) { + const commentContent = this.processCommentContent(comment.comment); if (!commentContent.trim()) { return false; } - - let commentBarrageItem = document.createElement("div"); + const commentBarrageItem = document.createElement("div"); commentBarrageItem.className = "comment-barrage-item"; - commentBarrageItem.innerHTML = ` -
    - 热评 -
    ${e.nick}
    - - -
    - ${commentContent} - `; - +
    + 热评 +
    ${comment.nick}
    + + +
    + ${commentContent} + `; this.config.barrageTimer.push(commentBarrageItem); - this.config.dom.appendChild(commentBarrageItem); return true; } - removeCommentBarrage(e) { - e.className = "comment-barrage-item out", - setTimeout((() => { - this.config.dom.removeChild(e) - } - ), 1e3) + removeCommentBarrage(commentBarrageItem) { + commentBarrageItem.className = "comment-barrage-item out"; + setTimeout(() => { + this.config.dom.removeChild(commentBarrageItem); + }, 1000); } async initCommentBarrage() { - if (localStorage.getItem("commentBarrageSwitch") != null) { + const commentBarrageSwitch = localStorage.getItem("commentBarrageSwitch"); + if (commentBarrageSwitch != null) { document.querySelector(".comment-barrage").style.display = "flex"; - GLOBAL_CONFIG.rightside.enable && (document.querySelector(".menu-commentBarrage-text").textContent = "关闭热评"); + if (GLOBAL_CONFIG.rightside.enable) { + document.querySelector(".menu-commentBarrage-text").textContent = "关闭热评"; + } document.querySelector("#consoleCommentBarrage").classList.add("on"); } else { document.querySelector(".comment-barrage").style.display = "none"; - GLOBAL_CONFIG.rightside.enable && (document.querySelector(".menu-commentBarrage-text").textContent = "显示热评"); + if (GLOBAL_CONFIG.rightside.enable) { + document.querySelector(".menu-commentBarrage-text").textContent = "显示热评"; + } document.querySelector("#consoleCommentBarrage").classList.remove("on"); } const comments = await this.fetchComments(); @@ -121,12 +120,13 @@ function initializeCommentBarrage() { this.commentInterval = null; const t = () => { if (this.config.barrageList.length && !this.hoverOnCommentBarrage) { - if (!this.popCommentBarrage(this.config.barrageList[this.config.barrageIndex])) - return this.config.barrageIndex += 1, - this.config.barrageIndex %= this.config.barrageList.length, - void t(); - this.config.barrageIndex += 1, - this.config.barrageIndex %= this.config.barrageList.length + if (!this.popCommentBarrage(this.config.barrageList[this.config.barrageIndex])) { + this.config.barrageIndex += 1; + this.config.barrageIndex %= this.config.barrageList.length; + return t(); + } + this.config.barrageIndex += 1; + this.config.barrageIndex %= this.config.barrageList.length; } if (this.config.barrageTimer.length > (this.config.barrageList.length > this.config.maxBarrage ? this.config.maxBarrage : this.config.barrageList.length) && !this.hoverOnCommentBarrage) { this.removeCommentBarrage(this.config.barrageTimer.shift()); @@ -152,5 +152,6 @@ function initializeCommentBarrage() { }); } } - (e) + + new CommentBarrage(e); } \ No newline at end of file diff --git a/source/js/covercolor/local.js b/source/js/covercolor/local.js index 6810f8b2..adb59d36 100644 --- a/source/js/covercolor/local.js +++ b/source/js/covercolor/local.js @@ -107,9 +107,6 @@ function colorRgb(str) { } function setThemeColors(value, r = null, g = null, b = null) { - const cardContents = document.getElementsByClassName('card-content'); - const authorInfo = document.getElementsByClassName('author-info__sayhi'); - if (value) { document.documentElement.style.setProperty('--sco-main', value); document.documentElement.style.setProperty('--sco-main-op', value + '23'); @@ -118,13 +115,17 @@ function setThemeColors(value, r = null, g = null, b = null) { if (r && g && b) { let brightness = Math.round(((parseInt(r) * 299) + (parseInt(g) * 587) + (parseInt(b) * 114)) / 1000); - for (let i = 0; i < cardContents.length; i++) { - cardContents[i].style.setProperty('--sco-card-bg', 'var(--sco-white)'); - } - - for (let i = 0; i < authorInfo.length; i++) { - authorInfo[i].style.setProperty('background', 'var(--sco-white-op)'); - authorInfo[i].style.setProperty('color', 'var(--sco-white)'); + if (brightness < 125) { + let cardContents = document.getElementsByClassName('card-content'); + for (let i = 0; i < cardContents.length; i++) { + cardContents[i].style.setProperty('--sco-card-bg', 'var(--sco-white)'); + } + + let authorInfo = document.getElementsByClassName('author-info__sayhi'); + for (let i = 0; i < authorInfo.length; i++) { + authorInfo[i].style.setProperty('background', 'var(--sco-white-op)'); + authorInfo[i].style.setProperty('color', 'var(--sco-white)'); + } } } diff --git a/source/js/music.js b/source/js/music.js index e9f085b0..2d771474 100644 --- a/source/js/music.js +++ b/source/js/music.js @@ -1,93 +1,82 @@ -var vh = window.innerHeight * 1; -var scoMusic = { - // 获取地址栏参数 - // 创建URLSearchParams对象并传入URL中的查询字符串 +const scoMusic = { params: new URLSearchParams(window.location.search), - extractValue: function (input) { - var valueRegex = /\("([^\s]+)"\)/g; - var match = valueRegex.exec(input); + extractValue: (input) => { + const valueRegex = /\("([^\s]+)"\)/g; + const match = valueRegex.exec(input); return match[1]; }, - changeMusicBg: function (isChangeBg = true) { - const MusicBg = document.getElementById("Music-bg") - const MusicLoading = document.getElementsByClassName("Music-loading") + changeMusicBg: (isChangeBg = true) => { + const MusicBg = document.getElementById("Music-bg"); + const MusicLoading = document.getElementsByClassName("Music-loading"); if (isChangeBg) { const musiccover = document.querySelector("#Music-page .aplayer-pic"); - var img = new Image(); + const img = new Image(); img.src = scoMusic.extractValue(musiccover.style.backgroundImage); - img.onload = function () { + img.onload = () => { MusicBg.style.backgroundImage = musiccover.style.backgroundImage; }; } else { - let timer = setInterval(() => { + const timer = setInterval(() => { const musiccover = document.querySelector("#Music-page .aplayer-pic"); - // 确保player加载完成 if (musiccover) { MusicLoading[0].style.display = "none"; - clearInterval(timer) - document.querySelector('meting-js') - .aplayer.volume(0.8, true); + clearInterval(timer); + document.querySelector('meting-js').aplayer.volume(0.8, true); scoMusic.addEventListenerChangeMusicBg(); MusicBg.style.display = "block"; } - }, 100) + }, 100); } }, - lrcupdate: function () { - var aplayerLrcContents = document.querySelector('.aplayer-lrc-contents'); - var currentLrc = aplayerLrcContents.querySelector('p.aplayer-lrc-current'); + lrcupdate: () => { + const aplayerLrcContents = document.querySelector('.aplayer-lrc-contents'); + const currentLrc = aplayerLrcContents.querySelector('p.aplayer-lrc-current'); if (currentLrc) { - var currentIndex = Array.from(aplayerLrcContents.children) - .indexOf(currentLrc); - var translateYValue = -currentIndex * 80; + const currentIndex = Array.from(aplayerLrcContents.children).indexOf(currentLrc); + const translateYValue = -currentIndex * 80; - aplayerLrcContents.style.transform = 'translateY(' + translateYValue + 'px)'; + aplayerLrcContents.style.transform = `translateY(${translateYValue}px)`; } }, - buttonlist: function () { - document.querySelector(".aplayer-lrc") - .addEventListener("click", function () { - const aplayerList = document.querySelector(".aplayer-list"); + buttonlist: () => { + document.querySelector(".aplayer-lrc").addEventListener("click", () => { + const aplayerList = document.querySelector(".aplayer-list"); - if (aplayerList.classList.contains("aplayer-list-hide")) { - aplayerList.classList.remove("aplayer-list-hide"); - } else { - aplayerList.classList.add("aplayer-list-hide"); - } - }); + if (aplayerList.classList.contains("aplayer-list-hide")) { + aplayerList.classList.remove("aplayer-list-hide"); + } else { + aplayerList.classList.add("aplayer-list-hide"); + } + }); }, - addEventListenerChangeMusicBg: function () { - const aplayer = document.getElementById("Music-page").querySelector("meting-js").aplayer - aplayer.on('loadeddata', function () { + addEventListenerChangeMusicBg: () => { + const aplayer = document.getElementById("Music-page").querySelector("meting-js").aplayer; + aplayer.on('loadeddata', () => { scoMusic.changeMusicBg(); }); - aplayer.on('timeupdate', function () { + aplayer.on('timeupdate', () => { scoMusic.lrcupdate(); }); scoMusic.buttonlist(); }, - getCustomPlayList: function () { + getCustomPlayList: () => { const MusicPage = document.getElementById("Music-page"); const playlistType = scoMusic.params.get("type") || "playlist"; if (scoMusic.params.get("id") && params.get("server")) { - var id = scoMusic.params.get("id") - var server = scoMusic.params.get("server") + const id = scoMusic.params.get("id"); + const server = scoMusic.params.get("server"); MusicPage.innerHTML = ``; } else { MusicPage.innerHTML = ``; } scoMusic.changeMusicBg(false); }, - /** - * 绑定键盘事件 - * @param event - */ - setKeydown: function (event) { - const aplayer = document.querySelector('meting-js').aplayer + setKeydown: (event) => { + const aplayer = document.querySelector('meting-js').aplayer; if (event.code === "Space") { event.preventDefault(); aplayer.toggle(); @@ -113,15 +102,13 @@ var scoMusic = { } } }, - init: function () { + init: () => { + let vh = window.innerHeight * 1; document.documentElement.style.setProperty('--vh', `${vh}px`); - // 初始化 - this.getCustomPlayList(); - - //热键控制音乐 + scoMusic.getCustomPlayList(); document.addEventListener("keydown", scoMusic.setKeydown); } -} +}; window.addEventListener('resize', () => { let vh = window.innerHeight * 1; From a8abc761d96aa10daa7c66ae1fbe02302331245f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8D=93Sco?= Date: Wed, 7 Feb 2024 23:18:11 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E2=9C=A8feat:=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化代码 --- scripts/helper/getArchiveLength.js | 14 +- scripts/helper/related_post.js | 67 +-- scripts/helper/stylus.js | 14 +- source/css/_global/animation.css | 813 ----------------------------- source/css/_global/animation.styl | 307 +++++++++++ source/css/index.styl | 1 - 6 files changed, 345 insertions(+), 871 deletions(-) delete mode 100644 source/css/_global/animation.css create mode 100644 source/css/_global/animation.styl diff --git a/scripts/helper/getArchiveLength.js b/scripts/helper/getArchiveLength.js index 8be8aafe..0391ab1b 100644 --- a/scripts/helper/getArchiveLength.js +++ b/scripts/helper/getArchiveLength.js @@ -6,13 +6,9 @@ hexo.extend.helper.register('getArchiveLength', function (type) { } const posts = this.site.posts.sort('-date').data let archive = {} - posts.forEach(post => { + for (const post of posts) { const postdate = type === 'year' ? moment(post.date).format('YYYY') : moment(post.date).format('YYYY/MM'); - if(!archive[postdate]){ - archive[postdate] = 1 - } else { - archive[postdate] ++ - } - }); - return archive -}); + archive[postdate] = (archive[postdate] || 0) + 1; + } + return archive; +}); \ No newline at end of file diff --git a/scripts/helper/related_post.js b/scripts/helper/related_post.js index 4c94e0e0..50cd9c0a 100644 --- a/scripts/helper/related_post.js +++ b/scripts/helper/related_post.js @@ -1,10 +1,15 @@ 'use strict' hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { - let relatedPosts = [] + const relatedPosts = [] + const config = hexo.theme.config + const limitNum = config.related_post.limit || 6 + const dateType = config.related_post.date_type || 'created' + const headlineLang = this._p('喜欢这篇的人也看了') + currentPost.tags.forEach(function (tag) { allPosts.forEach(function (post) { - if (isTagRelated(tag.name, post.tags)) { + if (isTagRelated(tag.name, post.tags) && currentPost.path !== post.path) { const relatedPost = { title: post.title, path: post.path, @@ -18,61 +23,45 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { if (index !== -1) { relatedPosts[index].weight += 1 } else { - if (currentPost.path !== post.path) { - relatedPosts.push(relatedPost) - } + relatedPosts.push(relatedPost) } } }) }) + if (relatedPosts.length === 0) { return '' } - let result = '' - const config = hexo.theme.config - - const limitNum = config.related_post.limit || 6 - const dateType = config.related_post.date_type || 'created' - const headlineLang = this._p('喜欢这篇的人也看了') - - relatedPosts = relatedPosts.sort(compare('weight', dateType)) - if (relatedPosts.length > 0) { - result += '' + return result }) function isTagRelated(tagName, TBDtags) { - let result = false - TBDtags.forEach(function (tag) { - if (tagName === tag.name) { - result = true - } + return TBDtags.some(function (tag) { + return tagName === tag.name }) - return result } function findItem(arrayToSearch, attr, val) { - for (let i = 0; i < arrayToSearch.length; i++) { - if (arrayToSearch[i][attr] === val) { - return i - } - } - return -1 + return arrayToSearch.findIndex(function (item) { + return item[attr] === val + }) } function compare(attr, dateType) { diff --git a/scripts/helper/stylus.js b/scripts/helper/stylus.js index f2ca56cb..53f7e41a 100644 --- a/scripts/helper/stylus.js +++ b/scripts/helper/stylus.js @@ -1,13 +1,13 @@ hexo.extend.filter.register('stylus:renderer', function (style) { - const {config, theme} = this + const {config, theme} = this; const data = hexo.locals.get('data'); if (theme.config.aside.tags.highlight) { - let array = theme.config.aside.tags.list.map(item => encodeURIComponent(item)); + const array = theme.config.aside.tags.list.map(item => encodeURIComponent(item)); style.define('highlightTags', array); } - let aside = [ + const aside = [ theme.config.aside.home.noSticky, theme.config.aside.home.Sticky, theme.config.aside.post.noSticky, @@ -15,14 +15,10 @@ hexo.extend.filter.register('stylus:renderer', function (style) { theme.config.aside.page.Sticky, theme.config.aside.page.noSticky ].join(',').split(','); - let uniqueArr = [...new Set(aside)]; // 去重 + const uniqueArr = [...new Set(aside)]; if (uniqueArr.length > 0) { style.define('aside', uniqueArr); } - if (data && data.about) { - style.define('about', Object.keys(data.about)); - } else { - style.define('about', []); - } + style.define('about', data && data.about ? Object.keys(data.about) : []); }); \ No newline at end of file diff --git a/source/css/_global/animation.css b/source/css/_global/animation.css deleted file mode 100644 index d35258ea..00000000 --- a/source/css/_global/animation.css +++ /dev/null @@ -1,813 +0,0 @@ -@keyframes barrageIn { - 0% { - transform: translateY(20px); - opacity: 0 - } - - 100% { - transform: translateY(0); - opacity: 1 - } -} - -@keyframes barrageOut { - 0% { - transform: translateY(0); - opacity: 1 - } - - 100% { - transform: translateY(20px); - opacity: 0 - } -} - -@-webkit-keyframes scroll-down-effect { - 0% { - top: 0; - opacity: .4 - } - - 50% { - top: -16px; - opacity: 1; - filter: none - } - - 100% { - top: 0; - opacity: .4 - } -} - -@keyframes scroll-down-effect { - 0% { - top: 0; - opacity: .4 - } - - 50% { - top: -16px; - opacity: 1; - filter: none - } - - 100% { - top: 0; - opacity: .4 - } -} - -@-webkit-keyframes header-effect { - 0% { - opacity: 0; - transform: translateY(-50px) - } - - 100% { - opacity: 1; - filter: none; - transform: translateY(0) - } -} - -@keyframes header-effect { - 0% { - opacity: 0; - transform: translateY(-50px) - } - - 100% { - opacity: 1; - filter: none; - transform: translateY(0) - } -} - -@-webkit-keyframes headerNoOpacity { - 0% { - transform: translateY(-50px) - } - - 100% { - transform: translateY(0) - } -} - -@keyframes headerNoOpacity { - 0% { - transform: translateY(-50px) - } - - 100% { - transform: translateY(0) - } -} - -@-webkit-keyframes bottom-top { - 0% { - opacity: 0; - margin-top: 50px - } - - 100% { - opacity: 1; - filter: none; - margin-top: 0 - } -} - -@keyframes bottom-top { - 0% { - opacity: 0; - margin-top: 50px - } - - 100% { - opacity: 1; - filter: none; - margin-top: 0 - } -} - -@-webkit-keyframes titlescale { - 0% { - opacity: 0; - transform: scale(.7) - } - - 100% { - opacity: 1; - filter: none; - transform: scale(1) - } -} - -@keyframes titlescale { - 0% { - opacity: 0; - transform: scale(.7) - } - - 100% { - opacity: 1; - filter: none; - transform: scale(1) - } -} - -@-webkit-keyframes search_close { - 0% { - transform: translateY(0); - opacity: 1 - } - - 100% { - transform: translateY(20px); - opacity: 0 - } -} - -@keyframes search_close { - 0% { - transform: translateY(0); - opacity: 1 - } - - 100% { - transform: translateY(20px); - opacity: 0 - } -} - -@-webkit-keyframes to_show { - 0% { - opacity: 0 - } - - 100% { - opacity: 1; - filter: none - } -} - -@keyframes to_show { - 0% { - opacity: 0 - } - - 100% { - opacity: 1; - filter: none - } -} - -@-webkit-keyframes to_hide { - 0% { - opacity: 1; - filter: none - } - - 100% { - opacity: 0 - } -} - -@keyframes to_hide { - 0% { - opacity: 1; - filter: none - } - - 100% { - opacity: 0 - } -} - -@-webkit-keyframes ribbon_to_show { - 0% { - opacity: 0 - } - - 100% { - opacity: .6 - } -} - -@keyframes ribbon_to_show { - 0% { - opacity: 0 - } - - 100% { - opacity: .6 - } -} - -@-webkit-keyframes avatar_turn_around { - 0% { - transform: rotate(0) - } - - 100% { - transform: rotate(360deg) - } -} - -@keyframes avatar_turn_around { - 0% { - transform: rotate(0) - } - - 100% { - transform: rotate(360deg) - } -} - -@-webkit-keyframes sub_menus { - 0% { - opacity: 0; - transform: translateY(10px) - } - - 100% { - opacity: 1; - filter: none; - transform: translateY(0) - } -} - -@keyframes sub_menus { - 0% { - opacity: 0; - transform: translateY(10px) - } - - 100% { - opacity: 1; - filter: none; - transform: translateY(0) - } -} - -@-webkit-keyframes donate_effcet { - 0% { - opacity: 0; - transform: translateY(-20px) - } - - 100% { - opacity: 1; - filter: none; - transform: translateY(0) - } -} - -@keyframes donate_effcet { - 0% { - opacity: 0; - transform: translateY(-20px) - } - - 100% { - opacity: 1; - filter: none; - transform: translateY(0) - } -} - -@-webkit-keyframes announ_animation { - 0%, 100% { - transform: scale(1); - filter: blur(0) - } - - 50% { - transform: scale(1.2); - filter: blur(20px) - } -} - -@keyframes announ_animation { - 0%, 100% { - transform: scale(1); - filter: blur(0) - } - - 50% { - transform: scale(1.2); - filter: blur(20px) - } -} - -@-webkit-keyframes sidebarItem { - 0% { - transform: translateX(200px) - } - - 100% { - transform: translateX(0) - } -} - -@keyframes sidebarItem { - 0% { - transform: translateX(200px) - } - - 100% { - transform: translateX(0) - } -} - -@keyframes sco-spin { - 0% { - transform: rotate(0) - } - - 100% { - transform: rotate(360deg) - } -} - -@-webkit-keyframes code-expand-key { - 0% { - opacity: .6 - } - - 50% { - opacity: .1 - } - - 100% { - opacity: .6 - } -} - -@keyframes code-expand-key { - 0% { - opacity: .6 - } - - 50% { - opacity: .1 - } - - 100% { - opacity: .6 - } -} - -@keyframes slide-in { - from { - transform: translateY(20px); - opacity: 0 - } - - to { - transform: translateY(0); - opacity: 1 - } -} - -@keyframes slide-in-op { - from { - opacity: 0 - } - - to { - opacity: 1 - } -} - -@-webkit-keyframes more-btn-move { - 0%, 100% { - transform: translateX(0) - } - - 50% { - transform: translateX(3px) - } -} - -@keyframes more-btn-move { - 0%, 100% { - transform: translateX(0) - } - - 50% { - transform: translateX(3px) - } -} - -@-webkit-keyframes toc-open { - 0% { - transform: scale(.7) - } - - 100% { - transform: scale(1) - } -} - -@keyframes toc-open { - 0% { - transform: scale(.7) - } - - 100% { - transform: scale(1) - } -} - -@-webkit-keyframes toc-close { - 0% { - transform: scale(1) - } - - 100% { - transform: scale(.7) - } -} - -@keyframes toc-close { - 0% { - transform: scale(1) - } - - 100% { - transform: scale(.7) - } -} - -@-webkit-keyframes configure-clockwise { - 0% { - transform: rotate(0) - } - - 25% { - transform: rotate(90deg) - } - - 50% { - transform: rotate(180deg) - } - - 75% { - transform: rotate(270deg) - } - - 100% { - transform: rotate(360deg) - } -} - -@keyframes configure-clockwise { - 0% { - transform: rotate(0) - } - - 25% { - transform: rotate(90deg) - } - - 50% { - transform: rotate(180deg) - } - - 75% { - transform: rotate(270deg) - } - - 100% { - transform: rotate(360deg) - } -} - -@-webkit-keyframes configure-xclockwise { - 0% { - transform: rotate(45deg) - } - - 25% { - transform: rotate(-45deg) - } - - 50% { - transform: rotate(-135deg) - } - - 75% { - transform: rotate(-225deg) - } - - 100% { - transform: rotate(-315deg) - } -} - -@keyframes configure-xclockwise { - 0% { - transform: rotate(45deg) - } - - 25% { - transform: rotate(-45deg) - } - - 50% { - transform: rotate(-135deg) - } - - 75% { - transform: rotate(-225deg) - } - - 100% { - transform: rotate(-315deg) - } -} - -@-webkit-keyframes tabshow { - 0% { - transform: translateY(15px) - } - - 100% { - transform: translateY(0) - } -} - -@keyframes tabshow { - 0% { - transform: translateY(15px) - } - - 100% { - transform: translateY(0) - } -} - -@-webkit-keyframes playingShadow { - 0% { - box-shadow: 0 0 12px -6px var(--sco-none) - } - - 50% { - box-shadow: 0 0 12px 0 var(--sco-main) - } - - 100% { - box-shadow: 0 0 12px -6px var(--sco-none) - } -} - -@-webkit-keyframes changeright { - 0% { - -webkit-transform: rotate(0) scale(1.1); - box-shadow: 0 0 2px #ffffff00 - } - - 25% { - -webkit-transform: rotate(90deg) scale(1.1); - box-shadow: 0 0 10px #fff - } - - 50% { - -webkit-transform: rotate(180deg) scale(1.1); - box-shadow: 0 0 2px #ffffff00 - } - - 75% { - -webkit-transform: rotate(270deg) scale(1.1); - box-shadow: 0 0 10px #fff - } - - 100% { - -webkit-transform: rotate(360deg) scale(1.1); - box-shadow: 0 0 2px #ffffff00 - } -} - -@-webkit-keyframes lightBar { - 0% { - opacity: .1 - } - - 60% { - opacity: .3 - } - - 100% { - opacity: .1 - } -} - -@keyframes snackbar-progress { - from { - width: 0 - } - - to { - width: 100% - } -} - -@keyframes move-forever { - 0% { - transform: translate3d(-90px, 0, 0) - } - - 100% { - transform: translate3d(85px, 0, 0) - } -} - -@keyframes rowup { - from { - transform: translateX(0) - } - - to { - transform: translateX(-50%) - } -} - -@keyframes gradient { - 0% { - background-position: 0 50% - } - - 50% { - background-position: 100% 50% - } - - 100% { - background-position: 0 50% - } -} - -@keyframes commonTipsIn { - 0% { - top: -50px; - opacity: 0 - } - - 100% { - top: -60px; - opacity: 1 - } -} - -@keyframes commonTriangleIn { - 0% { - transform: translate(-50%, -36px); - opacity: 0 - } - - 100% { - transform: translate(-50%, -46px); - opacity: 1 - } -} - -@keyframes owoIn { - 0% { - transform: translate(0, -95%); - opacity: 0 - } - - 100% { - transform: translate(0, -105%); - opacity: 1 - } -} - -@keyframes light_tag { - 0% { - transform: skewx(0); - -o-transform: skewx(0); - -moz-transform: skewx(0); - -webkit-transform: skewx(0); - left: -150px - } - - 99% { - transform: skewx(-25deg); - -o-transform: skewx(-25deg); - -moz-transform: skewx(-25deg); - -webkit-transform: skewx(-25deg); - left: 50px - } -} - -@keyframes floating { - 0% { - transform: translate(0, -4px) - } - - 50% { - transform: translate(0, 4px) - } - - 100% { - transform: translate(0, -4px) - } -} - -@media screen and (min-width: 768px) { - @keyframes showCover { - from { - opacity: 0; - transform: rotate(10deg) translateY(-8%) scale(1.8); - } - to { - opacity: 0.5; - transform: rotate(10deg) translateY(-10%) scale(2); - } - } -} - -@keyframes blinking-cursor { - 0% { - transform: scale(.6) - } - - 25% { - transform: scale(1) - } - - 50% { - transform: scale(.6) - } - - 75% { - transform: scale(1) - } - - 100% { - transform: scale(.6) - } -} - -@keyframes AILoading { - 0% { - opacity: 1 - } - - 25% { - opacity: .3 - } - - 50% { - opacity: 1 - } - - 75% { - opacity: .3 - } - - 100% { - opacity: 1 - } -} \ No newline at end of file diff --git a/source/css/_global/animation.styl b/source/css/_global/animation.styl new file mode 100644 index 00000000..5196d54a --- /dev/null +++ b/source/css/_global/animation.styl @@ -0,0 +1,307 @@ +@keyframes barrageIn + 0% + transform translateY(20px) + opacity 0 + 100% + transform translateY(0) + opacity 1 + +@keyframes barrageOut + 0% + transform translateY(0) + opacity 1 + 100% + transform translateY(20px) + opacity 0 + +@keyframes scroll-down-effect + 0% + top 0 + opacity .4 + 50% + top -16px + opacity 1 + filter none + 100% + top 0 + opacity .4 + +@keyframes header-effect + 0% + opacity 0 + transform translateY(-50px) + 100% + opacity 1 + filter none + transform translateY(0) + +@keyframes headerNoOpacity + 0% + transform translateY(-50px) + 100% + transform translateY(0) + +@keyframes bottom-top + 0% + opacity 0 + margin-top 50px + 100% + opacity 1 + filter none + margin-top 0 + +@keyframes titlescale + 0% + opacity 0 + transform scale(.7) + 100% + opacity 1 + filter none + transform scale(1) + +@keyframes search_close + 0% + transform translateY(0) + opacity 1 + 100% + transform translateY(20px) + opacity 0 + +@keyframes to_show + 0% + opacity 0 + 100% + opacity 1 + filter none + +@keyframes to_hide + 0% + opacity 1 + filter none + 100% + opacity 0 + +@keyframes ribbon_to_show + 0% + opacity 0 + 100% + opacity .6 + +@keyframes avatar_turn_around + 0% + transform rotate(0) + 100% + transform rotate(360deg) + +@keyframes sub_menus + 0% + opacity 0 + transform translateY(10px) + 100% + opacity 1 + filter none + transform translateY(0) + +@keyframes donate_effcet + 0% + opacity 0 + transform translateY(-20px) + 100% + opacity 1 + filter none + transform translateY(0) + +@keyframes announ_animation + 0%, 100% + transform scale(1) + filter blur(0) + 50% + transform scale(1.2) + filter blur(20px) + +@keyframes sidebarItem + 0% + transform translateX(200px) + 100% + transform translateX(0) + +@keyframes sco-spin + 0% + transform rotate(0) + 100% + transform rotate(360deg) + +@keyframes code-expand-key + 0% + opacity .6 + 50% + opacity .1 + 100% + opacity .6 + +@keyframes slide-in + from + transform translateY(20px) + opacity 0 + to + transform translateY(0) + opacity 1 + +@keyframes slide-in-op + from + opacity 0 + to + opacity 1 + +@keyframes more-btn-move + 0%, 100% + transform translateX(0) + 50% + transform translateX(3px) + +@keyframes toc-open + 0% + transform scale(.7) + 100% + transform scale(1) + +@keyframes toc-close + 0% + transform scale(1) + 100% + transform scale(.7) + +@keyframes configure-clockwise + 0% + transform rotate(0) + 25% + transform rotate(90deg) + 50% + transform rotate(180deg) + 75% + transform rotate(270deg) + 100% + transform rotate(360deg) + +@keyframes configure-xclockwise + 0% + transform rotate(45deg) + 25% + transform rotate(-45deg) + 50% + transform rotate(-135deg) + 75% + transform rotate(-225deg) + 100% + transform rotate(-315deg) + +@keyframes tabshow + 0% + transform translateY(15px) + 100% + transform translateY(0) + +@keyframes snackbar-progress + from + width 0 + to + width 100% + +@keyframes move-forever + 0% + transform translate3d(-90px, 0, 0) + 100% + transform translate3d(85px, 0, 0) + +@keyframes rowup + from + transform translateX(0) + to + transform translateX(-50%) + +@keyframes gradient + 0% + background-position 0 50% + 50% + background-position 100% 50% + 100% + background-position 0 50% + +@keyframes commonTipsIn + 0% + top -50px + opacity 0 + 100% + top -60px + opacity 1 + +@keyframes commonTriangleIn + 0% + transform translate(-50%, -36px) + opacity 0 + 100% + transform translate(-50%, -46px) + opacity 1 + +@keyframes owoIn + 0% + transform translate(0, -95%) + opacity 0 + 100% + transform translate(0, -105%) + opacity 1 + +@keyframes light_tag + 0% + transform skewx(0) + -o-transform skewx(0) + -moz-transform skewx(0) + -webkit-transform skewx(0) + left -150px + 99% + transform skewx(-25deg) + -o-transform skewx(-25deg) + -moz-transform skewx(-25deg) + -webkit-transform skewx(-25deg) + left 50px + +@keyframes floating + 0% + transform translate(0, -4px) + 50% + transform translate(0, 4px) + 100% + transform translate(0, -4px) + +@media screen and (min-width: 768px) + @keyframes showCover + from + opacity 0 + transform rotate(10deg) translateY(-8%) scale(1.8) + to + opacity 0.5 + transform rotate(10deg) translateY(-10%) scale(2) + +@keyframes blinking-cursor + 0% + transform scale(.6) + 25% + transform scale(1) + 50% + transform scale(.6) + 75% + transform scale(1) + 100% + transform scale(.6) + +@keyframes AILoading + 0% + opacity 1 + 25% + opacity .3 + 50% + opacity 1 + 75% + opacity .3 + 100% + opacity 1 \ No newline at end of file diff --git a/source/css/index.styl b/source/css/index.styl index 5ed30e03..72079197 100644 --- a/source/css/index.styl +++ b/source/css/index.styl @@ -4,7 +4,6 @@ if hexo-config('css_prefix') @import 'nib' // project -@import '_global/animation.css' @import '_global/*' @import '_layout/*' @import '_page/index.styl' From 37865fa66ea7b681537b940ad62a9c5fc2e0a412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8D=93Sco?= Date: Thu, 8 Feb 2024 17:54:48 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E2=9C=A8feat:=20update=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 6 -- languages/en-US.yml | 5 +- languages/zh-CN.yml | 5 +- languages/zh-TW.yml | 5 +- layout/404.pug | 4 +- layout/includes/head/config.pug | 14 +-- layout/includes/head/opengraph.pug | 9 +- layout/includes/head/pwa.pug | 5 +- layout/includes/inject/body.pug | 34 +++---- layout/includes/inject/head.pug | 5 +- layout/includes/mixins/pagination.pug | 2 +- layout/includes/page/rss.pug | 20 ----- layout/includes/page/says.pug | 49 ++++++++-- layout/includes/widgets/home/bb/local.pug | 20 ----- layout/includes/widgets/home/bb/memos.pug | 36 -------- layout/includes/widgets/home/bbTimeList.pug | 18 ++-- layout/includes/widgets/page/says/local.pug | 44 --------- layout/includes/widgets/page/says/memos.pug | 99 --------------------- layout/page.pug | 2 - source/js/music.js | 71 +++++++++++++-- 20 files changed, 168 insertions(+), 285 deletions(-) delete mode 100644 layout/includes/page/rss.pug delete mode 100644 layout/includes/widgets/home/bb/local.pug delete mode 100644 layout/includes/widgets/home/bb/memos.pug delete mode 100644 layout/includes/widgets/page/says/local.pug delete mode 100644 layout/includes/widgets/page/says/memos.pug diff --git a/_config.yml b/_config.yml index 3c11c6e9..50250311 100644 --- a/_config.yml +++ b/_config.yml @@ -607,12 +607,6 @@ says: # 即刻短文仅展示前n条 # Jike short text only shows the first n strip: 30 - # 模式选择。local:本地静态 / memos:动态Memos - # Mode selection. Local: local static/memos: dynamic Memos - mode: local - # 动态模式地址。memos模式,此项为必填。链接获取以及格式可查看主题文档。 - # Dynamic mode address. For memos mode, this item is required. Link acquisition and format can be viewed in the theme documentation. - mode_link: # https://example.com/api/v1/memo?creatorId=1&tag=says # ------------------------- # meeting-api,用于界面中的音乐胶囊和音乐馆页,可自定义api,不会请勿动。 diff --git a/languages/en-US.yml b/languages/en-US.yml index c368eea6..ffed0ec5 100755 --- a/languages/en-US.yml +++ b/languages/en-US.yml @@ -144,4 +144,7 @@ rightmenu: dark: Dark light: Light chs_to_cht: Traditional - cht_to_chs: Simplified \ No newline at end of file + cht_to_chs: Simplified + +404: + button: Back to home \ No newline at end of file diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml index 36bd0782..1a672ca1 100755 --- a/languages/zh-CN.yml +++ b/languages/zh-CN.yml @@ -144,4 +144,7 @@ rightmenu: dark: 深色模式 light: 浅色模式 chs_to_cht: 轉為繁體 - cht_to_chs: 转为简体 \ No newline at end of file + cht_to_chs: 转为简体 + +404: + button: 返回首页 \ No newline at end of file diff --git a/languages/zh-TW.yml b/languages/zh-TW.yml index 4428c45b..9766ea0a 100755 --- a/languages/zh-TW.yml +++ b/languages/zh-TW.yml @@ -144,4 +144,7 @@ rightmenu: dark: 深色模式 light: 淺色模式 chs_to_cht: 轉為繁體 - cht_to_chs: 转为简体 \ No newline at end of file + cht_to_chs: 转为简体 + +404: + button: 返回首頁 \ No newline at end of file diff --git a/layout/404.pug b/layout/404.pug index 5b4e27ac..9baadbfd 100644 --- a/layout/404.pug +++ b/layout/404.pug @@ -3,13 +3,13 @@ extends includes/layout.pug block content #error-wrap .error-content - .error-img(style='background-image: url(' + url_for(theme.errorpage.img) + ')') + .error-img(style=`background-image: url(${url_for(theme.errorpage.img)})`) .error-info h1.error_title 404 .error_subtitle= theme.errorpage.text a.button--animated(href="/") i.scoicon.sco-external-link - | 回到主页 + =_p('404.button') if theme.errorpage.recommendList .aside-list diff --git a/layout/includes/head/config.pug b/layout/includes/head/config.pug index e27087df..b91071a3 100644 --- a/layout/includes/head/config.pug +++ b/layout/includes/head/config.pug @@ -7,7 +7,7 @@ localSearch = JSON.stringify({ preload: theme.search.local.preload, path: theme?.search?.local?.CDN || '/search.xml' - }) + }); break; case 'algolia': algolia = JSON.stringify({ @@ -17,7 +17,7 @@ hits: { per_page: theme?.search?.algolia?.hits?.per_page || 10 } - }) + }); break; } } @@ -27,12 +27,12 @@ translate = JSON.stringify({ defaultEncoding: theme.translate.defaultEncoding, translateDelay: theme.translate.translateDelay, - }) + }); } - const commentInfoStart = theme.comment.randomInfoStart.map(item => `"${item}"`) || "" - const commentInfoEnd = theme.comment.randomInfoEnd.map(item => `"${item}"`) || "" - var sayhello2 = theme.aside.card.sayhello2.map(item => `"${item}"`) || [] + const commentInfoStart = theme.comment.randomInfoStart.map(item => `"${item}"`) || []; + const commentInfoEnd = theme.comment.randomInfoEnd.map(item => `"${item}"`) || []; + const sayhello2 = theme.aside.card.sayhello2.map(item => `"${item}"`) || []; script. const GLOBAL_CONFIG = { @@ -119,4 +119,4 @@ script. enable: !{theme.music.enable}, }, translate: !{translate}, - } \ No newline at end of file + }; \ No newline at end of file diff --git a/layout/includes/head/opengraph.pug b/layout/includes/head/opengraph.pug index 5d71c575..4a8f40a5 100644 --- a/layout/includes/head/opengraph.pug +++ b/layout/includes/head/opengraph.pug @@ -1,10 +1,11 @@ if theme.opengraph.enable - const coverVal = page.cover || theme.site.siteIcon - let ogOption = Object.assign({ - type: is_post() ? 'article' : 'website', - image: coverVal ? full_url_for(coverVal) : '', - }, theme.opengraph.options) + let ogOption = { + type: is_post() ? 'article' : 'website', + image: coverVal ? full_url_for(coverVal) : '', + ...theme.opengraph.options + } - != open_graph(ogOption) else diff --git a/layout/includes/head/pwa.pug b/layout/includes/head/pwa.pug index 7aab17fe..58b147cc 100644 --- a/layout/includes/head/pwa.pug +++ b/layout/includes/head/pwa.pug @@ -1,11 +1,11 @@ if theme.pwa.enable meta(name="theme-color", content=theme.pwa.theme_color) link(rel="manifest" href=url_for(theme.pwa.manifest)) - if(theme.pwa.theme_color) + if theme.pwa.theme_color meta(name="msapplication-TileColor" content=theme.pwa.theme_color) if theme.pwa.mask_icon link(rel="mask-icon", href=theme.pwa.mask_icon, color=theme.pwa.theme_color) - if(theme.pwa.apple_touch_icon) + if theme.pwa.apple_touch_icon link(rel="apple-touch-icon" sizes="180x180" href=url_for(theme.pwa.apple_touch_icon)) if theme.pwa.favicon_16_16 link(rel="icon", type="image/png", sizes="16x16", href=theme.pwa.favicon_16_16) @@ -13,7 +13,6 @@ if theme.pwa.enable link(rel="icon", type="image/png", sizes="32x32", href=theme.pwa.favicon_32_32) if theme.pwa.bookmark_icon link(rel="bookmark", href=theme.pwa.bookmark_icon) - else meta(name="apple-mobile-web-app-capable", content=config.title) link(rel="bookmark", href=theme.site.siteIcon) diff --git a/layout/includes/inject/body.pug b/layout/includes/inject/body.pug index 5940b3c2..cc311bd7 100644 --- a/layout/includes/inject/body.pug +++ b/layout/includes/inject/body.pug @@ -1,5 +1,15 @@ - page.type = is_post() ? 'post' : page.type +mixin katex + if theme.katex.copytex + script(src=url_for(theme.cdn.katex_copytex)) + script. + (() => { + document.querySelectorAll('#article-container span.katex-display').forEach(item => { + utils.wrap(item, 'div', {class: 'katex-wrap'}) + }) + })(); + div script(src=url_for(theme.cdn.main)) script(src=url_for(theme.cdn.utils)) @@ -19,24 +29,11 @@ div if theme.translate.enable script(src=url_for(theme.cdn.translate)) - mixin katex - link(rel="stylesheet", href=url_for(theme.cdn.katex)) - if theme.katex.copytex - script(src=url_for(theme.cdn.katex_copytex)) - script. - (() => { - document.querySelectorAll('#article-container span.katex-display').forEach(item => { - utils.wrap(item, 'div', {class: 'katex-wrap'}) - }) - })() - if theme.katex && theme.katex.enable - if theme.katex.per_page - if is_post() || is_page() - +katex - else - if page.katex - +katex + if theme.katex.per_page && (is_post() || is_page()) + +katex + else if page.katex + +katex script(src=url_for(theme.cdn.pjax)) if theme.lazyload.enable @@ -111,6 +108,9 @@ div#js-pjax if page.type === 'album' && theme.album.enable script. initGallery() + if is_home() && theme.says.home_mini + script. + sco.initbbtalk(); if page.type === 'says' && theme.says.enable script. window.addEventListener('resize', utils.throttle(function () { diff --git a/layout/includes/inject/head.pug b/layout/includes/inject/head.pug index 8205335b..fad7d2a5 100644 --- a/layout/includes/inject/head.pug +++ b/layout/includes/inject/head.pug @@ -15,6 +15,9 @@ if theme.says.home_mini if theme.lightbox && theme.fancybox link(rel="stylesheet", href=url_for(theme.cdn.fancyapps_css)) +if theme.katex && theme.katex.enable + link(rel="stylesheet", href=url_for(theme.cdn.katex)) + // Open Graph include ../head/opengraph.pug @@ -78,8 +81,6 @@ script. "%c🔥 !{_p('head.console')}", "color: #fff; background: linear-gradient(-25deg, #a8edea, #fed6e3); padding: 8px 15px; border-radius: 8px; text-shadow: 2px 2px 4px white; color: black;" ); - -// custom inject if theme.extends.head each item in theme.extends.head != item \ No newline at end of file diff --git a/layout/includes/mixins/pagination.pug b/layout/includes/mixins/pagination.pug index 8057bb4a..983d239c 100644 --- a/layout/includes/mixins/pagination.pug +++ b/layout/includes/mixins/pagination.pug @@ -3,6 +3,6 @@ nav#pagination - var options = {mid_size: 1,escape: false,next_text: '
    下页
    ',prev_text: '
    上页
    '} !=paginator(options) div.toPageGroup - input#toPageText(oninput="value=value.replace(/[^0-9]/g,'')", maxlength="3", title="跳转到指定页面", onkeyup="if (this.value === '0') this.value = ''") + input#toPageText(oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3" title="跳转到指定页面" onkeyup="if (this.value === '0') this.value = ''") a#toPageButton(onclick="sco.toPage()") i.scoicon.sco-show-right-line \ No newline at end of file diff --git a/layout/includes/page/rss.pug b/layout/includes/page/rss.pug deleted file mode 100644 index e6a397c9..00000000 --- a/layout/includes/page/rss.pug +++ /dev/null @@ -1,20 +0,0 @@ -.rss-plan-list - a.rss-plan-item.rss-plan-wechat(href=page.wechatOA, title="公众号") - .rss-plan-description 推送精选文章
    推送全文 - .rss-plan-info-group - .rss-plan-title 公众号订阅 - .rss-plan-info 推荐的订阅方式 - img.rss-plan-icon(src="https://bu.dusays.com/2023/11/01/6541d14a4de78.png", alt="wechat") - a.rss-plan-item.rss-plan-mail(href=page.emailOA, title="email") - .rss-plan-description 推送全部文章
    推送封面与简介 - .rss-plan-info-group - .rss-plan-title 邮件订阅 - .rss-plan-info 推荐的订阅方式 - img.rss-plan-icon(src="https://bu.dusays.com/2023/11/01/6541d16c3ea22.png", alt="email") - a.rss-plan-item.rss-plan-rss(href=page.rssOA, title="rss") - .rss-plan-description 推送全部文章
    推送简介 - .rss-plan-info-group - .rss-plan-title RSS - .rss-plan-info 备用订阅方式 - img.rss-plan-icon(src="https://bu.dusays.com/2023/11/01/6541d184e2a09.png", alt="rss") -!= page.content \ No newline at end of file diff --git a/layout/includes/page/says.pug b/layout/includes/page/says.pug index 064c565c..ff902210 100644 --- a/layout/includes/page/says.pug +++ b/layout/includes/page/says.pug @@ -3,11 +3,50 @@ if theme.says.enable #bber section.timeline.page-1 ul.list#waterfall - case theme.says.mode - when 'local' - include ../widgets/page/says/local - when 'memos' - include ../widgets/page/says/memos + each item in site.data.essay.essay_list.slice(0, theme.says.strip) + li.item + if theme.says.style === 2 + .meta + img.avatar(src=theme.aside.card.author.img) + .info + span.bber_nick= config.author + time.datetime.bber_date(datetime=moment(item.date).format()) + if item.content + a.bber-reply.goComment(onclick=`sco.toTalk('${item.content}')`) + i.scoicon.sco-chat-fill + + #bber-content + p.datacont= item.content + if item.image + .bber-content-img + each img in item.image + img(src=img title="即刻短文配图") + + if item.aplayer + .bber-music + meting-js(server=item.aplayer.server type="song" id=item.aplayer.id mutex="true" preload="none" theme="var(--sco-main)" data-lrctype="0") + + if item.video + .bber-video + if item.video.player + video(src=item.video.player controls="controls" style="object-fit: cover;") + if item.video.bilibili + iframe(src='//player.bilibili.com/player.html?auto-play=0&bvid=' + item.video.bilibili scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true") + + if theme.says.style === 1 + hr + .bber-bottom + .bber-info + .bber-info-time + i.scoicon.sco-calendar-todo-fill + time.datetime(datetime=moment(item.date).format()) + if item.link + a.bber-content-link(href=url_for(item.link) title="跳转到短文指引的链接" target="_blank") + i.scoicon.sco-link-m-line + | 链接 + if item.content + a.bber-reply(onclick=`sco.toTalk('${item.content}')`) + i.scoicon.sco-chat-fill #bber-tips if theme.says.strip === -1 | - 已展开所有短文 - diff --git a/layout/includes/widgets/home/bb/local.pug b/layout/includes/widgets/home/bb/local.pug deleted file mode 100644 index 278f8763..00000000 --- a/layout/includes/widgets/home/bb/local.pug +++ /dev/null @@ -1,20 +0,0 @@ -each item, i in site.data.essay.essay_list.slice(0, 10) - .li-style.swiper-slide - | #{item.content} - if item.image - i.scoicon.sco-image-fill - else if item.aplayer - i.scoicon.sco-disc-fill - else if item.video - i.scoicon.sco-video-fill - else if item.bilibili - i.scoicon.sco-bilibili-line - else if item.link - i.scoicon.sco-links -script. - document.addEventListener('DOMContentLoaded',()=>{ - sco.initbbtalk(); - }) - document.addEventListener('pjax:complete',()=>{ - sco.initbbtalk(); - }) \ No newline at end of file diff --git a/layout/includes/widgets/home/bb/memos.pug b/layout/includes/widgets/home/bb/memos.pug deleted file mode 100644 index 4d1770e6..00000000 --- a/layout/includes/widgets/home/bb/memos.pug +++ /dev/null @@ -1,36 +0,0 @@ -script. - async function getSays() { - const bberTalk = document.querySelector('#bber-talk'); - if (!bberTalk) return; - else bberTalk.innerHTML = '
    '; - - try { - const response = await fetch('!{theme.says.mode_link}'); - const data = await response.json(); - - const aplayerRegex = /{aplayer,(.*?),(.*?)}/g; - const bilibiliRegex = /{bilibili,(.*?)}/g; - const playerRegex = /{player,(.*?)}/g; - const linkRegex = /(? { - const content = item.content.match(contentRegex, '$1').map(item => item.replace(contentRegex, '$1')); - const imageBox = item.content.match(imageRegex) ? '' : ''; - const aplayer = item.content.match(aplayerRegex) ? '' : ''; - const video = item.content.match(playerRegex) ? '' : item.content.match(bilibiliRegex) ? '' : ''; - const link = item.content.match(linkRegex) ? `` : ''; - - return `
    ${content + aplayer + video + imageBox + link}
    `; - }).join(' '); - - sco.initbbtalk(); - } catch (error) { - console.error('bbtime | ', error); - } - } - - document.addEventListener('DOMContentLoaded', getSays); - document.addEventListener('pjax:complete', getSays); diff --git a/layout/includes/widgets/home/bbTimeList.pug b/layout/includes/widgets/home/bbTimeList.pug index 42b6a325..5461b608 100644 --- a/layout/includes/widgets/home/bbTimeList.pug +++ b/layout/includes/widgets/home/bbTimeList.pug @@ -2,9 +2,17 @@ i.bber-logo.scoicon.sco-bblogo(onclick=`pjax.loadUrl('/essay/')`) .swiper-container.swiper-no-swiping.swiper-container-initialized.swiper-container-vertical.swiper-container-pointer-events#bbtalk(tabindex="-1" onclick=`pjax.loadUrl('/essay/')`) .swiper-wrapper#bber-talk - case theme.says.mode - when 'local' - include bb/local - when 'memos' - include bb/memos + each item, i in site.data.essay.essay_list.slice(0, 10) + .li-style.swiper-slide + | #{item.content} + if item.image + i.scoicon.sco-image-fill + else if item.aplayer + i.scoicon.sco-disc-fill + else if item.video + i.scoicon.sco-video-fill + else if item.bilibili + i.scoicon.sco-bilibili-line + else if item.link + i.scoicon.sco-links i.bber-gotobb.scoicon.sco-right-btn-fill(title=_p('home.bbtime.text') onclick=`pjax.loadUrl('/essay/')`) \ No newline at end of file diff --git a/layout/includes/widgets/page/says/local.pug b/layout/includes/widgets/page/says/local.pug deleted file mode 100644 index 0fee3374..00000000 --- a/layout/includes/widgets/page/says/local.pug +++ /dev/null @@ -1,44 +0,0 @@ -each item in site.data.essay.essay_list.slice(0, theme.says.strip) - li.item - if theme.says.style === 2 - .meta - img.avatar(src=theme.aside.card.author.img) - .info - span.bber_nick= config.author - time.datetime.bber_date(datetime=moment(item.date).format()) - if item.content - a.bber-reply.goComment(onclick=`sco.toTalk('${item.content}')`) - i.scoicon.sco-chat-fill - - #bber-content - p.datacont= item.content - if item.image - .bber-content-img - each img in item.image - img(src=img title="即刻短文配图") - - if item.aplayer - .bber-music - meting-js(server=item.aplayer.server type="song" id=item.aplayer.id mutex="true" preload="none" theme="var(--sco-main)" data-lrctype="0") - - if item.video - .bber-video - if item.video.player - video(src=item.video.player controls="controls" style="object-fit: cover;") - if item.video.bilibili - iframe(src='//player.bilibili.com/player.html?auto-play=0&bvid=' + item.video.bilibili scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true") - - if theme.says.style === 1 - hr - .bber-bottom - .bber-info - .bber-info-time - i.scoicon.sco-calendar-todo-fill - time.datetime(datetime=moment(item.date).format()) - if item.link - a.bber-content-link(href=url_for(item.link) title="跳转到短文指引的链接" target="_blank") - i.scoicon.sco-link-m-line - | 链接 - if item.content - a.bber-reply(onclick=`sco.toTalk('${item.content}')`) - i.scoicon.sco-chat-fill \ No newline at end of file diff --git a/layout/includes/widgets/page/says/memos.pug b/layout/includes/widgets/page/says/memos.pug deleted file mode 100644 index 45b8df14..00000000 --- a/layout/includes/widgets/page/says/memos.pug +++ /dev/null @@ -1,99 +0,0 @@ -case theme.says.style - when 1 - script. - !async function () { - const aplayerRegex = /{aplayer,(.*?),(.*?)}/g; - const linkRegex = /(? { - aplayer = item.content.match(aplayerRegex); - aplayer = aplayer ? `
    ` : null; - video = item.content.match(playerRegex); - video = video ? `
    ` : item.content.match(bilibiliRegex); - video = item.content.match(bilibiliRegex) ? `
    ` : video; - imageBox = item.content.match(imageRegex); - imageBox = imageBox ? `
    ${imageBox.map(img => ``).join('')}
    ` : ''; - const time = new Date(item.createdTs * 1000).toISOString().replace('Z', '+08:00'); - const content = item.content.match(contentRegex).map(item => item.replace(contentRegex, '$1')); - const link = item.content.match(linkRegex); - const linkHtml = link ? `链接` : ''; - const replyHtml = content ? `` : ''; - return `
  • -
    -

    ${content}

    - ${imageBox || ''} -
    - ${video || ''} - ${aplayer || ''} -
    -
    -
    -
    - - -
    - ${linkHtml} -
    - ${replyHtml} -
    -
  • `; - }).join(''); - sco.reflashEssayWaterFall(); - GLOBAL_CONFIG.lazyload.enable && utils.lazyloadImg(); - GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll(".bber-content-img img")); - changeTimeFormat(); - }(); - when 2 - script. - !async function () { - const aplayerRegex = /{aplayer,(.*?),(.*?)}/g; - const bilibiliRegex = /{bilibili,(.*?)}/g; - const playerRegex = /{player,(.*?)}/g; - const imageRegex = /!\[\]\((.*?)\)/g; - const contentRegex = /#.*?\s([^{\n]*)/g; - const response = await fetch("!{url_for(theme.says.mode_link)}"); - const data = await response.json(); - const list = data.slice(0, !{theme.says.strip}); - let aplayer, video, imageBox; - - document.querySelector('#waterfall').innerHTML = list.map(item => { - aplayer = item.content.match(aplayerRegex); - aplayer = aplayer ? `
    ` : null; - video = item.content.match(playerRegex); - video = video ? `
    ` : item.content.match(bilibiliRegex); - video = item.content.match(bilibiliRegex) ? `
    ` : video; - imageBox = item.content.match(imageRegex); - imageBox = imageBox ? `
    ${imageBox.map(img => ``).join('')}
    ` : ''; - const time = new Date(item.createdTs * 1000).toISOString().replace('Z', '+08:00'); - const content = item.content.match(contentRegex).map(item => item.replace(contentRegex, '$1')); - const replyHtml = content ? `` : ''; - return `
  • -
    - -
    - #{config.author} - -
    - ${replyHtml} -
    -
    -

    ${content}

    - ${imageBox || ''} -
    - ${video || ''} - ${aplayer || ''} -
  • `; - }).join(''); - sco.reflashEssayWaterFall(); - GLOBAL_CONFIG.lazyload.enable && utils.lazyloadImg(); - GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll(".bber-content-img img")); - changeTimeFormat(); - }(); diff --git a/layout/page.pug b/layout/page.pug index b35299e1..3a354b81 100644 --- a/layout/page.pug +++ b/layout/page.pug @@ -18,8 +18,6 @@ block content include includes/page/says when 'equipment' include includes/page/equipment - when 'rss' - include includes/page/rss when 'moment' include includes/page/moment when 'douban' diff --git a/source/js/music.js b/source/js/music.js index 2d771474..7525a6ef 100644 --- a/source/js/music.js +++ b/source/js/music.js @@ -42,15 +42,69 @@ const scoMusic = { } }, buttonlist: () => { - document.querySelector(".aplayer-lrc").addEventListener("click", () => { - const aplayerList = document.querySelector(".aplayer-list"); + const aplayerList = document.querySelector(".aplayer-list"); + if (aplayerList) { + document.querySelector(".aplayer-lrc").addEventListener("click", () => { + if (aplayerList.classList.contains("aplayer-list-hide")) { + aplayerList.classList.remove("aplayer-list-hide"); + } else { + aplayerList.classList.add("aplayer-list-hide"); + } + }); + } + }, + extractValue: (input) => { + const valueRegex = /\("([^\s]+)"\)/g; + const match = valueRegex.exec(input); + return match[1]; + }, + changeMusicBg: (isChangeBg = true) => { + const MusicBg = document.getElementById("Music-bg"); + const MusicLoading = document.getElementsByClassName("Music-loading"); - if (aplayerList.classList.contains("aplayer-list-hide")) { - aplayerList.classList.remove("aplayer-list-hide"); - } else { - aplayerList.classList.add("aplayer-list-hide"); - } - }); + if (isChangeBg) { + const musiccover = document.querySelector("#Music-page .aplayer-pic"); + const img = new Image(); + img.src = scoMusic.extractValue(musiccover.style.backgroundImage); + img.onload = () => { + MusicBg.style.backgroundImage = musiccover.style.backgroundImage; + }; + } else { + const timer = setInterval(() => { + const musiccover = document.querySelector("#Music-page .aplayer-pic"); + if (musiccover) { + MusicLoading[0].style.display = "none"; + clearInterval(timer); + document.querySelector('meting-js').aplayer.volume(0.8, true); + + scoMusic.addEventListenerChangeMusicBg(); + MusicBg.style.display = "block"; + } + }, 100); + } + }, + lrcupdate: () => { + const aplayerLrcContents = document.querySelector('.aplayer-lrc-contents'); + const currentLrc = aplayerLrcContents.querySelector('p.aplayer-lrc-current'); + + if (currentLrc) { + const currentIndex = Array.from(aplayerLrcContents.children).indexOf(currentLrc); + const translateYValue = -currentIndex * 80; + + aplayerLrcContents.style.transform = `translateY(${translateYValue}px)`; + } + }, + buttonlist: () => { + const aplayerList = document.querySelector(".aplayer-list"); + if (aplayerList) { + document.querySelector(".aplayer-lrc").addEventListener("click", () => { + if (aplayerList.classList.contains("aplayer-list-hide")) { + aplayerList.classList.remove("aplayer-list-hide"); + } else { + aplayerList.classList.add("aplayer-list-hide"); + } + }); + } }, addEventListenerChangeMusicBg: () => { const aplayer = document.getElementById("Music-page").querySelector("meting-js").aplayer; @@ -60,7 +114,6 @@ const scoMusic = { aplayer.on('timeupdate', () => { scoMusic.lrcupdate(); }); - scoMusic.buttonlist(); }, getCustomPlayList: () => { const MusicPage = document.getElementById("Music-page"); From bbaa0fc94b40eb800f8cb17f2d9b6afb8f866a23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8D=93Sco?= Date: Thu, 8 Feb 2024 17:59:09 +0800 Subject: [PATCH 5/6] release: v1.4.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e03385be..21579fc2 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-solitude", - "version": "1.4.6", + "version": "1.4.7", "description": "A beautiful, powerful, and efficient Hexo theme developed by the wleelw", "main": "package.json", "scripts": { From 7caf302db015af15bba4213b47c2d4988556e32c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8D=93Sco?= Date: Thu, 8 Feb 2024 18:14:43 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E2=9C=A8feat:=20del=20rss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/css/_page/index.styl | 2 - source/css/_page/rss.styl | 82 ------------------------------------- 2 files changed, 84 deletions(-) delete mode 100644 source/css/_page/rss.styl diff --git a/source/css/_page/index.styl b/source/css/_page/index.styl index de251335..f71049a6 100644 --- a/source/css/_page/index.styl +++ b/source/css/_page/index.styl @@ -8,8 +8,6 @@ @import "error.styl" -@import "rss.styl" - if hexo-config('moments.enable') @import "moment.styl" diff --git a/source/css/_page/rss.styl b/source/css/_page/rss.styl deleted file mode 100644 index 3313d1e2..00000000 --- a/source/css/_page/rss.styl +++ /dev/null @@ -1,82 +0,0 @@ -.rss-plan-list - display flex - width 100% - flex-direction row - flex-wrap wrap - margin-left -4px - position relative - - .rss-plan-item - border-radius 12px - display flex - flex-direction column - justify-content space-between - min-width 240px - height 240px - margin 4px auto - overflow hidden - text-decoration none - width calc(100% / 3 - 8px) - filter brightness(1) - transition .3s - - +maxWidth1024() - width calc(100% / 2 - 8px) - - &first-child - width 100% - - +maxWidth768() - width 100% - - &.rss-plan-wechat - background #27c125 - overflow hidden - - &.rss-plan-mail - background var(--sco-blue) - - &.rss-plan-rss - background var(--sco-orange) - - &:hover - filter brightness(1.1) - - img.rss-plan-icon - bottom -40px - right -10px - filter blur(0) - opacity 1 - - .rss-plan-description - font-size 16px - color var(--sco-white) - margin 26px 0 0 30px - line-height 20px - - img.rss-plan-icon - position absolute - bottom -50px - right -20px - height 140px - user-select none - -webkit-user-drag none - transition all 1.2s cubic-bezier(.39, .575, .565, 1) - transform-origin bottom right - filter blur(8px) - opacity .6 - - .rss-plan-info-group - position relative - margin 0 0 26px 30px - color var(--sco-white) - - .rss-plan-title - font-size 36px - font-weight 700 - width fit-content - line-height 1 - - .rss-plan-info - width fit-content - opacity .6 \ No newline at end of file