hexo-theme-solitude 2.1.6 → 2.1.7
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/_config.yml +15 -19
- package/languages/default.yml +173 -173
- package/layout/archive.pug +3 -1
- package/layout/category.pug +3 -1
- package/layout/includes/rightmenu.pug +6 -5
- package/layout/includes/widgets/third-party/hot/artalk.pug +56 -0
- package/layout/includes/widgets/third-party/hot/twikoo.pug +57 -0
- package/layout/includes/widgets/third-party/pjax.pug +2 -1
- package/layout/index.pug +1 -1
- package/layout/tag.pug +2 -0
- package/package.json +1 -1
- package/scripts/event/init.js +0 -1
- package/scripts/event/merge_config.js +14 -39
- package/scripts/filter/default.js +20 -21
- package/scripts/filter/lazyload.js +2 -4
- package/scripts/helper/getArchiveLength.js +9 -11
- package/scripts/helper/related_post.js +56 -56
- package/scripts/tags/tabs.js +28 -46
- package/source/css/_comments/twikoo.styl +3 -3
- package/source/css/_highlight/highlight/diff.styl +13 -1
- package/source/css/_highlight/index.styl +2 -2
- package/source/css/_highlight/prismjs/diff.styl +13 -1
- package/source/css/_layout/recent-post.styl +2 -2
- package/source/img/error_load.avif +0 -0
- package/source/js/covercolor/api.js +29 -14
- package/source/js/covercolor/ave.js +38 -24
- package/source/js/covercolor/local.js +52 -52
- package/source/js/main.js +236 -244
- package/source/js/music.js +21 -39
- package/source/js/right_menu.js +67 -132
- package/source/js/third_party/barrage.min.js +93 -1
- package/source/js/third_party/envelope.min.js +1 -1
- package/source/js/third_party/post_ai.min.js +184 -1
- package/source/js/tw_cn.js +19 -18
- package/source/js/utils.js +50 -57
- package/layout/includes/widgets/home/hot/artalk.pug +0 -45
- package/layout/includes/widgets/home/hot/twikoo.pug +0 -46
- package/source/img/loading.avif +0 -0
- /package/layout/includes/widgets/{home → third-party}/hot/index.pug +0 -0
@@ -1,38 +1,49 @@
|
|
1
1
|
const coverColor = () => {
|
2
|
-
const
|
3
|
-
if (
|
4
|
-
setThemeColors(
|
5
|
-
|
2
|
+
const pageColor = PAGE_CONFIG.color;
|
3
|
+
if (pageColor) {
|
4
|
+
setThemeColors(pageColor);
|
5
|
+
} else {
|
6
|
+
const path = document.getElementById("post-cover")?.src;
|
7
|
+
path ? handleApiColor(path) : setDefaultThemeColors();
|
6
8
|
}
|
7
|
-
const path = document.getElementById("post-cover")?.src;
|
8
|
-
path ? handleApiColor(path) : setDefaultThemeColors();
|
9
9
|
}
|
10
10
|
|
11
11
|
const handleApiColor = (path) => {
|
12
|
-
const cacheGroup = JSON.parse(localStorage.getItem('Solitude')) || {};
|
13
|
-
const color = cacheGroup.postcolor
|
14
|
-
|
12
|
+
const cacheGroup = JSON.parse(localStorage.getItem('Solitude')) || { postcolor: {} };
|
13
|
+
const color = cacheGroup.postcolor[path]?.value;
|
14
|
+
if (color) {
|
15
|
+
setThemeColors(color);
|
16
|
+
} else {
|
17
|
+
img2color(path);
|
18
|
+
}
|
15
19
|
}
|
16
20
|
|
17
21
|
const img2color = (src) => {
|
18
22
|
fetch(`${src}?imageAve`)
|
19
|
-
.then(response =>
|
23
|
+
.then(response => {
|
24
|
+
if (!response.ok) throw new Error('Network response was not ok');
|
25
|
+
return response.json();
|
26
|
+
})
|
20
27
|
.then(({ RGB }) => {
|
21
|
-
|
22
|
-
setThemeColors(
|
23
|
-
cacheColor(src,
|
28
|
+
const formattedRGB = `#${RGB.slice(2)}`;
|
29
|
+
setThemeColors(formattedRGB);
|
30
|
+
cacheColor(src, formattedRGB);
|
24
31
|
})
|
25
|
-
.catch(console.error);
|
32
|
+
.catch(error => console.error('Error fetching color:', error));
|
26
33
|
}
|
27
34
|
|
28
35
|
const setThemeColors = (value) => {
|
29
36
|
if (!value) return setDefaultThemeColors();
|
30
37
|
const [r, g, b] = value.match(/\w\w/g).map(x => parseInt(x, 16));
|
31
|
-
const
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
38
|
+
const themeColors = {
|
39
|
+
main: value,
|
40
|
+
op: `${value}23`,
|
41
|
+
opDeep: `${value}dd`,
|
42
|
+
none: `${value}00`
|
43
|
+
};
|
44
|
+
Object.entries(themeColors).forEach(([key, color]) => {
|
45
|
+
document.documentElement.style.setProperty(`--efu-${key}`, color);
|
46
|
+
});
|
36
47
|
adjustBrightness(r, g, b);
|
37
48
|
document.getElementById("coverdiv").classList.add("loaded");
|
38
49
|
initThemeColor();
|
@@ -40,7 +51,9 @@ const setThemeColors = (value) => {
|
|
40
51
|
|
41
52
|
const setDefaultThemeColors = () => {
|
42
53
|
const vars = ['--efu-theme', '--efu-theme-op', '--efu-theme-op-deep', '--efu-theme-none'];
|
43
|
-
vars.forEach((varName, i) =>
|
54
|
+
vars.forEach((varName, i) => {
|
55
|
+
document.documentElement.style.setProperty(['--efu-main', '--efu-main-op', '--efu-main-op-deep', '--efu-main-none'][i], `var(${varName})`);
|
56
|
+
});
|
44
57
|
initThemeColor();
|
45
58
|
}
|
46
59
|
|
@@ -51,10 +64,11 @@ const cacheColor = (src, color) => {
|
|
51
64
|
}
|
52
65
|
|
53
66
|
const adjustBrightness = (r, g, b) => {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
67
|
+
const brightness = Math.round(((r * 299) + (g * 587) + (b * 114)) / 1000);
|
68
|
+
if (brightness < 125) {
|
69
|
+
document.querySelectorAll('.card-content').forEach(item => {
|
70
|
+
item.style.setProperty('--efu-card-bg', 'var(--efu-white)');
|
71
|
+
});
|
58
72
|
document.querySelectorAll('.author-info__sayhi').forEach(item => {
|
59
73
|
item.style.setProperty('background', 'var(--efu-white-op)');
|
60
74
|
item.style.setProperty('color', 'var(--efu-white)');
|
@@ -1,23 +1,26 @@
|
|
1
1
|
const coverColor = () => {
|
2
|
-
const
|
3
|
-
if (
|
4
|
-
|
5
|
-
return;
|
2
|
+
const pageColor = PAGE_CONFIG.color || document.getElementById("post-cover")?.src;
|
3
|
+
if (pageColor) {
|
4
|
+
return localColor(pageColor);
|
6
5
|
}
|
7
|
-
|
8
|
-
path ? localColor(path) : setDefaultThemeColors();
|
6
|
+
setDefaultThemeColors();
|
9
7
|
}
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
const setDefaultThemeColors = () => {
|
10
|
+
const themeVars = {
|
11
|
+
'--efu-main': 'var(--efu-theme)',
|
12
|
+
'--efu-main-op': 'var(--efu-theme-op)',
|
13
|
+
'--efu-main-op-deep': 'var(--efu-theme-op-deep)',
|
14
|
+
'--efu-main-none': 'var(--efu-theme-none)'
|
15
|
+
};
|
16
|
+
Object.entries(themeVars).forEach(([key, value]) => {
|
17
|
+
document.documentElement.style.setProperty(key, value);
|
18
|
+
});
|
16
19
|
initThemeColor();
|
17
20
|
}
|
18
21
|
|
19
22
|
const localColor = path => {
|
20
|
-
|
23
|
+
const colorThief = new ColorThief();
|
21
24
|
const img = new Image();
|
22
25
|
img.crossOrigin = "Anonymous";
|
23
26
|
img.onload = () => setThemeColors(rgbToHex(colorThief.getColor(img)));
|
@@ -26,50 +29,47 @@ const localColor = path => {
|
|
26
29
|
}
|
27
30
|
|
28
31
|
const rgbToHex = ([r, g, b]) => {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
}).join('');
|
34
|
-
return hex;
|
32
|
+
return '#' + [r, g, b].map(x => {
|
33
|
+
const component = Math.floor(x * 0.8);
|
34
|
+
return component.toString(16).padStart(2, '0');
|
35
|
+
}).join('');
|
35
36
|
}
|
36
37
|
|
37
|
-
|
38
|
-
if (value)
|
39
|
-
document.documentElement.style.setProperty('--efu-main', value);
|
40
|
-
document.documentElement.style.setProperty('--efu-main-op', value + '23');
|
41
|
-
document.documentElement.style.setProperty('--efu-main-op-deep', value + 'dd');
|
42
|
-
document.documentElement.style.setProperty('--efu-main-none', value + '00');
|
38
|
+
const setThemeColors = (value, r = null, g = null, b = null) => {
|
39
|
+
if (!value) return setDefaultThemeColors();
|
43
40
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
41
|
+
const themeColors = {
|
42
|
+
'--efu-main': value,
|
43
|
+
'--efu-main-op': value + '23',
|
44
|
+
'--efu-main-op-deep': value + 'dd',
|
45
|
+
'--efu-main-none': value + '00'
|
46
|
+
};
|
47
|
+
Object.entries(themeColors).forEach(([key, color]) => {
|
48
|
+
document.documentElement.style.setProperty(key, color);
|
49
|
+
});
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
value = LightenDarkenColor(value, 50);
|
59
|
-
document.documentElement.style.setProperty('--efu-main', value);
|
60
|
-
document.documentElement.style.setProperty('--efu-main-op', value + '23');
|
61
|
-
document.documentElement.style.setProperty('--efu-main-op-deep', value + 'dd');
|
62
|
-
document.documentElement.style.setProperty('--efu-main-none', value + '00');
|
63
|
-
}
|
51
|
+
if (r && g && b) {
|
52
|
+
const brightness = Math.round(((parseInt(r) * 299) + (parseInt(g) * 587) + (parseInt(b) * 114)) / 1000);
|
53
|
+
if (brightness < 125) {
|
54
|
+
adjustCardStyles();
|
55
|
+
value = LightenDarkenColor(value, 50);
|
56
|
+
setThemeColors(value);
|
64
57
|
}
|
65
|
-
|
66
|
-
document.getElementById("coverdiv").classList.add("loaded");
|
67
|
-
initThemeColor();
|
68
|
-
} else {
|
69
|
-
document.documentElement.style.setProperty('--efu-main', 'var(--efu-theme)');
|
70
|
-
document.documentElement.style.setProperty('--efu-main-op', 'var(--efu-theme-op)');
|
71
|
-
document.documentElement.style.setProperty('--efu-main-op-deep', 'var(--efu-theme-op-deep)');
|
72
|
-
document.documentElement.style.setProperty('--efu-main-none', 'var(--efu-theme-none)');
|
73
|
-
initThemeColor();
|
74
58
|
}
|
59
|
+
|
60
|
+
document.getElementById("coverdiv").classList.add("loaded");
|
61
|
+
initThemeColor();
|
62
|
+
}
|
63
|
+
|
64
|
+
const adjustCardStyles = () => {
|
65
|
+
const cardContents = document.getElementsByClassName('card-content');
|
66
|
+
Array.from(cardContents).forEach(item => {
|
67
|
+
item.style.setProperty('--efu-card-bg', 'var(--efu-white)');
|
68
|
+
});
|
69
|
+
|
70
|
+
const authorInfo = document.getElementsByClassName('author-info__sayhi');
|
71
|
+
Array.from(authorInfo).forEach(item => {
|
72
|
+
item.style.setProperty('background', 'var(--efu-white-op)');
|
73
|
+
item.style.setProperty('color', 'var(--efu-white)');
|
74
|
+
});
|
75
75
|
}
|