hexo-theme-solitude 1.4.1 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +1 -1
- package/README.md +1 -1
- package/README_EN.md +1 -1
- package/_config.yml +68 -3
- package/languages/en-US.yml +32 -2
- package/languages/zh-CN.yml +33 -2
- package/languages/zh-TW.yml +147 -0
- package/layout/includes/console.pug +4 -0
- package/layout/includes/footer.pug +1 -1
- package/layout/includes/head/config.pug +16 -3
- package/layout/includes/inject/body.pug +18 -9
- package/layout/includes/keyboard.pug +65 -0
- package/layout/includes/layout.pug +8 -0
- package/layout/includes/page/album.pug +39 -0
- package/layout/includes/page/gallery.pug +11 -0
- package/layout/includes/page/links.pug +2 -0
- package/layout/includes/page/moment.pug +28 -0
- package/layout/includes/page/music.pug +1 -4
- package/layout/includes/page/says.pug +1 -3
- package/layout/includes/widgets/home/bb/json.pug +2 -1
- package/layout/includes/widgets/home/bb/local.pug +2 -3
- package/layout/includes/widgets/home/bb/memos.pug +2 -1
- package/layout/includes/widgets/page/about/authorinfo.pug +1 -1
- package/layout/includes/widgets/page/about/hobbies.pug +2 -2
- package/layout/includes/widgets/page/about/motto.pug +17 -15
- package/layout/includes/widgets/page/about/skillsinfo.pug +38 -36
- package/layout/includes/widgets/page/about/tenyear.pug +1 -1
- package/layout/includes/widgets/page/moments/angle.pug +19 -0
- package/layout/includes/widgets/page/says/json.pug +3 -3
- package/layout/includes/widgets/page/says/local.pug +2 -2
- package/layout/includes/widgets/rightside/index.pug +33 -22
- package/layout/includes/widgets/third-party/search/algolia-search.pug +20 -15
- package/layout/includes/widgets/third-party/search/local-search.pug +3 -0
- package/layout/page.pug +6 -0
- package/package.json +1 -1
- package/plugins.yml +12 -4
- package/scripts/event/cdn.js +5 -0
- package/scripts/event/init.js +18 -19
- package/scripts/event/page.js +0 -5
- package/scripts/filter/checkThemeConfig.js +23 -7
- package/scripts/helper/related_post.js +0 -6
- package/scripts/helper/stylus.js +8 -3
- package/source/css/_global/index.styl +1 -5
- package/source/css/_layout/basic.styl +0 -1
- package/source/css/_layout/index.styl +54 -34
- package/source/css/_mode/index.styl +6 -1
- package/source/css/_page/about/index.styl +26 -16
- package/source/css/_page/gallery/index.styl +99 -0
- package/source/css/_page/index.styl +5 -1
- package/source/css/_page/moment.styl +4 -2
- package/source/css/_widgets/_comment/twikoo.styl +21 -18
- package/source/css/_widgets/_mixins/keyboard.styl +59 -0
- package/source/css/_widgets/_search/algolia-search.styl +37 -16
- package/source/css/_widgets/_search/local-search.styl +18 -2
- package/source/css/_widgets/_tags/link.styl +1 -1
- package/source/css/_widgets/index.styl +4 -0
- package/source/css/index.styl +0 -1
- package/source/js/covercolor/api.js +10 -6
- package/source/js/covercolor/local.js +88 -13
- package/source/js/main.js +15 -1
- package/source/js/rightside.js +159 -342
- package/source/js/search/algolia.js +4 -2
- package/source/js/search/local.js +3 -1
- package/source/js/tw_cn.js +76 -0
- package/source/js/utils.js +1 -1
- package/layout/includes/page/not_configured.pug +0 -18
- package/scripts/helper/cdn.js +0 -12
- package/source/img/avatar.png +0 -0
@@ -12,10 +12,13 @@
|
|
12
12
|
border var(--style-border)
|
13
13
|
transition 0.3s
|
14
14
|
border-radius 8px
|
15
|
+
animation slide-in .6s ease 0s 1 normal none running
|
15
16
|
|
16
17
|
&:hover
|
17
18
|
border var(--style-border-hover)
|
18
19
|
box-shadow var(--sco-shadow-theme)
|
20
|
+
+maxWidth768()
|
21
|
+
border none
|
19
22
|
|
20
23
|
+maxWidth768()
|
21
24
|
top 0
|
@@ -23,6 +26,7 @@
|
|
23
26
|
margin 0
|
24
27
|
width 100%
|
25
28
|
height 100%
|
29
|
+
border 0
|
26
30
|
|
27
31
|
.search-dialog-title
|
28
32
|
font-weight 700
|
@@ -116,7 +120,7 @@
|
|
116
120
|
max-width 100%
|
117
121
|
width 100%
|
118
122
|
padding-top 8px
|
119
|
-
|
123
|
+
padding-bottom 8px
|
120
124
|
|
121
125
|
input
|
122
126
|
height 100%
|
@@ -138,4 +142,16 @@
|
|
138
142
|
backdrop-filter blur(12px)
|
139
143
|
-webkit-backdrop-filter blur(12px)
|
140
144
|
transform translateZ(0)
|
141
|
-
background var(--sco-maskbgdeep)
|
145
|
+
background var(--sco-maskbgdeep)
|
146
|
+
|
147
|
+
#search-hits
|
148
|
+
.tag-list
|
149
|
+
padding 4px 8px
|
150
|
+
border-radius 8px
|
151
|
+
margin-right 0.5rem
|
152
|
+
margin-top 0.5rem
|
153
|
+
border var(--style-border-always)
|
154
|
+
|
155
|
+
&:hover
|
156
|
+
background var(--sco-main)
|
157
|
+
color var(--sco-white)
|
package/source/css/index.styl
CHANGED
@@ -2,12 +2,17 @@ const coverColor = () => {
|
|
2
2
|
const path = document.getElementById("post-cover")?.src;
|
3
3
|
if (path) {
|
4
4
|
handleApiColor(path);
|
5
|
+
} else {
|
6
|
+
document.documentElement.style.setProperty('--sco-main', 'var(--sco-theme)');
|
7
|
+
document.documentElement.style.setProperty('--sco-main-op', 'var(--sco-theme-op)');
|
8
|
+
document.documentElement.style.setProperty('--sco-main-op-deep', 'var(--sco-theme-op-deep)');
|
9
|
+
document.documentElement.style.setProperty('--sco-main-none', 'var(--sco-theme-none)');
|
10
|
+
initThemeColor()
|
5
11
|
}
|
6
12
|
}
|
7
13
|
|
8
14
|
function handleApiColor(path) {
|
9
15
|
const cacheGroup = JSON.parse(localStorage.getItem('Solitude')) || {};
|
10
|
-
console.log(cacheGroup)
|
11
16
|
if (cacheGroup.postcolor && cacheGroup.postcolor[path]) {
|
12
17
|
const color = cacheGroup.postcolor[path].value;
|
13
18
|
const [r, g, b] = color.match(/\w\w/g).map(x => parseInt(x, 16));
|
@@ -26,14 +31,13 @@ function img2color(src) {
|
|
26
31
|
const [r, g, b] = color.match(/\w\w/g).map(x => parseInt(x, 16));
|
27
32
|
setThemeColors(color, r, g, b);
|
28
33
|
const expirationTime = Date.now() + coverColorConfig.time;
|
29
|
-
const cacheGroup =
|
34
|
+
const cacheGroup = JSON.parse(localStorage.getItem('Solitude')) || {};
|
30
35
|
cacheGroup.postcolor = cacheGroup.postcolor || {};
|
31
36
|
cacheGroup.postcolor[src] = {value: color, expiration: expirationTime};
|
32
37
|
localStorage.setItem('Solitude', JSON.stringify(cacheGroup));
|
33
38
|
})
|
34
39
|
.catch(error => {
|
35
40
|
console.error('请检查API是否正常!\n' + error);
|
36
|
-
setThemeColors();
|
37
41
|
});
|
38
42
|
}
|
39
43
|
|
@@ -45,14 +49,14 @@ function setThemeColors(value, r = null, g = null, b = null) {
|
|
45
49
|
document.documentElement.style.setProperty('--sco-main-none', value + '00');
|
46
50
|
|
47
51
|
if (r && g && b) {
|
48
|
-
|
52
|
+
let brightness = Math.round(((parseInt(r) * 299) + (parseInt(g) * 587) + (parseInt(b) * 114)) / 1000);
|
49
53
|
if (brightness < 125) {
|
50
|
-
|
54
|
+
let cardContents = document.getElementsByClassName('card-content');
|
51
55
|
for (let i = 0; i < cardContents.length; i++) {
|
52
56
|
cardContents[i].style.setProperty('--sco-card-bg', 'var(--sco-white)');
|
53
57
|
}
|
54
58
|
|
55
|
-
|
59
|
+
let authorInfo = document.getElementsByClassName('author-info__sayhi');
|
56
60
|
for (let i = 0; i < authorInfo.length; i++) {
|
57
61
|
authorInfo[i].style.setProperty('background', 'var(--sco-white-op)');
|
58
62
|
authorInfo[i].style.setProperty('color', 'var(--sco-white)');
|
@@ -1,21 +1,26 @@
|
|
1
|
-
|
1
|
+
const coverColor = () => {
|
2
2
|
const path = document.getElementById("post-cover")?.src;
|
3
|
-
|
4
3
|
if (path) {
|
5
4
|
localColor(path);
|
5
|
+
} else {
|
6
|
+
document.documentElement.style.setProperty('--sco-main', 'let(--sco-theme)');
|
7
|
+
document.documentElement.style.setProperty('--sco-main-op', 'let(--sco-theme-op)');
|
8
|
+
document.documentElement.style.setProperty('--sco-main-op-deep', 'let(--sco-theme-op-deep)');
|
9
|
+
document.documentElement.style.setProperty('--sco-main-none', 'let(--sco-theme-none)');
|
10
|
+
initThemeColor()
|
6
11
|
}
|
7
12
|
}
|
8
13
|
|
9
|
-
|
14
|
+
const localColor = (path) => {
|
10
15
|
const img = new Image();
|
11
16
|
img.crossOrigin = "Anonymous";
|
12
17
|
img.onload = function () {
|
13
18
|
const canvas = document.createElement("canvas");
|
14
|
-
canvas.width =
|
15
|
-
canvas.height =
|
19
|
+
canvas.width = img.width;
|
20
|
+
canvas.height = img.height;
|
16
21
|
const ctx = canvas.getContext("2d");
|
17
|
-
ctx.drawImage(
|
18
|
-
const data = ctx.getImageData(0, 0,
|
22
|
+
ctx.drawImage(img, 0, 0);
|
23
|
+
const data = ctx.getImageData(0, 0, img.width, img.height).data;
|
19
24
|
const {r, g, b} = calculateRGB(data);
|
20
25
|
let value = rgbToHex(r, g, b);
|
21
26
|
if (getContrastYIQ(value) === "light") {
|
@@ -23,9 +28,26 @@ function localColor(path) {
|
|
23
28
|
}
|
24
29
|
setThemeColors(value, r, g, b);
|
25
30
|
};
|
31
|
+
img.onerror = function () {
|
32
|
+
console.error('图片加载失败');
|
33
|
+
};
|
26
34
|
img.src = path;
|
27
35
|
}
|
28
36
|
|
37
|
+
function calculateRGB(data) {
|
38
|
+
let r = 0, g = 0, b = 0;
|
39
|
+
const step = 5;
|
40
|
+
for (let i = 0; i < data.length; i += 4 * step) {
|
41
|
+
r += data[i];
|
42
|
+
g += data[i + 1];
|
43
|
+
b += data[i + 2];
|
44
|
+
}
|
45
|
+
r = Math.floor(r / (data.length / 4 / step));
|
46
|
+
g = Math.floor(g / (data.length / 4 / step));
|
47
|
+
b = Math.floor(b / (data.length / 4 / step));
|
48
|
+
return {r, g, b};
|
49
|
+
}
|
50
|
+
|
29
51
|
function rgbToHex(r, g, b) {
|
30
52
|
return "#" + [r, g, b].map(x => x.toString(16).padStart(2, '0')).join('');
|
31
53
|
}
|
@@ -47,12 +69,12 @@ function LightenDarkenColor(col, amt) {
|
|
47
69
|
}
|
48
70
|
|
49
71
|
function getContrastYIQ(hexcolor) {
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
72
|
+
let colorrgb = colorRgb(hexcolor);
|
73
|
+
let colors = colorrgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
74
|
+
let red = colors[1];
|
75
|
+
let green = colors[2];
|
76
|
+
let blue = colors[3];
|
77
|
+
let brightness = (red * 299) + (green * 587) + (blue * 114);
|
56
78
|
brightness = brightness / 255000;
|
57
79
|
return brightness >= 0.5 ? "light" : "dark";
|
58
80
|
}
|
@@ -82,4 +104,57 @@ function colorRgb(str) {
|
|
82
104
|
} else {
|
83
105
|
return sColor;
|
84
106
|
}
|
107
|
+
}
|
108
|
+
|
109
|
+
function setThemeColors(value, r = null, g = null, b = null) {
|
110
|
+
const cardContents = document.getElementsByClassName('card-content');
|
111
|
+
const authorInfo = document.getElementsByClassName('author-info__sayhi');
|
112
|
+
|
113
|
+
if (value) {
|
114
|
+
document.documentElement.style.setProperty('--sco-main', value);
|
115
|
+
document.documentElement.style.setProperty('--sco-main-op', value + '23');
|
116
|
+
document.documentElement.style.setProperty('--sco-main-op-deep', value + 'dd');
|
117
|
+
document.documentElement.style.setProperty('--sco-main-none', value + '00');
|
118
|
+
|
119
|
+
if (r && g && b) {
|
120
|
+
let brightness = Math.round(((parseInt(r) * 299) + (parseInt(g) * 587) + (parseInt(b) * 114)) / 1000);
|
121
|
+
for (let i = 0; i < cardContents.length; i++) {
|
122
|
+
cardContents[i].style.setProperty('--sco-card-bg', 'let(--sco-white)');
|
123
|
+
}
|
124
|
+
|
125
|
+
for (let i = 0; i < authorInfo.length; i++) {
|
126
|
+
authorInfo[i].style.setProperty('background', 'let(--sco-white-op)');
|
127
|
+
authorInfo[i].style.setProperty('color', 'let(--sco-white)');
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
document.getElementById("coverdiv").classList.add("loaded");
|
132
|
+
initThemeColor();
|
133
|
+
} else {
|
134
|
+
document.documentElement.style.setProperty('--sco-main', 'let(--sco-theme)');
|
135
|
+
document.documentElement.style.setProperty('--sco-main-op', 'let(--sco-theme-op)');
|
136
|
+
document.documentElement.style.setProperty('--sco-main-op-deep', 'let(--sco-theme-op-deep)');
|
137
|
+
document.documentElement.style.setProperty('--sco-main-none', 'let(--sco-theme-none)');
|
138
|
+
initThemeColor();
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
function initThemeColor() {
|
143
|
+
const currentTop = window.scrollY || document.documentElement.scrollTop;
|
144
|
+
let themeColor;
|
145
|
+
if (currentTop > 0) {
|
146
|
+
themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-card-bg');
|
147
|
+
} else if (PAGE_CONFIG.is_post) {
|
148
|
+
themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-main');
|
149
|
+
} else {
|
150
|
+
themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-background');
|
151
|
+
}
|
152
|
+
changeThemeColor(themeColor);
|
153
|
+
}
|
154
|
+
|
155
|
+
function changeThemeColor(color) {
|
156
|
+
const meta = document.querySelector('meta[name="theme-color"]');
|
157
|
+
if (meta) {
|
158
|
+
meta.setAttribute('content', color);
|
159
|
+
}
|
85
160
|
}
|
package/source/js/main.js
CHANGED
@@ -281,6 +281,20 @@ let sco = {
|
|
281
281
|
htmlClassList.toggle("hide-aside");
|
282
282
|
htmlClassList.contains("hide-aside") ? document.querySelector("#consoleHideAside").classList.add("on") : document.querySelector("#consoleHideAside").classList.remove("on");
|
283
283
|
},
|
284
|
+
switchKeyboard: function() {
|
285
|
+
sco_keyboards = !sco_keyboards;
|
286
|
+
const consoleKeyboard = document.querySelector("#consoleKeyboard");
|
287
|
+
if (sco_keyboards) {
|
288
|
+
consoleKeyboard.classList.add("on");
|
289
|
+
openKeyboard()
|
290
|
+
localStorage.setItem("keyboard", true);
|
291
|
+
} else {
|
292
|
+
closeKeyboard()
|
293
|
+
consoleKeyboard.classList.remove("on");
|
294
|
+
localStorage.setItem("keyboard", false);
|
295
|
+
document.getElementById('keyboard-tips')?.classList.remove('show')
|
296
|
+
}
|
297
|
+
},
|
284
298
|
initConsoleState: function () {
|
285
299
|
document.documentElement.classList.contains("hide-aside") ? document.querySelector("#consoleHideAside").classList.add("on") : document.querySelector("#consoleHideAside").classList.remove("on")
|
286
300
|
},
|
@@ -672,7 +686,7 @@ let sco = {
|
|
672
686
|
element.value = "donotreply@examp.com";
|
673
687
|
element.dispatchEvent(new Event("input"));
|
674
688
|
});
|
675
|
-
}
|
689
|
+
},
|
676
690
|
}
|
677
691
|
|
678
692
|
class hightlight {
|