Skip to content

Commit

Permalink
Merge pull request #119 from wleelw/dev
Browse files Browse the repository at this point in the history
v1.4.2
  • Loading branch information
王卓Sco authored Jan 30, 2024
2 parents bfe0ae1 + 8a1deb2 commit 5ae9ae4
Show file tree
Hide file tree
Showing 39 changed files with 664 additions and 98 deletions.
55 changes: 55 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,27 @@ capsule:
server: netease # 播放列表的服务商。netease:网易云 / tencent:腾讯 / kugou:酷狗 / xiami:小米 / baidu:百度 : Music service provider. netease: Netease Cloud / tencent: Tencent / kugou: Kugou / xiaomi: Xiaomi / baidu: Baidu
type: playlist # 播放列表的类型。song:单曲 / playlist:歌单 / album:专辑 / artist:歌手 : Type of playlist. song: Single / playlist: Playlist / album: Album / artist: Singer

# 友链鱼塘
# Links fish pond
moments:
enable: false # 是否开启鱼塘 / Whether to enable fish pond
api: # https://blog.wzsco.top/circle/ # api地址 / api address
error_img: https://bu.dusays.com/2023/11/08/654af68b25bb8.jpg # 加载失败显示图片 / Loading failed display image
sort_rule: created # 排序规则:created:按创建时间排序 / updated:按更新时间排序 : Sort rule: created: Sort by creation time / updated: Sort by update time
expire_days: 1 # 缓存过期时间(天),默认为1天 / Cache expiration time (days), default is 1 day
page_init_number: 10 # 页面初始化加载数量,默认为10条 / Page initialization loading quantity, default is 10
page_turning_number: 5 # 页面翻页加载数量,默认为5条 / Page turning loading quantity, default is 5
angle: true # 鱼塘随机文章 / Fish pond random article
appjs: https://cdn.cbd.int/solitude-source@1.0.3/js/fcircle.min.js # 鱼塘js / Fish pond js
bundlejs: https://cdn.cbd.int/solitude-source/js/moment/bundle.min.js # 鱼塘js / Fish pond js
randompostjs: https://cdn.cbd.int/solitude-source/js/moment/random_post.min.js # 鱼塘js / Fish pond js

# 相册
# album
album:
enable: false # 是否开启相册 / Whether to enable album
limit: 6 # 单行显示图片数量 / Number of pictures displayed in a single line

# -------------------------
# 文章页、页面配置
# post、page settings
Expand Down Expand Up @@ -542,6 +563,35 @@ post:
api: https://img2color.wzsco.top/api?img= # api地址 / api address
time: 43200000 # api取色间隔(毫秒),默认为12小时 / api color interval (milliseconds), default is 12 hours

keyboard:
enable: false # 是否开启键盘控制 / Whether to enable keyboard control
# 键盘控制配置
# 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/'


# -------------------------
# 自定义主题

Expand Down Expand Up @@ -722,6 +772,11 @@ search:
enable: false
# algolia, local
type: algolia
# 推荐标签
# Recommended tags
tags:
# - Solitude
# - Hexo
algolia:
# hits:
# per_page: 6
Expand Down
3 changes: 2 additions & 1 deletion languages/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,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/DuoSco/Hexo-theme-solitude | Version: v1.4.1 😄'
console: 'Program: Hexo | Theme: Hexo-Theme-Solitude | Author: WangZhuoSco、YiFeng | Github: https://github.com/DuoSco/Hexo-theme-solitude | Version: v1.4.2 😄'

aside:
postcount: 'Posts :'
Expand All @@ -93,6 +93,7 @@ console:
tag_title: Find interesting areas
switch_darkmode: Day and night switching
switch_hideAside: Sidebar display control
switch_keyboard: Keyboard operation
switch_music: Music switch
archive_unit: Posts

Expand Down
3 changes: 2 additions & 1 deletion languages/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ search:

head:
noscript: 开启JavaScript才能访问本站哦~
console: '程序:Hexo | 主题:Hexo-Theme-Solitude | 作者:王卓Sco、亦封 | Github: https://github.com/DuoSco/Hexo-theme-solitude | 版本:v1.4.1 😄'
console: '程序:Hexo | 主题:Hexo-Theme-Solitude | 作者:王卓Sco、亦封 | Github: https://github.com/DuoSco/Hexo-theme-solitude | 版本:v1.4.2 😄'

aside:
postcount: '文章总数 :'
Expand All @@ -92,6 +92,7 @@ console:
tag_title: 寻找感兴趣的领域
switch_darkmode: 昼夜切换
switch_hideAside: 边栏显示控制
switch_keyboard: 键盘快捷键
switch_music: 音乐开关
archive_unit:

Expand Down
4 changes: 4 additions & 0 deletions layout/includes/console.pug
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ div#console
div.console-btn-item#consoleHideAside
a.asideSwitch(onclick="sco.switchHideAside()", title=_p('console.switch_hideAside'), href="javascript:void(0);")
i.scoicon.sco-side-bar-fill
if theme.keyboard.enable
div.console-btn-item#consoleKeyboard(onclick="sco.switchKeyboard()")
a.keyboardSwitch(title=_p('console.switch_keyboard'), href="javascript:void(0);")
i.scoicon.sco-keyboard-box-fill
if theme.capsule.enable
div.console-btn-item#consoleMusic(onclick="sco.musicToggle()")
a.music-switch(title=_p('console.switch_music'), href="javascript:void(0);")
Expand Down
2 changes: 1 addition & 1 deletion layout/includes/head/config.pug
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
apiKey: config.algolia.apiKey,
indexName: config.algolia.indexName,
hits: {
per_page: theme?.search?.algolia_search?.hits?.per_page || 10
per_page: theme?.search?.algolia?.hits?.per_page || 10
}
})
break;
Expand Down
11 changes: 6 additions & 5 deletions layout/includes/inject/body.pug
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
div
script(src=url_for(theme.cdn.main))

if theme.album.enable
script(src=url_for(theme.cdn.macy_js))

mixin katex
link(rel="stylesheet", href=url_for(theme.cdn.katex))
if theme.katex.copytex
Expand Down Expand Up @@ -84,11 +87,6 @@ div
if theme.music.enable
script(src=url_for(theme.cdn.music_js))

// gallery
if theme.gallery
script(src=url_for(theme.cdn.fj_gallery))
link(rel="stylesheet", href=url_for(theme.cdn.fj_gallery_css))

// pace 胶囊加载条(Capsule loading bar)
if theme.loading.pace
script(src=url_for(theme.cdn.pace_js))
Expand All @@ -108,6 +106,9 @@ div
!= item

div#js-pjax
if page.type === 'album' && theme.album.enable
script.
initGallery()
if page.type === 'says' && theme.says.enable
script.
window.addEventListener('resize', utils.throttle(function () {
Expand Down
65 changes: 65 additions & 0 deletions layout/includes/keyboard.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
- const list = theme.keyboard.list || []
#keyboard-tips
.keyboardTitle= '博客快捷键'
.keyboardList
each item in list
.keyboardItem
.keyGroup
.key= 'Shift'
.key= item.key
.keyContent
.content= item.name
script.
const keyboard_addKeyup = (e) => {
if (e.key === 'Shift') {
document.getElementById('keyboard-tips').classList.remove('show');
}
}

const keyboard_addKeydown = (e) => {
const keyboards = !{JSON.stringify(list)};
if (e.keyCode === 16) {
document.getElementById('keyboard-tips').classList.add('show');
}

for (let i = 0; i < keyboards.length; i++) {
if (keyboards[i].url) {
if (keyboards[i].url.startsWith('http')) {
if (e.key === keyboards[i].key) {
window.open(keyboards[i].url);
}
} else {
if (e.key === keyboards[i].key) {
pjax.loadUrl(keyboards[i].url);
}
}
} else if (keyboards[i].sco) {
if (e.key === keyboards[i].key) {
sco[keyboards[i].sco]();
}
} else if (keyboards[i].func) {
if (e.key === keyboards[i].key) {
window[keyboards[i].func]();
}
}
}
}

function openKeyboard() {

window.addEventListener('keyup', keyboard_addKeyup);

window.addEventListener('keydown', keyboard_addKeydown);
}
function closeKeyboard() {

window.removeEventListener('keyup', keyboard_addKeyup);

window.removeEventListener('keydown', keyboard_addKeydown);
}

var sco_keyboards = localStorage.getItem('keyboard') === 'true'
if (sco_keyboards) {
openKeyboard();
document.getElementById('consoleKeyboard').classList.add('on');
}
4 changes: 4 additions & 0 deletions layout/includes/layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ html(lang=config.language, data-theme="light")
// sidebar
include ./sidebar.pug

// keyboard
if theme.keyboard.enable
include ./keyboard.pug

#body-wrap(class = is_post() ? 'post' : 'page')
include ./header.pug

Expand Down
56 changes: 56 additions & 0 deletions layout/includes/page/album.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
include ../widgets/page/banner

- var gallery = site.data.gallery.gallery
- var album = gallery.find(item => item.album = page.album)
- var {limit} = theme.album

if album
#album
#sco-container
if album.json
script.
function initGallery() {
let macy = Macy({ container: '#sco-container', trueOrder: false, waitForImages: true, margin: 5, columns: !{limit}, breakAt: { 1200: 5, 940: 3, 520: 2, 400: 1 }})
macy.runOnImageLoad(function () {
setTimeout(function () {
GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll(".sco-gallery-item img"));
macy.recalculate(true)
}, 500);
}, true)
}
(async function () {
await fetch('!{url_for(album.json)}')
.then(res => res.json())
.then(data => {
let html = ''
data = data.sort((a, b) => b.date - a.date)
data.forEach(item => {
html += `
<div class="sco-gallery-item">
<span class="locate">${item.locate}</span>
<img class="sco-gallery-image" src="${item.image}" alt="${item.content}">
</div>
`
})
document.querySelector('#sco-container').innerHTML = html
GLOBAL_CONFIG.lazyload.enable && utils.lazyloadImg();
initGallery()
})
})()

else
each item in album.items.sort((a, b) => b.date - a.date)
.sco-gallery-item
span.locate= item.locate
img.sco-gallery-image(src=item.image, alt=item.content)
script.
function initGallery(){
let macy = Macy({ container: '#sco-container', trueOrder: false, waitForImages: true, margin: 5, columns: !{limit}, breakAt: { 1200: 5, 940: 3, 520: 2, 400: 1 }})
macy.runOnImageLoad(function () {
setTimeout(function () {
GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll(".sco-gallery-item img"));
macy.recalculate(true)
}, 500);
}, true)
}
document.addEventListener('DOMContentLoaded', initGallery);
11 changes: 11 additions & 0 deletions layout/includes/page/gallery.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include ../widgets/page/banner

- var gallery = site.data.gallery.gallery

if theme.album.enable && gallery
#gallery
each item in gallery
.gallery-item(onclick="pjax.loadUrl('/" + item.album + "/')")
img.cover(src=item.cover)
span.title= item.class_name
span.desc= item.descr
2 changes: 2 additions & 0 deletions layout/includes/page/links.pug
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.flink#banners
include ../widgets/page/links/banner
if theme.moments.angle
include ../widgets/page/moments/angle
.flink#article-container
each data in site.data.links.links
h2= data.class_name + " (" + data.link_list.length + ")"
Expand Down
28 changes: 28 additions & 0 deletions layout/includes/page/moment.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
include ../widgets/page/banner
if theme.moments.angle
include ../widgets/page/moments/angle

.title-h2-a
.title-h2-a-left
h2(style="padding-top: 0;margin:0.6rem 0 0.6rem;") 🐟 鱼塘
.title-h2-a-right
span 以下内容自动生成,未经过审核

div#hexo-circle-of-friends-root
script.
let UserConfig = {
// 填写你的api地址
private_api_url: '!{theme.moments.api}',
// 默认加载文章数
page_init_number: !{theme.moments.page_init_number},
// 点击加载更多时,一次最多加载几篇文章,默认10
page_turning_number: !{theme.moments.page_turning_number},
// 头像加载失败时,默认头像地址
error_img: '!{theme.moments.error_img}',
// 进入页面时第一次的排序规则
sort_rule: '!{theme.moments.sort_rule}',
// 本地文章缓存数据过期时间(天)
expire_days: !{theme.moments.expire_days},
}
script(src=url_for(theme.moments.appjs))
script(src=url_for(theme.moments.bundlejs))
19 changes: 19 additions & 0 deletions layout/includes/widgets/page/moments/angle.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.title-h2-a
.title-h2-a-left
h2(style="padding-top: 0;margin:0.6rem 0 0.6rem;") 🎣 钓鱼
a#random-post-start(href="javascript:fetchRandomPost();", style="transition-duration: 0.3s; transform: rotate(63000deg); opacity: 1;", data-pjax-state="")
i.scoicon.sco-restart-line
.title-h2-a-right
if page.type !== 'links'
a.random-post-all(href="/links/", data-pjax-state="") 全部友链

#random-post

script.
var fdata = {
apiurl: "#{theme.moments.api}",
defaultFish: 100,
hungryFish: 100,
}

script(src=url_for(theme.moments.randompostjs))
2 changes: 1 addition & 1 deletion layout/includes/widgets/page/says/local.pug
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ each item in site.data.essay.essay_list.slice(0, theme.says.strip)
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?autop-lay=0&bvid=' + item.video.bilibili scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true")
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
Expand Down
Loading

0 comments on commit 5ae9ae4

Please sign in to comment.