hexo-theme-solitude 1.0.0 → 1.1.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 (125) hide show
  1. package/README.md +62 -20
  2. package/README_EN.md +98 -0
  3. package/_config.yml +162 -144
  4. package/layout/404.ejs +1 -1
  5. package/layout/layout.ejs +27 -32
  6. package/layout/page/about.ejs +3 -1
  7. package/layout/page/circle.ejs +1 -1
  8. package/layout/page/echarts.ejs +1 -14
  9. package/layout/page/links.ejs +2 -13
  10. package/layout/page/rss.ejs +10 -8
  11. package/layout/page/says.ejs +1 -0
  12. package/layout/partial/body.ejs +0 -1
  13. package/layout/partial/compoment/about/award.ejs +3 -1
  14. package/layout/partial/compoment/about/hobbies.ejs +44 -35
  15. package/layout/partial/compoment/about/other.ejs +68 -60
  16. package/layout/partial/compoment/aside/asideFlipCard.ejs +67 -3
  17. package/layout/partial/compoment/aside/asideHistory.ejs +49 -0
  18. package/layout/partial/compoment/aside/asideNewestPost.ejs +1 -1
  19. package/layout/partial/compoment/aside/asidePower.ejs +3 -3
  20. package/layout/partial/compoment/aside/asideSwitch.ejs +6 -0
  21. package/layout/partial/compoment/aside/asideToc.ejs +1 -1
  22. package/layout/partial/compoment/aside/asideWebInfo.ejs +8 -8
  23. package/layout/partial/compoment/aside/asideWelcome.ejs +33 -0
  24. package/layout/partial/compoment/circle/angle.ejs +2 -2
  25. package/layout/partial/compoment/circle/content.ejs +8 -11
  26. package/layout/partial/compoment/dorakika/rightmenu.ejs +90 -105
  27. package/layout/partial/compoment/hometop/bbTimeList.ejs +1 -1
  28. package/layout/partial/compoment/hometop/groupTag.ejs +1 -1
  29. package/layout/partial/compoment/hometop/topGroup.ejs +11 -18
  30. package/layout/partial/compoment/inject/body.ejs +20 -7
  31. package/layout/partial/compoment/inject/head.ejs +67 -3
  32. package/layout/partial/compoment/links/angle.ejs +26 -0
  33. package/layout/partial/compoment/links/banner.ejs +2 -2
  34. package/layout/partial/compoment/mixins/pagination.ejs +2 -2
  35. package/layout/partial/compoment/nav/right.ejs +6 -6
  36. package/layout/partial/compoment/post/award.ejs +30 -22
  37. package/layout/partial/compoment/post/copyright.ejs +10 -8
  38. package/layout/partial/compoment/post/postMeta.ejs +21 -19
  39. package/layout/partial/compoment/says/saysBottom.ejs +3 -3
  40. package/layout/partial/compoment/says/saysContent.ejs +0 -1
  41. package/layout/partial/compoment/says/saysFunction.ejs +15 -0
  42. package/layout/partial/compoment/third-party/comments/comment.ejs +1 -1
  43. package/layout/partial/compoment/third-party/comments/twikoo.ejs +2 -1
  44. package/layout/partial/compoment/third-party/search/algolia-search.ejs +2 -2
  45. package/layout/partial/compoment/third-party/search/local-search.ejs +2 -2
  46. package/layout/partial/console.ejs +10 -4
  47. package/layout/partial/footer.ejs +11 -9
  48. package/layout/partial/nav.ejs +2 -2
  49. package/layout/partial/sidebar.ejs +2 -2
  50. package/layout/post.ejs +19 -3
  51. package/package.json +4 -5
  52. package/scripts/event/welcome.js +6 -7
  53. package/scripts/helper/charts.js +45 -34
  54. package/scripts/helper/randomLinks.js +1 -1
  55. package/scripts/helper/related_post.js +11 -4
  56. package/scripts/helper/themeJsExport.js +12 -10
  57. package/scripts/tags/fold.js +2 -3
  58. package/scripts/tags/note.js +6 -2
  59. package/scripts/tags/tabs.js +2 -2
  60. package/source/css/main.css +79 -265
  61. package/source/css/search/algolia-search.css +1 -1
  62. package/source/css/search/local-search.css +1 -1
  63. package/source/css/var.css +3 -0
  64. package/source/img/default.png +0 -0
  65. package/source/img/error_load.png +0 -0
  66. package/source/img/logo-horizontal_version.png +0 -0
  67. package/source/img/pwa/16.png +0 -0
  68. package/source/img/pwa/180.png +0 -0
  69. package/source/img/pwa/192.png +0 -0
  70. package/source/img/pwa/32.png +0 -0
  71. package/source/img/pwa/512.png +0 -0
  72. package/source/img/pwa/logo.png +0 -0
  73. package/source/img/pwa/siteicon/splash-1125x2436.png +0 -0
  74. package/source/img/pwa/siteicon/splash-1136x640.png +0 -0
  75. package/source/img/pwa/siteicon/splash-1170x2532.png +0 -0
  76. package/source/img/pwa/siteicon/splash-1179x2556.png +0 -0
  77. package/source/img/pwa/siteicon/splash-1242x2208.png +0 -0
  78. package/source/img/pwa/siteicon/splash-1242x2688.png +0 -0
  79. package/source/img/pwa/siteicon/splash-1248x2778.png +0 -0
  80. package/source/img/pwa/siteicon/splash-1290x2796.png +0 -0
  81. package/source/img/pwa/siteicon/splash-1334x750.png +0 -0
  82. package/source/img/pwa/siteicon/splash-1536x2048.png +0 -0
  83. package/source/img/pwa/siteicon/splash-1620x2160.png +0 -0
  84. package/source/img/pwa/siteicon/splash-1668x2224.png +0 -0
  85. package/source/img/pwa/siteicon/splash-1668x2388.png +0 -0
  86. package/source/img/pwa/siteicon/splash-1792x828.png +0 -0
  87. package/source/img/pwa/siteicon/splash-2048x1536.png +0 -0
  88. package/source/img/pwa/siteicon/splash-2048x2732.png +0 -0
  89. package/source/img/pwa/siteicon/splash-2160x1620.png +0 -0
  90. package/source/img/pwa/siteicon/splash-2208x1242.png +0 -0
  91. package/source/img/pwa/siteicon/splash-2224x1668.png +0 -0
  92. package/source/img/pwa/siteicon/splash-2388x1668.png +0 -0
  93. package/source/img/pwa/siteicon/splash-2436x1125.png +0 -0
  94. package/source/img/pwa/siteicon/splash-2532x1170.png +0 -0
  95. package/source/img/pwa/siteicon/splash-2556x1179.png +0 -0
  96. package/source/img/pwa/siteicon/splash-2688x1242.png +0 -0
  97. package/source/img/pwa/siteicon/splash-2732x2048.png +0 -0
  98. package/source/img/pwa/siteicon/splash-2778x1248.png +0 -0
  99. package/source/img/pwa/siteicon/splash-2796x1290.png +0 -0
  100. package/source/img/pwa/siteicon/splash-640x1136.png +0 -0
  101. package/source/img/pwa/siteicon/splash-750x1334.png +0 -0
  102. package/source/img/pwa/siteicon/splash-828x1792.png +0 -0
  103. package/source/img/solitude-show.jpg +0 -0
  104. package/source/js/commentBarrage.js +145 -136
  105. package/source/js/extend/covercolor/local.js +104 -94
  106. package/source/js/extend/search/algolia-search.js +11 -0
  107. package/source/js/extend/search/local-search.js +12 -1
  108. package/source/js/main.js +212 -27
  109. package/source/js/rightmenu.js +402 -0
  110. package/source/js/txmap.js +236 -0
  111. package/source/lib/chuckle-post-ai.js +1 -0
  112. package/source/lib/circle.min.js +1 -0
  113. package/source/lib/friends_post.js +4 -98
  114. package/source/lib/snackbar.min.js +9 -0
  115. package/source/lib/view-image.min.js +6 -0
  116. package/scripts/filter/katex.js +0 -25
  117. package/scripts/tags/expand.js +0 -4
  118. package/source/img/power.png +0 -0
  119. package/source/js/circle.js +0 -1828
  120. package/source/js/extend/covercolor/web.js +0 -137
  121. package/source/js/post_ai.js +0 -517
  122. package/source/lib/snackbar.js +0 -16
  123. package/source/lib/view-image.js +0 -13
  124. /package/source/lib/{bundle.js → bundle.min.js} +0 -0
  125. /package/source/lib/{lazyload.js → lazyload.min.js} +0 -0
@@ -1,148 +1,157 @@
1
- var commentBarrageConfig = {
2
- maxBarrage: 1,
3
- barrageTime: 8e3,
4
- twikooUrl: "https://twikoo.sondy.top",
5
- pageUrl: window.location.pathname,
6
- barrageTimer: [],
7
- barrageList: [],
8
- barrageIndex: 0,
9
- dom: document.querySelector(".comment-barrage")
10
- }
11
- , commentInterval = null
12
- , hoverOnCommentBarrage = !1
13
- , isFirstTime = !0;
14
- document.querySelector(".comment-barrage").addEventListener("mouseenter", (function () {
15
- hoverOnCommentBarrage = !0
16
- }
17
- )),
18
- document.querySelector(".comment-barrage").addEventListener("mouseleave", (function () {
19
- hoverOnCommentBarrage = !1
20
- }
21
- ));
22
- var fetchComments = async function () {
23
- try {
24
- var e = await fetch(commentBarrageConfig.twikooUrl, {
25
- method: "POST",
26
- headers: {
27
- "Content-Type": "application/json"
1
+ function initializeCommentBarrage() {
2
+ window.commentBarrageInitialized = !0;
3
+ let e = {
4
+ maxBarrage: 1,
5
+ barrageTime: 8e3,
6
+ twikooUrl: GLOBALCONFIG.comment.twikooUrl,
7
+ pageUrl: window.location.pathname,
8
+ accessToken: GLOBALCONFIG.comment.twikooAccessToken,
9
+ };
10
+ new class {
11
+ commentInterval = null
12
+ constructor(e) {
13
+ this.config = {
14
+ ...e,
15
+ barrageTimer: [],
16
+ barrageList: [],
17
+ barrageIndex: 0,
18
+ dom: document.querySelector(".comment-barrage")
28
19
  },
29
- body: JSON.stringify({
30
- event: "COMMENT_GET",
31
- accessToken: commentBarrageConfig.accessToken,
32
- url: commentBarrageConfig.pageUrl
33
- })
34
- });
35
- if (!e.ok)
36
- throw new Error("HTTP error! status: " + e.status);
37
- return (await e.json()).data
38
- } catch (e) {
39
- console.error("An error occurred while fetching comments: ", e)
40
- }
41
- }
42
- , initCommentBarrage = function () {
43
- "false" !== localStorage.getItem("commentBarrageSwitch") ? (commentBarrageConfig.dom.style.display = "none",
44
- document.querySelector(".menu-commentBarrage-text").textContent = "显示热评",
45
- document.querySelector("#consoleCommentBarrage").classList.remove("on")) : (commentBarrageConfig.dom.style.display = "flex",
46
- document.querySelector(".menu-commentBarrage-text").textContent = "关闭热评",
47
- document.querySelector("#consoleCommentBarrage").classList.add("on")),
48
- fetchComments().then((function (e) {
49
- commentBarrageConfig.barrageList = commentLinkFilter(e),
50
- commentBarrageConfig.dom.innerHTML = "",
51
- clearInterval(commentInterval),
52
- commentInterval = null;
53
- var r = function () {
54
- if (commentBarrageConfig.barrageList.length && !hoverOnCommentBarrage) {
55
- if (!popCommentBarrage(commentBarrageConfig.barrageList[commentBarrageConfig.barrageIndex]))
56
- return commentBarrageConfig.barrageIndex += 1,
57
- commentBarrageConfig.barrageIndex %= commentBarrageConfig.barrageList.length,
58
- r();
59
- commentBarrageConfig.barrageIndex += 1,
60
- commentBarrageConfig.barrageIndex %= commentBarrageConfig.barrageList.length
61
- }
62
- commentBarrageConfig.barrageTimer.length > (commentBarrageConfig.barrageList.length > commentBarrageConfig.maxBarrage ? commentBarrageConfig.maxBarrage : commentBarrageConfig.barrageList.length) && !hoverOnCommentBarrage && removeCommentBarrage(commentBarrageConfig.barrageTimer.shift())
63
- };
64
- setTimeout((function () {
65
- r(),
66
- commentInterval = setInterval(r, commentBarrageConfig.barrageTime)
67
- }
68
- ), 3e3)
69
- }
70
- ))
71
- };
20
+ this.commentInterval = null,
21
+ this.hoverOnCommentBarrage = !1,
22
+ this.init()
23
+ }
72
24
 
73
- function commentLinkFilter(e) {
74
- e.sort((function (e, r) {
75
- return e.created - r.created
25
+ async fetchComments() {
26
+ return fetch(this.config.twikooUrl, {
27
+ method: "POST",
28
+ headers: {
29
+ "Content-Type": "application/json"
30
+ },
31
+ body: JSON.stringify({
32
+ event: "COMMENT_GET",
33
+ accessToken: this.config.accessToken,
34
+ url: this.config.pageUrl
35
+ })
36
+ }).then((e => {
37
+ if (!e.ok)
38
+ throw Error("HTTP error! status: " + e.status);
39
+ return e.json()
40
+ }
41
+ )).then((e => e.data)).catch((e => console.error("An error occurred while fetching comments: ", e)))
76
42
  }
77
- ));
78
- var r = [];
79
- return e.forEach((function (e) {
80
- r.push(...getCommentReplies(e))
43
+
44
+ commentLinkFilter(e) {
45
+ e.sort(((e, t) => e.created - t.created));
46
+ let t = [];
47
+ return e.forEach((e => {
48
+ t.push(...this.getCommentReplies(e))
49
+ }
50
+ )),
51
+ t
81
52
  }
82
- )),
83
- r
84
- }
85
53
 
86
- function getCommentReplies(e) {
87
- if (e.replies) {
88
- var r = [e];
89
- return e.replies.forEach((function (e) {
90
- r.push(...getCommentReplies(e))
54
+ getCommentReplies(e) {
55
+ if (e.replies) {
56
+ let comments = [e];
57
+ e.replies.forEach((reply) => {
58
+ comments.push(...this.getCommentReplies(reply));
59
+ });
60
+ return comments;
91
61
  }
92
- )),
93
- r
94
- }
95
- return []
96
- }
62
+ return [];
63
+ }
97
64
 
98
- function processCommentContent(e) {
99
- var r = document.createElement("div");
100
- r.innerHTML = e;
101
- for (var a = r.getElementsByTagName("img"), n = a.length - 1; n >= 0; n--) {
102
- var t = a[n];
103
- t.parentNode.removeChild(t)
104
- }
105
- var o = r.getElementsByTagName("blockquote");
106
- for (n = o.length - 1; n >= 0; n--) {
107
- var m = o[n];
108
- m.parentNode.removeChild(m)
109
- }
110
- var c = r.getElementsByTagName("a");
111
- for (n = c.length - 1; n >= 0; n--) {
112
- var i = c[n]
113
- , g = document.createTextNode(i.textContent);
114
- i.parentNode.replaceChild(g, i)
115
- }
116
- var s = r.getElementsByTagName("p");
117
- for (n = s.length - 1; n >= 0; n--) {
118
- var l = s[n];
119
- "" === l.textContent.trim() && l.parentNode.removeChild(l)
120
- }
121
- return r.innerHTML
122
- }
123
65
 
124
- function popCommentBarrage(e) {
125
- var r = processCommentContent(e.comment);
126
- if (!r.trim())
127
- return !1;
128
- var a = document.createElement("div");
129
- return a.className = "comment-barrage-item",
130
- a.innerHTML = `\n <div class="barrageHead">\n <a class="barrageTitle" href="javascript:sco.scrollTo('post-comment')">热评</a>\n <div class="barrageNick">${e.nick}</div>\n <img class="barrageAvatar" src="https://cravatar.cn/avatar/${e.mailMd5}"/>\n <a class="comment-barrage-close" href="javascript:sco.switchCommentBarrage();"><i class="scofont icon-close-fill"></i></a>\n </div>\n <a class="barrageContent" href="javascript:sco.scrollTo('${e.id}');">${r}</a>\n `,
131
- commentBarrageConfig.barrageTimer.push(a),
132
- commentBarrageConfig.dom.appendChild(a),
133
- !0
134
- }
66
+ processCommentContent(e) {
67
+ const t = e.replace(/<blockquote\b[^>]*>[\s\S]*?<\/blockquote>/gi, "")
68
+ , r = t.replace(/<[^>]*>/g, "").replace(/\n/g, " ");
69
+ return "" === t.trim() ? "" : `<p>${r}</p>`
70
+ }
71
+
72
+ popCommentBarrage(e) {
73
+ var commentContent = this.processCommentContent(e.comment);
135
74
 
136
- function removeCommentBarrage(e) {
137
- e.className = "comment-barrage-item out",
138
- setTimeout((function () {
139
- commentBarrageConfig.dom.removeChild(e)
75
+ if (!commentContent.trim()) {
76
+ return false;
140
77
  }
141
- ), 1e3)
142
- }
143
78
 
144
- initCommentBarrage(),
145
- document.addEventListener("pjax:send", (function () {
146
- clearInterval(commentInterval)
79
+ let commentBarrageItem = document.createElement("div");
80
+ commentBarrageItem.className = "comment-barrage-item";
81
+
82
+ commentBarrageItem.innerHTML = `
83
+ <div class="barrageHead">
84
+ <a class="barrageTitle" href="javascript:sco.scrollTo('post-comment')">热评</a>
85
+ <div class="barrageNick">${e.nick}</div>
86
+ <img class="barrageAvatar" src="https://cravatar.cn/avatar/${e.mailMd5}"/>
87
+ <a class="comment-barrage-close" href="javascript:sco.switchCommentBarrage();"><i class="scoicon sco-close-fill"></i></a>
88
+ </div>
89
+ <a class="barrageContent" href="javascript:sco.scrollTo('${e.id}');">${commentContent}</a>
90
+ `;
91
+
92
+ this.config.barrageTimer.push(commentBarrageItem);
93
+
94
+ this.config.dom.appendChild(commentBarrageItem);
95
+ return true;
96
+ }
97
+
98
+ removeCommentBarrage(e) {
99
+ e.className = "comment-barrage-item out",
100
+ setTimeout((() => {
101
+ this.config.dom.removeChild(e)
102
+ }
103
+ ), 1e3)
147
104
  }
148
- ));
105
+
106
+ async initCommentBarrage() {
107
+ if (localStorage.getItem("commentBarrageSwitch") != null) {
108
+ document.querySelector(".comment-barrage").style.display = "flex";
109
+ document.querySelector(".menu-commentBarrage-text").textContent = "关闭热评";
110
+ document.querySelector("#consoleCommentBarrage").classList.add("on");
111
+ } else {
112
+ document.querySelector(".comment-barrage").style.display = "none";
113
+ document.querySelector(".menu-commentBarrage-text").textContent = "显示热评";
114
+ document.querySelector("#consoleCommentBarrage").classList.remove("on");
115
+ }
116
+ const comments = await this.fetchComments();
117
+ this.config.barrageList = this.commentLinkFilter(comments);
118
+ this.config.dom.innerHTML = "";
119
+ clearInterval(this.commentInterval);
120
+ this.commentInterval = null;
121
+ const t = () => {
122
+ if (this.config.barrageList.length && !this.hoverOnCommentBarrage) {
123
+ if (!this.popCommentBarrage(this.config.barrageList[this.config.barrageIndex]))
124
+ return this.config.barrageIndex += 1,
125
+ this.config.barrageIndex %= this.config.barrageList.length,
126
+ void t();
127
+ this.config.barrageIndex += 1,
128
+ this.config.barrageIndex %= this.config.barrageList.length
129
+ }
130
+ if (this.config.barrageTimer.length > (this.config.barrageList.length > this.config.maxBarrage ? this.config.maxBarrage : this.config.barrageList.length) && !this.hoverOnCommentBarrage) {
131
+ this.removeCommentBarrage(this.config.barrageTimer.shift());
132
+ }
133
+ };
134
+ setTimeout(() => {
135
+ t();
136
+ if (this.commentInterval) {
137
+ clearInterval(this.commentInterval);
138
+ }
139
+ this.commentInterval = setInterval(t, this.config.barrageTime);
140
+ }, 3000);
141
+ }
142
+
143
+ init() {
144
+ this.initCommentBarrage();
145
+ const commentBarrage = document.querySelector(".comment-barrage");
146
+ commentBarrage.addEventListener('mouseover', () => {
147
+ this.hoverOnCommentBarrage = true;
148
+ });
149
+ commentBarrage.addEventListener('mouseout', () => {
150
+ this.hoverOnCommentBarrage = false;
151
+ });
152
+ }
153
+ }
154
+ (e)
155
+ }
156
+
157
+ initializeCommentBarrage();
@@ -1,107 +1,113 @@
1
1
  function coverColor() {
2
2
  var path = document.getElementById("post-cover")?.src;
3
3
  if (path !== undefined) {
4
- var img = new Image();
5
- img.crossOrigin = "Anonymous";
6
- img.src = path;
7
- img.onload = function () {
8
- var canvas = document.createElement("canvas");
9
- canvas.width = this.width;
10
- canvas.height = this.height;
11
- var ctx = canvas.getContext("2d");
12
- ctx.drawImage(this, 0, 0);
13
- var data = ctx.getImageData(0, 0, this.width, this.height).data;
14
- var r = 0, g = 0, b = 0;
15
- var step = 5;
16
- for (var i = 0; i < data.length; i += 4 * step) {
17
- r += data[i];
18
- g += data[i + 1];
19
- b += data[i + 2];
4
+ var img = new Image();
5
+ img.crossOrigin = "Anonymous";
6
+ img.src = path;
7
+ img.onload = function () {
8
+ var canvas = document.createElement("canvas");
9
+ canvas.width = this.width;
10
+ canvas.height = this.height;
11
+ var ctx = canvas.getContext("2d");
12
+ ctx.drawImage(this, 0, 0);
13
+ var data = ctx.getImageData(0, 0, this.width, this.height).data;
14
+ var colorCounts = {};
15
+ var dominantColor = '';
16
+ var maxCount = 0;
17
+ var step = 5;
18
+ for (var i = 0; i < data.length; i += 4 * step) {
19
+ var r = data[i];
20
+ var g = data[i + 1];
21
+ var b = data[i + 2];
22
+ var color = `${r},${g},${b}`;
23
+
24
+ colorCounts[color] = (colorCounts[color] || 0) + 1;
25
+
26
+ if (colorCounts[color] > maxCount) {
27
+ maxCount = colorCounts[color];
28
+ dominantColor = color;
29
+ }
30
+ }
31
+ var rgb = dominantColor.split(',').map(c => parseInt(c, 10));
32
+ var value = "#" + rgb[0].toString(16) + rgb[1].toString(16) + rgb[2].toString(16);
33
+ if (getContrastYIQ(value) == "light") {
34
+ value = LightenDarkenColor(colorHex(value), -50)
35
+ }
36
+
37
+ document.documentElement.style.setProperty('--sco-main', value);
38
+ document.documentElement.style.setProperty('--sco-main-op', value + '23');
39
+ document.documentElement.style.setProperty('--sco-main-op-deep', value + 'dd');
40
+ document.documentElement.style.setProperty('--sco-main-none', value + '00');
41
+ initThemeColor()
42
+ document.getElementById("coverdiv").classList.add("loaded");
20
43
  }
21
- r = Math.floor(r / (data.length / 4 / step));
22
- g = Math.floor(g / (data.length / 4 / step));
23
- b = Math.floor(b / (data.length / 4 / step));
24
- var value = "#" + r.toString(16) + g.toString(16) + b.toString(16);
25
- if (getContrastYIQ(value) == "light") {
26
- value = LightenDarkenColor(colorHex(value), -50)
27
- }
28
-
29
- document.documentElement.style.setProperty('--sco-main', value);
30
- document.documentElement.style.setProperty('--sco-main-op', value + '23');
31
- document.documentElement.style.setProperty('--sco-main-op-deep', value + 'dd');
32
- document.documentElement.style.setProperty('--sco-main-none', value + '00');
33
- initThemeColor()
34
- document.getElementById("coverdiv").classList.add("loaded");
35
- }
36
44
  } else {
37
- document.documentElement.style.setProperty('--sco-main', 'var(--sco-theme)');
38
- document.documentElement.style.setProperty('--sco-main-op', 'var(--sco-theme-op)');
39
- document.documentElement.style.setProperty('--sco-main-op-deep', 'var(--sco-theme-op-deep)');
40
- document.documentElement.style.setProperty('--sco-main-none', 'var(--sco-theme-none)');
41
- initThemeColor()
45
+ document.documentElement.style.setProperty('--sco-main', 'var(--sco-theme)');
46
+ document.documentElement.style.setProperty('--sco-main-op', 'var(--sco-theme-op)');
47
+ document.documentElement.style.setProperty('--sco-main-op-deep', 'var(--sco-theme-op-deep)');
48
+ document.documentElement.style.setProperty('--sco-main-none', 'var(--sco-theme-none)');
49
+ initThemeColor()
42
50
  }
43
- }
44
-
51
+ }
45
52
 
46
- function colorHex(colorString) {
53
+ function colorHex(colorString) {
47
54
  const hexRegex = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
48
55
  let color = colorString;
49
56
 
50
57
  if (/^(rgb|RGB)/.test(color)) {
51
- const colorArr = color.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
52
- const hexArr = colorArr.map(c => {
53
- const hex = Number(c).toString(16);
54
- return hex.length === 1 ? "0" + hex : hex;
55
- });
56
- return "#" + hexArr.join("");
57
- } else if (hexRegex.test(color)) {
58
- const hexDigits = color.replace(/#/, "").split("");
59
- if (hexDigits.length === 6) {
60
- return color;
61
- } else if (hexDigits.length === 3) {
62
- const hexArr = hexDigits.map(c => c + c);
58
+ const colorArr = color.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
59
+ const hexArr = colorArr.map(c => {
60
+ const hex = Number(c).toString(16);
61
+ return hex.length === 1 ? "0" + hex : hex;
62
+ });
63
63
  return "#" + hexArr.join("");
64
- }
64
+ } else if (hexRegex.test(color)) {
65
+ const hexDigits = color.replace(/#/, "").split("");
66
+ if (hexDigits.length === 6) {
67
+ return color;
68
+ } else if (hexDigits.length === 3) {
69
+ const hexArr = hexDigits.map(c => c + c);
70
+ return "#" + hexArr.join("");
71
+ }
65
72
  }
66
73
  return color;
67
- }
68
-
74
+ }
69
75
 
70
76
 
71
77
  function colorRgb(str) {
72
- const HEX_SHORT_REGEX = /^#([0-9a-fA-f]{3})$/;
73
- const HEX_LONG_REGEX = /^#([0-9a-fA-f]{6})$/;
74
- const HEX_SHORT_LENGTH = 4;
75
-
76
- if (!str || typeof str !== 'string') {
77
- return str;
78
- }
79
-
80
- const sColor = str.toLowerCase();
81
- let hexValue = "";
82
-
83
- if (sColor && (HEX_SHORT_REGEX.test(sColor) || HEX_LONG_REGEX.test(sColor))) {
84
- hexValue = sColor.length === HEX_SHORT_LENGTH ?
85
- sColor.replace(/^#(.)/g, "#$1$1") :
86
- sColor;
87
-
88
- const rgbValue = hexValue.slice(1)
89
- .match(/.{2}/g)
90
- .map(val => parseInt(val, 16));
91
-
92
- return `rgb(${rgbValue[0]}, ${rgbValue[1]}, ${rgbValue[2]})`;
93
- } else {
94
- return sColor;
95
- }
78
+ const HEX_SHORT_REGEX = /^#([0-9a-fA-f]{3})$/;
79
+ const HEX_LONG_REGEX = /^#([0-9a-fA-f]{6})$/;
80
+ const HEX_SHORT_LENGTH = 4;
81
+
82
+ if (!str || typeof str !== 'string') {
83
+ return str;
84
+ }
85
+
86
+ const sColor = str.toLowerCase();
87
+ let hexValue = "";
88
+
89
+ if (sColor && (HEX_SHORT_REGEX.test(sColor) || HEX_LONG_REGEX.test(sColor))) {
90
+ hexValue = sColor.length === HEX_SHORT_LENGTH ?
91
+ sColor.replace(/^#(.)/g, "#$1$1") :
92
+ sColor;
93
+
94
+ const rgbValue = hexValue.slice(1)
95
+ .match(/.{2}/g)
96
+ .map(val => parseInt(val, 16));
97
+
98
+ return `rgb(${rgbValue[0]}, ${rgbValue[1]}, ${rgbValue[2]})`;
99
+ } else {
100
+ return sColor;
101
+ }
96
102
  }
97
103
 
98
104
 
99
- function LightenDarkenColor(col, amt) {
105
+ function LightenDarkenColor(col, amt) {
100
106
  let usePound = false;
101
107
 
102
108
  if (col[0] === "#") {
103
- col = col.slice(1);
104
- usePound = true;
109
+ col = col.slice(1);
110
+ usePound = true;
105
111
  }
106
112
 
107
113
  const num = parseInt(col, 16);
@@ -110,12 +116,15 @@ function colorRgb(str) {
110
116
  const g = Math.min(255, Math.max(0, (num & 0xff) + amt));
111
117
 
112
118
  return `${usePound ? "#" : ""}${(g | (b << 8) | (r << 16)).toString(16).padStart(6, "0")}`;
113
- }
119
+ }
114
120
 
115
121
 
116
- function getContrastYIQ(hexcolor) {
122
+ function getContrastYIQ(hexcolor) {
117
123
  var colorrgb = colorRgb(hexcolor);
118
124
  var colors = colorrgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
125
+ if (!colors) {
126
+ return "light"; // or "dark", depending on your preference
127
+ }
119
128
  var red = colors[1];
120
129
  var green = colors[2];
121
130
  var blue = colors[3];
@@ -123,28 +132,29 @@ function colorRgb(str) {
123
132
  brightness = (red * 299) + (green * 587) + (blue * 114);
124
133
  brightness = brightness / 255000;
125
134
  if (brightness >= 0.5) {
126
- return "light";
135
+ return "light";
127
136
  } else {
128
- return "dark";
137
+ return "dark";
129
138
  }
130
- }
139
+ }
140
+
131
141
 
132
- function initThemeColor() {
142
+ function initThemeColor() {
133
143
  const currentTop = window.scrollY || document.documentElement.scrollTop;
134
144
  let themeColor;
135
145
  if (currentTop > 0) {
136
- themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-card-bg');
146
+ themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-card-bg');
137
147
  } else if (PAGECONFIG.is_post) {
138
- themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-main');
148
+ themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-main');
139
149
  } else {
140
- themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-background');
150
+ themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-background');
141
151
  }
142
152
  changeThemeColor(themeColor);
143
- }
153
+ }
144
154
 
145
- function changeThemeColor(color) {
155
+ function changeThemeColor(color) {
146
156
  const meta = document.querySelector('meta[name="theme-color"]');
147
157
  if (meta) {
148
- meta.setAttribute('content', color);
158
+ meta.setAttribute('content', color);
149
159
  }
150
- }
160
+ }
@@ -118,6 +118,17 @@ class search {
118
118
 
119
119
  const searchClickFn = () => {
120
120
  document.querySelector('#search-button > .search').addEventListener('click', search.openSearch)
121
+ document.getElementById('menu-search').addEventListener('click', function() {
122
+ rm.hideRightMenu();
123
+ search.openSearch();
124
+ let t = document.getElementsByClassName('ais-search-box--input')[0];
125
+ let evt = new Event('input', {
126
+ bubbles: true,
127
+ cancelable: true
128
+ });
129
+ t.value = selectTextNow;
130
+ t.dispatchEvent(evt);
131
+ });
121
132
  }
122
133
 
123
134
  const searchClickFnOnce = () => {
@@ -47,7 +47,7 @@ class search{
47
47
  if (!GLOBALCONFIG.localsearch.preload && dataObj === null) dataObj = this.fetchData(GLOBALCONFIG.localsearch.path)
48
48
  $input.addEventListener('input', function type() {
49
49
  const keywords = this.value.trim().toLowerCase().split(/[\s]+/)
50
- if (keywords[0] !== '') $loadingStatus.innerHTML = '<i class="ri-loader-2-fill"></i><span>加载中</span>'
50
+ if (keywords[0] !== '') $loadingStatus.innerHTML = '<i class="scoicon sco-loading-line"></i><span>加载中</span>'
51
51
  else {
52
52
  $resultContent.innerHTML = ''
53
53
  return
@@ -142,6 +142,17 @@ class search{
142
142
 
143
143
  const searchClickFn = () => {
144
144
  document.querySelector('#search-button > .search').addEventListener('click', search.openSearch)
145
+ document.getElementById('menu-search').addEventListener('click', function() {
146
+ rm.hideRightMenu();
147
+ search.openSearch();
148
+ let t = document.getElementsByClassName('search-box-input')[0];
149
+ let evt = new Event('input', {
150
+ bubbles: true,
151
+ cancelable: true
152
+ });
153
+ t.value = selectTextNow;
154
+ t.dispatchEvent(evt);
155
+ })
145
156
  }
146
157
 
147
158
  const searchClickFnOnce = () => {