hexo-theme-solitude 1.4.0 → 1.4.2

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 (59) hide show
  1. package/_config.yml +66 -15
  2. package/languages/en-US.yml +3 -2
  3. package/languages/zh-CN.yml +3 -2
  4. package/layout/404.pug +1 -1
  5. package/layout/includes/console.pug +4 -0
  6. package/layout/includes/head/config.pug +1 -1
  7. package/layout/includes/head.pug +1 -1
  8. package/layout/includes/inject/body.pug +6 -5
  9. package/layout/includes/keyboard.pug +65 -0
  10. package/layout/includes/layout.pug +4 -0
  11. package/layout/includes/page/about.pug +1 -1
  12. package/layout/includes/page/album.pug +56 -0
  13. package/layout/includes/page/gallery.pug +11 -0
  14. package/layout/includes/page/links.pug +2 -0
  15. package/layout/includes/page/moment.pug +28 -0
  16. package/layout/includes/widgets/page/moments/angle.pug +19 -0
  17. package/layout/includes/widgets/page/says/json.pug +2 -4
  18. package/layout/includes/widgets/page/says/local.pug +3 -7
  19. package/layout/includes/widgets/page/says/memos.pug +2 -4
  20. package/layout/includes/widgets/third-party/search/algolia-search.pug +20 -15
  21. package/layout/includes/widgets/third-party/search/local-search.pug +3 -0
  22. package/layout/page.pug +6 -0
  23. package/package.json +1 -1
  24. package/plugins.yml +6 -2
  25. package/source/css/_global/index.styl +1 -5
  26. package/source/css/_layout/basic.styl +6 -2
  27. package/source/css/_mode/index.styl +6 -1
  28. package/source/css/_page/about/author.styl +94 -0
  29. package/source/css/_page/about/buff.styl +34 -0
  30. package/source/css/_page/about/careers.styl +27 -0
  31. package/source/css/_page/about/contentinfo.styl +78 -0
  32. package/source/css/_page/about/game.styl +41 -0
  33. package/source/css/_page/about/index.styl +39 -1
  34. package/source/css/_page/about/like.styl +29 -0
  35. package/source/css/_page/about/maxim.styl +23 -0
  36. package/source/css/_page/about/myphoto.styl +34 -0
  37. package/source/css/_page/about/oneself.styl +91 -0
  38. package/source/css/_page/about/personalities.styl +25 -0
  39. package/source/css/_page/about/reward.styl +113 -0
  40. package/source/css/_page/about/skills.styl +75 -0
  41. package/source/css/_page/about/statistic.styl +55 -0
  42. package/source/css/_page/gallery/index.styl +96 -0
  43. package/source/css/_page/index.styl +24 -4
  44. package/source/css/_page/moment.styl +4 -2
  45. package/source/css/_widgets/_comment/twikoo.styl +20 -17
  46. package/source/css/_widgets/_mixins/keyboard.styl +59 -0
  47. package/source/css/_widgets/_search/algolia-search.styl +37 -16
  48. package/source/css/_widgets/_search/local-search.styl +18 -2
  49. package/source/css/_widgets/_tags/link.styl +1 -1
  50. package/source/css/_widgets/index.styl +4 -0
  51. package/source/css/index.styl +0 -1
  52. package/source/js/covercolor/api.js +22 -21
  53. package/source/js/covercolor/local.js +21 -15
  54. package/source/js/main.js +15 -1
  55. package/source/js/search/algolia.js +4 -2
  56. package/source/js/search/local.js +3 -1
  57. package/source/js/utils.js +1 -1
  58. package/source/css/_page/about.styl +0 -773
  59. package/source/img/avatar.png +0 -0
@@ -2,6 +2,12 @@ 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
 
@@ -18,30 +24,23 @@ function handleApiColor(path) {
18
24
 
19
25
  function img2color(src) {
20
26
  const apiUrl = coverColorConfig.api + encodeURIComponent(src);
21
-
22
27
  fetch(apiUrl)
23
28
  .then(response => response.json())
24
29
  .then(data => {
25
30
  const color = data.RGB;
26
31
  const [r, g, b] = color.match(/\w\w/g).map(x => parseInt(x, 16));
27
32
  setThemeColors(color, r, g, b);
28
- if (coverColorConfig.time !== 0) {
29
- cacheColor(src, color);
30
- }
33
+ const expirationTime = Date.now() + coverColorConfig.time;
34
+ const cacheGroup = JSON.parse(localStorage.getItem('Solitude')) || {};
35
+ cacheGroup.postcolor = cacheGroup.postcolor || {};
36
+ cacheGroup.postcolor[src] = {value: color, expiration: expirationTime};
37
+ localStorage.setItem('Solitude', JSON.stringify(cacheGroup));
31
38
  })
32
39
  .catch(error => {
33
40
  console.error('请检查API是否正常!\n' + error);
34
41
  });
35
42
  }
36
43
 
37
- function cacheColor(src, color) {
38
- const expirationTime = Date.now() + coverColorConfig.time;
39
- const cacheGroup = saveToLocal.get('Solitude') || {};
40
- cacheGroup.postcolor = cacheGroup.postcolor || {};
41
- cacheGroup.postcolor[src] = {value: color, expiration: expirationTime};
42
- localStorage.setItem('Solitude', JSON.stringify(cacheGroup));
43
- }
44
-
45
44
  function setThemeColors(value, r = null, g = null, b = null) {
46
45
  if (value) {
47
46
  document.documentElement.style.setProperty('--sco-main', value);
@@ -50,16 +49,18 @@ function setThemeColors(value, r = null, g = null, b = null) {
50
49
  document.documentElement.style.setProperty('--sco-main-none', value + '00');
51
50
 
52
51
  if (r && g && b) {
53
- var brightness = Math.round(((parseInt(r) * 299) + (parseInt(g) * 587) + (parseInt(b) * 114)) / 1000);
54
- var cardContents = document.getElementsByClassName('card-content');
55
- var authorInfo = document.getElementsByClassName('author-info__sayhi');
56
- for (let i = 0; i < cardContents.length; i++) {
57
- cardContents[i].style.setProperty('--sco-card-bg', 'var(--sco-white)');
58
- }
52
+ let brightness = Math.round(((parseInt(r) * 299) + (parseInt(g) * 587) + (parseInt(b) * 114)) / 1000);
53
+ if (brightness < 125) {
54
+ let cardContents = document.getElementsByClassName('card-content');
55
+ for (let i = 0; i < cardContents.length; i++) {
56
+ cardContents[i].style.setProperty('--sco-card-bg', 'var(--sco-white)');
57
+ }
59
58
 
60
- for (let i = 0; i < authorInfo.length; i++) {
61
- authorInfo[i].style.setProperty('background', 'var(--sco-white-op)');
62
- authorInfo[i].style.setProperty('color', 'var(--sco-white)');
59
+ let authorInfo = document.getElementsByClassName('author-info__sayhi');
60
+ for (let i = 0; i < authorInfo.length; i++) {
61
+ authorInfo[i].style.setProperty('background', 'var(--sco-white-op)');
62
+ authorInfo[i].style.setProperty('color', 'var(--sco-white)');
63
+ }
63
64
  }
64
65
  }
65
66
 
@@ -2,6 +2,12 @@ const coverColor = () => {
2
2
  const path = document.getElementById("post-cover")?.src;
3
3
  if (path) {
4
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()
5
11
  }
6
12
  }
7
13
 
@@ -22,7 +28,7 @@ const localColor = (path) => {
22
28
  }
23
29
  setThemeColors(value, r, g, b);
24
30
  };
25
- img.onerror = function() {
31
+ img.onerror = function () {
26
32
  console.error('图片加载失败');
27
33
  };
28
34
  img.src = path;
@@ -63,12 +69,12 @@ function LightenDarkenColor(col, amt) {
63
69
  }
64
70
 
65
71
  function getContrastYIQ(hexcolor) {
66
- var colorrgb = colorRgb(hexcolor);
67
- var colors = colorrgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
68
- var red = colors[1];
69
- var green = colors[2];
70
- var blue = colors[3];
71
- 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);
72
78
  brightness = brightness / 255000;
73
79
  return brightness >= 0.5 ? "light" : "dark";
74
80
  }
@@ -111,24 +117,24 @@ function setThemeColors(value, r = null, g = null, b = null) {
111
117
  document.documentElement.style.setProperty('--sco-main-none', value + '00');
112
118
 
113
119
  if (r && g && b) {
114
- var brightness = Math.round(((parseInt(r) * 299) + (parseInt(g) * 587) + (parseInt(b) * 114)) / 1000);
120
+ let brightness = Math.round(((parseInt(r) * 299) + (parseInt(g) * 587) + (parseInt(b) * 114)) / 1000);
115
121
  for (let i = 0; i < cardContents.length; i++) {
116
- cardContents[i].style.setProperty('--sco-card-bg', 'var(--sco-white)');
122
+ cardContents[i].style.setProperty('--sco-card-bg', 'let(--sco-white)');
117
123
  }
118
124
 
119
125
  for (let i = 0; i < authorInfo.length; i++) {
120
- authorInfo[i].style.setProperty('background', 'var(--sco-white-op)');
121
- authorInfo[i].style.setProperty('color', 'var(--sco-white)');
126
+ authorInfo[i].style.setProperty('background', 'let(--sco-white-op)');
127
+ authorInfo[i].style.setProperty('color', 'let(--sco-white)');
122
128
  }
123
129
  }
124
130
 
125
131
  document.getElementById("coverdiv").classList.add("loaded");
126
132
  initThemeColor();
127
133
  } else {
128
- document.documentElement.style.setProperty('--sco-main', 'var(--sco-theme)');
129
- document.documentElement.style.setProperty('--sco-main-op', 'var(--sco-theme-op)');
130
- document.documentElement.style.setProperty('--sco-main-op-deep', 'var(--sco-theme-op-deep)');
131
- document.documentElement.style.setProperty('--sco-main-none', 'var(--sco-theme-none)');
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)');
132
138
  initThemeColor();
133
139
  }
134
140
  }
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 {
@@ -1,8 +1,10 @@
1
+ let openSearch
2
+
1
3
  window.addEventListener("load", () => {
2
4
  const $searchMask = document.getElementById("search-mask");
3
5
  const $searchDialog = document.querySelector("#algolia-search .search-dialog");
4
6
 
5
- const openSearch = () => {
7
+ openSearch = () => {
6
8
  utils.animateIn($searchMask, "to_show 0.5s");
7
9
  $searchDialog.style.display = "block";
8
10
  setTimeout(() => {
@@ -68,7 +70,7 @@ window.addEventListener("load", () => {
68
70
  });
69
71
 
70
72
  const configure = instantsearch.widgets.configure({
71
- hitsPerPage: algolia.hits.per_page ?? 5,
73
+ hitsPerPage: algolia.hits.per_page || 5,
72
74
  });
73
75
 
74
76
  const searchBox = instantsearch.widgets.searchBox({
@@ -1,8 +1,10 @@
1
+ let openSearch
2
+
1
3
  window.onload = () => {
2
4
  let idx, store = [];
3
5
  const $searchMask = document.getElementById("search-mask");
4
6
  const $searchDialog = document.querySelector("#local-search .search-dialog");
5
- const openSearch = () => {
7
+ openSearch = () => {
6
8
  utils.animateIn($searchMask, "to_show 0.5s");
7
9
  $searchDialog.style.display = "block";
8
10
  setTimeout(() => {
@@ -243,5 +243,5 @@ const utils = {
243
243
  window.fancyboxRun = true
244
244
  }
245
245
  }
246
- },
246
+ }
247
247
  }