Skip to content

Commit

Permalink
Merge pull request #292 from valor-x/dev
Browse files Browse the repository at this point in the history
feat✨
  • Loading branch information
everfu committed May 24, 2024
2 parents 6275527 + 275c588 commit c0717da
Show file tree
Hide file tree
Showing 19 changed files with 148 additions and 39 deletions.
12 changes: 12 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,18 @@ right_menu:
# class:
# icon: st-afdian-line

# 哀悼模式,网页黑白
# Mourning mode, web page black and white
memorial:
enable: false
# 日期, (M-D)
# Date, (M-D)
# eg: 7-8, 9-18, 12-13 ...
date:
- "7-8" #七八卢沟桥事变
- "9-18" #九一八事变/建军节
- "12-13" #南京国家公祭日

# CDN
# Don't modify the following settings unless you know how they work
# 非必要请不要修改
Expand Down
2 changes: 2 additions & 0 deletions languages/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ aside:
toc: Table of contents
tagmore: View all
avatar: Avatar
hello: Long time no see,
back: Welcome back again,
sticker: Mood sticker
newpost: New posts
card:
Expand Down
2 changes: 2 additions & 0 deletions languages/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ aside:
toc: Table of contents
tagmore: View all
avatar: Avatar
hello: Long time no see,
back: Welcome back again,
sticker: Mood sticker
newpost: New posts
card:
Expand Down
2 changes: 2 additions & 0 deletions languages/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ aside:
toc: 文章目录
tagmore: 查看全部
avatar: 头像
hello: 好久不见,
back: 欢迎再次回来,
sticker: 心情贴纸
newpost: 最近发布
card:
Expand Down
2 changes: 2 additions & 0 deletions languages/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ aside:
toc: 文章目錄
tagmore: 查看全部
avatar: 头像
hello: 好久不見,
back: 歡迎再次回來,
sticker: 心情贴纸
newpost: 最近发布
card:
Expand Down
5 changes: 5 additions & 0 deletions layout/includes/head/config.pug
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
}
const sayhello2 = theme.aside?.card?.sayhello2?.map(item => `"${item}"`) || [];
const [hello_prefix, hello_back] = [_p('aside.hello'), _p('aside.back')];
let comment = false
Expand Down Expand Up @@ -149,6 +150,10 @@ script.
goodnight: '!{theme.aside.card.sayhello.goodnight}',
},
sayhello2: [!{sayhello2}],
sayhello3: {
prefix: '!{hello_prefix}',
back: '!{hello_back}',
},
},
covercolor: {
enable: !{theme.post.covercolor.enable}
Expand Down
13 changes: 12 additions & 1 deletion layout/includes/inject/head.pug
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,23 @@ include ../head/pwa.pug

script.
console.log(
"%c Program: Hexo %c Theme: Solitude %c Version: v1.11.0",
"%c Program: Hexo %c Theme: Solitude %c Version: v1.11.1",
"border-radius:5px 0 0 5px;padding: 5px 10px;color:white;background:#ff3842;",
"padding: 5px 10px;color:white;background:#3e9f50;",
"padding: 5px 10px;color:white;background:#0084ff;border-radius:0 5px 5px 0",
)

if theme.memorial.enable
script.
let mdate = "!{theme.memorial.date}";
mdate = (mdate.split(","));
let ndate = new Date();
for (let i of mdate) {
if (i == (ndate.getMonth()+1) + "-" + (ndate.getDate())) {
document.documentElement.classList.add('memorial');
}
}

if theme.extends.head
each item in theme.extends.head
!= item
Expand Down
4 changes: 4 additions & 0 deletions layout/includes/page/says.pug
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ if theme.says.enable
.bber-info-time
i.solitude.st-calendar-todo-fill
time.datetime(datetime=moment(item.date).format())
if item.location
.bber-info-location
i.solitude.st-map-pin-fill
| #{item.location}
if item.link
a.bber-content-link(href=url_for(item.link) target="_blank")
i.solitude.st-link-m-line
Expand Down
67 changes: 47 additions & 20 deletions layout/includes/widgets/page/about/other.pug
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,53 @@
#statistic
.post-tips
= _p('about.other.tj.post_tip')
a(href="https://v6.51.la/") 51la网站统计

script.
fetch("#{tj.url}")
.then(res => res.text())
.then(data => {
const title = ["最近活跃", "今日人数", "今日访问", "昨日人数", "昨日访问", "本月访问", "总访问量"];
let num = data.match(/(<\/span><span>).*?(\/span><\/p>)/g);
num = num.map(el => {
let val = el.replace(/(<\/span><span>)/g, "");
return val.replace(/(<\/span><\/p>)/g, "");
});
const s = document.getElementById("statistic");
let html = '';
for (let i = 0; i < num.length; i++) {
if (i === 0 || i === num.length - 1) continue;
html += `<div><span>${title[i]}</span><span id="${title[i]}">${num[i]}</span></div>`;
}
s.innerHTML = html;
});
case tj.provider
when '51la'
a(href="https://v6.51.la/") 51la网站统计
when 'baidu'
a(href="https://tongji.baidu.com/") 百度统计
if tj.button
.banner-button-group
a.banner-button(href=url_for(tj.button_link))
i.solitude.st-right-btn-fill
span.banner-button-text= tj.button_text

case tj.provider
when '51la'
script.
fetch("#{tj.url}")
.then(res => res.text())
.then(data => {
const title = ["最近活跃", "今日人数", "今日访问", "昨日人数", "昨日访问", "本月访问", "总访问量"];
let num = data.match(/(<\/span><span>).*?(\/span><\/p>)/g);
num = num.map(el => {
let val = el.replace(/(<\/span><span>)/g, "");
return val.replace(/(<\/span><\/p>)/g, "");
});
const s = document.getElementById("statistic");
let html = '';
for (let i = 0; i < num.length; i++) {
if (i === 0 || i === num.length - 1) continue;
html += `<div><span>${title[i]}</span><span id="${title[i]}">${num[i]}</span></div>`;
}
s.innerHTML = html;
});
when 'baidu'
script.
fetch("#{tj.url}")
.then(res => res.json())
.then(data => {
const title = {"today_uv": "今日人数", "today_pv": "今日访问", "yesterday_uv": "昨日人数", "yesterday_pv": "昨日访问", "last_month_pv": "最近月访问", "last_year_pv": "最近年访问"};

let s = document.getElementById("statistic");

for (let key in data) {
if (data.hasOwnProperty(key) && title[key]) {
s.innerHTML += `<div><span>${title[key]}</span><span id="${key}">${data[key]}</span></div>`;
}
}
});


if oneself
style.
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": "1.11.0",
"version": "1.11.1",
"description": "A beautiful, powerful, and efficient Hexo theme developed by EverFu.",
"main": "package.json",
"scripts": {
Expand Down
10 changes: 9 additions & 1 deletion source/css/_global/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -422,4 +422,12 @@ span.tags-punctuation::before

#post-info &
font-size 14px
line-height 32px
line-height 32px

if hexo-config('memorial.enable')
.memorial
-webkit-filter grayscale(100%)
-moz-filter grayscale(100%)
-ms-filter grayscale(100%)
-o-filter grayscale(100%)
filter grayscale(100%)
3 changes: 3 additions & 0 deletions source/css/_layout/footer.styl
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@
padding 0 8px
margin 0 4px

.footer-bar-link
margin 0

.footer-bar-link
margin 0 4px
color var(--efu-fontcolor)
Expand Down
3 changes: 2 additions & 1 deletion source/css/_layout/other.styl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ span.tags-punctuation
color var(--efu-gray)
font-size 14px;
position absolute
bottom 2rem
bottom 1rem
left 2rem

+maxWidth768()
Expand All @@ -22,6 +22,7 @@ span.tags-punctuation
a
color var(--efu-gray)
border none
margin-left 4px

&:hover
color var(--efu-main)
2 changes: 1 addition & 1 deletion source/css/_page/_about/skills.styl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
transition .3s

.tags-group-wrapper
margin-top 20px
margin-top 40px
display flex
flex-wrap nowrap
animation rowleft 60s linear infinite
Expand Down
2 changes: 1 addition & 1 deletion source/css/_page/_about/statistic.styl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
justify-content space-between
flex-direction row
flex-wrap wrap
margin-top 1rem
margin-top 4px
margin-bottom 2rem

div
Expand Down
3 changes: 3 additions & 0 deletions source/css/_page/_home/home-top.styl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
+maxWidth1200()
overflow-x auto

&::-webkit-scrollbar
display none

+minWidth1201()
display flex
flex-direction row
Expand Down
7 changes: 1 addition & 6 deletions source/css/_page/other.styl
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,6 @@ div#banners
font-weight 700
box-shadow var(--efu-shadow-blackdeep)

#page &
+maxWidth768()
width 50px
height 50px

&:nth-child(even)
margin-top 1rem
transform translate(-60px)
Expand Down Expand Up @@ -224,7 +219,7 @@ div#banners

.banner-button-group
position absolute
bottom 1.5rem
bottom 1rem
right 2rem

.banner-button
Expand Down
5 changes: 3 additions & 2 deletions source/css/_page/says.styl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ if hexo-config('says.enable')
.fa-rectangles-mixed
margin-right 8px

.bber-info-time
.bber-info-time, .bber-info-location
margin-right .5rem
color var(--efu-fontcolor)
font-size .7rem
background-color var(--efu-gray-op)
Expand All @@ -131,7 +132,7 @@ if hexo-config('says.enable')

.bber-content-link
display flex
margin-left .5rem
margin-right .5rem
color var(--efu-secondtext)
font-size .7rem
align-items center
Expand Down
41 changes: 36 additions & 5 deletions source/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ const handleThemeChange = mode => {

// lastSayHello 上次打招呼的内容
let lastSayHello = "";
// 用于记录标签页是否被隐藏,从而改变下次执行打招呼的内容
let wasPageHidden = false;
// musicPlaying 是否正在播放音乐
let musicPlaying = false
// is_rm 是否启用右键菜单
Expand Down Expand Up @@ -391,12 +393,35 @@ let sco = {
if (el) {
const hours = new Date().getHours();
const lang = GLOBAL_CONFIG.aside.sayhello;

const localData = getLocalData(['twikoo', 'WALINE_USER_META', 'WALINE_USER', '_v_Cache_Meta', 'ArtalkUser']);

function getLocalData(keys) {
for (let key of keys) {
const data = localStorage.getItem(key);
if (data) {
console.log(key, data);
return JSON.parse(data);
}
}
return null;
};
const nick = localData ? (localData.nick ? localData.nick : localData.display_name) : null;

let prefix;
if (wasPageHidden) {
prefix = GLOBAL_CONFIG.aside.sayhello3.back + nick;
wasPageHidden = false;
} else {
prefix = GLOBAL_CONFIG.aside.sayhello3.prefix + nick;
}

const greetings = [
{start: 0, end: 5, text: lang.goodnight},
{start: 6, end: 10, text: lang.morning},
{start: 11, end: 14, text: lang.noon},
{start: 15, end: 18, text: lang.afternoon},
{start: 19, end: 24, text: lang.night},
{start: 0, end: 5, text: nick ? prefix : lang.goodnight},
{start: 6, end: 10, text: nick ? prefix : lang.morning},
{start: 11, end: 14, text: nick ? prefix : lang.noon},
{start: 15, end: 18, text: nick ? prefix : lang.afternoon},
{start: 19, end: 24, text: nick ? prefix : lang.night},
];
const greeting = greetings.find(g => hours >= g.start && hours <= g.end);
el.innerText = greeting.text;
Expand Down Expand Up @@ -804,6 +829,12 @@ window.refreshFn = () => {
document.addEventListener('DOMContentLoaded', () => {
[addCopyright, sco.initConsoleState, window.refreshFn, asideStatus, () => window.onscroll = percent].forEach(fn => fn());
});
// 监听切换标签页
document.addEventListener('visibilitychange', () => {
if (document.hidden) {
wasPageHidden = true;
}
});
// 一些快捷键绑定
window.onkeydown = e => {
const {keyCode, ctrlKey, shiftKey} = e;
Expand Down

0 comments on commit c0717da

Please sign in to comment.