Skip to content

Commit

Permalink
Merge pull request #372 from everfu/dev
Browse files Browse the repository at this point in the history
v2.0.12-rc.
  • Loading branch information
everfu authored Aug 31, 2024
2 parents d1656e1 + eab0da6 commit 8e2767d
Show file tree
Hide file tree
Showing 19 changed files with 169 additions and 134 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ post:
# 文章封面取色
covercolor:
enable: false
# local: local color / api: api color
# local: local color / api: api color / ave: oss average color
mode: local
# api address / api 地址
api: https://api.qjqq.cn/api/Imgcolor?img=
Expand Down
8 changes: 7 additions & 1 deletion layout/includes/inject/body.pug
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ div
script(src=url_for(theme.cdn.swiper_js))

if theme.post_ai.enable
script(src=url_for(theme.cdn.efu_ai))
script(src=url_for(theme.cdn.post_ai))

if theme.capsule.enable || theme.music.enable || theme.says.enable
script.
Expand All @@ -74,6 +74,12 @@ div
time: !{theme.post.covercolor.time}
}
script(src=url_for(theme.cdn.cover_api))
when 'ave'
script.
const coverColorConfig = {
time: !{theme.post.covercolor.time}
}
script(src=url_for(theme.cdn.cover_ave))

if theme.loading.pace
script(src=url_for(theme.cdn.pace_js))
Expand Down
27 changes: 14 additions & 13 deletions layout/includes/widgets/page/links/banner.pug
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@
.tags-group-wrapper
- const data = site.data.links.links
- for (let i = 0; i < 2; i++)
each x in data
- var pairs = []
each y, index in x.link_list
if (index % 2 === 0)
- pairs.push([y])
else
- pairs[pairs.length - 1].push(y)
each pair in pairs
.tags-group-icon-pair
each y in pair
a.tags-group-icon(href=url_for(y.link), title=y.name)
img(src=y.avatar + (site.data.links.banner_suffix || ''), title=y.name)
span.tags-group-title=y.name
each item in [1,2]
each x in data
- var pairs = []
each y, index in x.link_list
if (index % 2 === 0)
- pairs.push([y])
else
- pairs[pairs.length - 1].push(y)
each pair in pairs
.tags-group-icon-pair
each y in pair
a.tags-group-icon(href=url_for(y.link), title=y.name)
img(src=y.avatar + (site.data.links.banner_suffix || ''), title=y.name)
span.tags-group-title=y.name
2 changes: 1 addition & 1 deletion layout/includes/widgets/post/post-ai.pug
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.post-ai
.ai-title
.ai-title-left
i.ai-title-icon.solitude.fa-solid.fa-robot
i.ai-title-icon.solitude.fab.fa-bilibili
.ai-title-text=_p('post.ai.title')
.ai-tag#ai-tag= theme.post_ai.modelName
.ai-explanation(style="display: block;")
Expand Down
2 changes: 1 addition & 1 deletion layout/includes/widgets/third-party/tianli-talk.pug
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- const {key,option,title} = theme.tianli_talk

span.needEndHide#efuTalk(onclick="togglePostChatContainer(); return false;" title=title)
i.solitude.fa-solid.fa-robot
i.solitude.fab.fa-bilibili
span.efuTalkTitle=title

script.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hexo-theme-solitude",
"version": "2.0.11",
"version": "2.0.12-rc.1",
"description": "A beautiful, powerful, and efficient Hexo theme developed by everfu.",
"main": "package.json",
"scripts": {
Expand Down
9 changes: 7 additions & 2 deletions scripts/event/cdn.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ hexo.extend.filter.register('before_generate', () => {
file: 'js/covercolor/api.js',
version
},
cover_ave: {
name: 'hexo-theme-solitude',
file: 'js/covercolor/ave.js',
version
},
music_js: {
name: 'hexo-theme-solitude',
file: 'js/music.js',
Expand All @@ -59,9 +64,9 @@ hexo.extend.filter.register('before_generate', () => {
file: 'js/tw_cn.js',
version
},
efu_ai: {
post_ai: {
name: 'hexo-theme-solitude',
file: 'js/third_party/efu_ai.min.js',
file: 'js/third_party/post_ai.min.js',
version
},
commentBarrage: {
Expand Down
8 changes: 8 additions & 0 deletions source/css/_page/music.styl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ body[data-type=music]
#page-header.not-top-img #nav .back-home-button
color var(--efu-white)

#page-header #nav #nav-right .nav-button a.console_switchbutton label i
background: var(--efu-white)

#page-header #nav #nav-right .nav-button a.console_switchbutton
&:hover
label i
background var(--efu-card-bg)

.page
.layout#content-inner
background none
Expand Down
10 changes: 6 additions & 4 deletions source/css/_post/postAI.styl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
color var(--efu-lighttext)
border-radius 8px
align-items center
padding 0 12px
user-select none

.ai-title-left
Expand Down Expand Up @@ -116,7 +115,6 @@
.ai-bottom
width 100%
margin-top 12px
padding 0 12px
display flex

.ai-tips
Expand All @@ -126,5 +124,9 @@

.ai-report
font-size 12px
color var(--efu-secondtext)
white-space nowrap
color var(--efu-secondtext) !important
white-space nowrap
border-bottom none!important

&:hover
background: none !important
2 changes: 1 addition & 1 deletion source/css/third_party/tianli_talk.styl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
background var(--efu-card-bg)
border-radius 20px
overflow hidden
padding 8px
padding 10px
color var(--efu-fontcolor)
width 42px
border var(--style-border-always)
Expand Down
Binary file removed source/img/avatar.avif
Binary file not shown.
Binary file removed source/img/happy-sticker.avif
Binary file not shown.
58 changes: 58 additions & 0 deletions source/js/covercolor/ave.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const coverColor = () => {
const path = document.getElementById("post-cover")?.src;
path ? handleApiColor(path) : setDefaultThemeColors();
}

const handleApiColor = (path) => {
const cacheGroup = JSON.parse(localStorage.getItem('Solitude')) || {};
const color = cacheGroup.postcolor?.[path]?.value;
color ? setThemeColors(color) : img2color(path);
}

const img2color = (src) => {
fetch(`${src}?imageAve`)
.then(response => response.json())
.then(({ RGB }) => {
RGB = `#${RGB.slice(2)}`;
setThemeColors(RGB);
cacheColor(src, RGB);
})
.catch(console.error);
}

const setThemeColors = (value) => {
if (!value) return setDefaultThemeColors();
const [r, g, b] = value.match(/\w\w/g).map(x => parseInt(x, 16));
const [main, op, opDeep, none] = [`${value}`, `${value}23`, `${value}dd`, `${value}00`];
document.documentElement.style.setProperty('--efu-main', main);
document.documentElement.style.setProperty('--efu-main-op', op);
document.documentElement.style.setProperty('--efu-main-op-deep', opDeep);
document.documentElement.style.setProperty('--efu-main-none', none);
adjustBrightness(r, g, b);
document.getElementById("coverdiv").classList.add("loaded");
initThemeColor();
}

const setDefaultThemeColors = () => {
const vars = ['--efu-theme', '--efu-theme-op', '--efu-theme-op-deep', '--efu-theme-none'];
vars.forEach((varName, i) => document.documentElement.style.setProperty(['--efu-main', '--efu-main-op', '--efu-main-op-deep', '--efu-main-none'][i], `var(${varName})`));
initThemeColor();
}

const cacheColor = (src, color) => {
const cacheGroup = JSON.parse(localStorage.getItem('Solitude')) || { postcolor: {} };
cacheGroup.postcolor[src] = { value: color, expiration: Date.now() + coverColorConfig.time };
localStorage.setItem('Solitude', JSON.stringify(cacheGroup));
}

const adjustBrightness = (r, g, b) => {
if (Math.round(((r * 299) + (g * 587) + (b * 114)) / 1000) < 125) {
document.querySelectorAll('.card-content').forEach(item =>
item.style.setProperty('--efu-card-bg', 'var(--efu-white)')
);
document.querySelectorAll('.author-info__sayhi').forEach(item => {
item.style.setProperty('background', 'var(--efu-white-op)');
item.style.setProperty('color', 'var(--efu-white)');
});
}
}
11 changes: 5 additions & 6 deletions source/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ const sidebarFn = () => {
});
}
const scrollFn = () => {
const innerHeight = window.innerHeight;
let initTop = 0;
const $header = document.getElementById('page-header');
const throttledScroll = utils.throttle((e) => {
const throttledScroll = utils.throttle(() => {
initThemeColor();
const currentTop = window.scrollY || document.documentElement.scrollTop;
const isDown = scrollDirection(currentTop);
Expand Down Expand Up @@ -155,10 +154,10 @@ const sco = {
$console.classList.toggle("on", this.musicPlaying);
if (this.musicPlaying) {
$meting.aplayer.play();
rm?.menuItems.music[0] && ($rm_text.textContent = GLOBAL_CONFIG.right_menu.music.stop) && ($rm_icon.className = 'solitude st-pause-fill')
(typeof rm !== 'undefined') && rm?.menuItems.music[0] && ($rm_text.textContent = GLOBAL_CONFIG.right_menu.music.stop) && ($rm_icon.className = 'solitude st-pause-fill')
} else {
$meting.aplayer.pause();
rm?.menuItems.music[0] && ($rm_text.textContent = GLOBAL_CONFIG.right_menu.music.start) && ($rm_icon.className = 'solitude st-play-fill')
(typeof rm !== 'undefined') && rm?.menuItems.music[0] && ($rm_text.textContent = GLOBAL_CONFIG.right_menu.music.start) && ($rm_icon.className = 'solitude st-play-fill')
}
},
switchCommentBarrage() {
Expand Down Expand Up @@ -598,7 +597,7 @@ class tabs {

static clickFnOfTabs() {
document.querySelectorAll('#article-container .tab > button').forEach((item) => {
item.addEventListener('click', function (e) {
item.addEventListener('click', function () {
const that = this;
const $tabItem = that.parentNode;
if (!$tabItem.classList.contains('active')) {
Expand Down Expand Up @@ -668,7 +667,7 @@ window.refreshFn = () => {
lazyload.enable && utils.lazyloadImg();
lightbox && utils.lightbox(document.querySelectorAll("#article-container img:not(.flink-avatar,.gallery-group img, .no-lightbox)"));
randomlink && randomLinksList();
post_ai && is_post && efu_ai.init();
post_ai && is_post && ai.init();
sco.switchComments();
initObserver();
if (is_home) {
Expand Down
11 changes: 2 additions & 9 deletions source/js/music.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/**
* Music Player
* @description Initialize the music player and add event listeners to control the player
*/
class ScoMusicPlayer {
class MusicPlayer {
constructor() {
this.init();
}
Expand Down Expand Up @@ -113,11 +109,8 @@ class ScoMusicPlayer {
}
}

/**
* Initialize the music player
*/
function initializeMusicPlayer() {
let exitingMusic = window.scoMusic;
if (exitingMusic) exitingMusic.destroy();
window.scoMusic = new ScoMusicPlayer();
window.scoMusic = new MusicPlayer();
}
2 changes: 1 addition & 1 deletion source/js/third_party/barrage.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions source/js/third_party/efu_ai.min.js

This file was deleted.

Loading

0 comments on commit 8e2767d

Please sign in to comment.