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.
Files changed (68) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/README.md +1 -1
  3. package/README_EN.md +1 -1
  4. package/_config.yml +68 -3
  5. package/languages/en-US.yml +32 -2
  6. package/languages/zh-CN.yml +33 -2
  7. package/languages/zh-TW.yml +147 -0
  8. package/layout/includes/console.pug +4 -0
  9. package/layout/includes/footer.pug +1 -1
  10. package/layout/includes/head/config.pug +16 -3
  11. package/layout/includes/inject/body.pug +18 -9
  12. package/layout/includes/keyboard.pug +65 -0
  13. package/layout/includes/layout.pug +8 -0
  14. package/layout/includes/page/album.pug +39 -0
  15. package/layout/includes/page/gallery.pug +11 -0
  16. package/layout/includes/page/links.pug +2 -0
  17. package/layout/includes/page/moment.pug +28 -0
  18. package/layout/includes/page/music.pug +1 -4
  19. package/layout/includes/page/says.pug +1 -3
  20. package/layout/includes/widgets/home/bb/json.pug +2 -1
  21. package/layout/includes/widgets/home/bb/local.pug +2 -3
  22. package/layout/includes/widgets/home/bb/memos.pug +2 -1
  23. package/layout/includes/widgets/page/about/authorinfo.pug +1 -1
  24. package/layout/includes/widgets/page/about/hobbies.pug +2 -2
  25. package/layout/includes/widgets/page/about/motto.pug +17 -15
  26. package/layout/includes/widgets/page/about/skillsinfo.pug +38 -36
  27. package/layout/includes/widgets/page/about/tenyear.pug +1 -1
  28. package/layout/includes/widgets/page/moments/angle.pug +19 -0
  29. package/layout/includes/widgets/page/says/json.pug +3 -3
  30. package/layout/includes/widgets/page/says/local.pug +2 -2
  31. package/layout/includes/widgets/rightside/index.pug +33 -22
  32. package/layout/includes/widgets/third-party/search/algolia-search.pug +20 -15
  33. package/layout/includes/widgets/third-party/search/local-search.pug +3 -0
  34. package/layout/page.pug +6 -0
  35. package/package.json +1 -1
  36. package/plugins.yml +12 -4
  37. package/scripts/event/cdn.js +5 -0
  38. package/scripts/event/init.js +18 -19
  39. package/scripts/event/page.js +0 -5
  40. package/scripts/filter/checkThemeConfig.js +23 -7
  41. package/scripts/helper/related_post.js +0 -6
  42. package/scripts/helper/stylus.js +8 -3
  43. package/source/css/_global/index.styl +1 -5
  44. package/source/css/_layout/basic.styl +0 -1
  45. package/source/css/_layout/index.styl +54 -34
  46. package/source/css/_mode/index.styl +6 -1
  47. package/source/css/_page/about/index.styl +26 -16
  48. package/source/css/_page/gallery/index.styl +99 -0
  49. package/source/css/_page/index.styl +5 -1
  50. package/source/css/_page/moment.styl +4 -2
  51. package/source/css/_widgets/_comment/twikoo.styl +21 -18
  52. package/source/css/_widgets/_mixins/keyboard.styl +59 -0
  53. package/source/css/_widgets/_search/algolia-search.styl +37 -16
  54. package/source/css/_widgets/_search/local-search.styl +18 -2
  55. package/source/css/_widgets/_tags/link.styl +1 -1
  56. package/source/css/_widgets/index.styl +4 -0
  57. package/source/css/index.styl +0 -1
  58. package/source/js/covercolor/api.js +10 -6
  59. package/source/js/covercolor/local.js +88 -13
  60. package/source/js/main.js +15 -1
  61. package/source/js/rightside.js +159 -342
  62. package/source/js/search/algolia.js +4 -2
  63. package/source/js/search/local.js +3 -1
  64. package/source/js/tw_cn.js +76 -0
  65. package/source/js/utils.js +1 -1
  66. package/layout/includes/page/not_configured.pug +0 -18
  67. package/scripts/helper/cdn.js +0 -12
  68. 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
- margin-bottom 8px
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)
@@ -8,7 +8,7 @@
8
8
  border-width 1px !important
9
9
  margin-top 1rem
10
10
 
11
- &:hover
11
+ /#article-container a.tag-Link:not(.headerlink):hover
12
12
  border var(--style-border-hover)
13
13
 
14
14
  .tag-link-tips
@@ -4,6 +4,10 @@
4
4
  // 手机端侧边栏
5
5
  @import "_mixins/sidebar.styl"
6
6
 
7
+ // keyboard(键盘)
8
+ if hexo-config('keyboard.enable')
9
+ @import "_mixins/keyboard.styl"
10
+
7
11
  // article-sort (归档)
8
12
  @import "_mixins/article-sort.styl"
9
13
 
@@ -12,5 +12,4 @@ if hexo-config('css_prefix')
12
12
  // widgets
13
13
  @import '_widgets/index.styl'
14
14
 
15
- // dark
16
15
  @import '_mode/*'
@@ -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 = saveToLocal.get('Solitude') || {};
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
- var brightness = Math.round(((parseInt(r) * 299) + (parseInt(g) * 587) + (parseInt(b) * 114)) / 1000);
52
+ let brightness = Math.round(((parseInt(r) * 299) + (parseInt(g) * 587) + (parseInt(b) * 114)) / 1000);
49
53
  if (brightness < 125) {
50
- var cardContents = document.getElementsByClassName('card-content');
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
- var authorInfo = document.getElementsByClassName('author-info__sayhi');
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
- function coverColor() {
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
- function localColor(path) {
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 = this.width;
15
- canvas.height = this.height;
19
+ canvas.width = img.width;
20
+ canvas.height = img.height;
16
21
  const ctx = canvas.getContext("2d");
17
- ctx.drawImage(this, 0, 0);
18
- const data = ctx.getImageData(0, 0, this.width, this.height).data;
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
- var colorrgb = colorRgb(hexcolor);
51
- var colors = colorrgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
52
- var red = colors[1];
53
- var green = colors[2];
54
- var blue = colors[3];
55
- var brightness = (red * 299) + (green * 587) + (blue * 114);
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 {