hexo-theme-stellar 1.33.0 → 1.34.0
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/CLAUDE.md +217 -0
- package/README.md +2 -0
- package/_config.yml +35 -26
- package/docs/audits/2026-08-08-stellar-analysis.md +267 -0
- package/docs/release-process.md +59 -0
- package/layout/_partial/comments/artalk/script.ejs +56 -41
- package/layout/_partial/comments/beaudar/script.ejs +35 -20
- package/layout/_partial/comments/giscus/script.ejs +34 -19
- package/layout/_partial/comments/twikoo/script.ejs +29 -14
- package/layout/_partial/comments/utterances/script.ejs +35 -20
- package/layout/_partial/comments/waline/script.ejs +40 -28
- package/layout/_partial/cover/wiki_cover.ejs +1 -1
- package/layout/_partial/head.ejs +53 -4
- package/layout/_partial/scripts/defines.ejs +21 -3
- package/layout/_partial/scripts/lazyload.ejs +2 -2
- package/layout/_partial/scripts/services.ejs +101 -41
- package/layout/_partial/scripts/utils.ejs +144 -5
- package/layout/_partial/sidebar/index_leftbar.ejs +3 -0
- package/layout/_partial/sidebar/search.ejs +3 -0
- package/layout/_partial/widgets/ghuser.ejs +18 -4
- package/layout/_partial/widgets/linklist.ejs +1 -1
- package/layout/_partial/widgets/timeline.ejs +36 -33
- package/layout/_plugins/copycode.ejs +9 -5
- package/layout/_plugins/mathjax.ejs +47 -18
- package/layout/_plugins/mermaid.ejs +28 -24
- package/layout/_plugins/pjax.ejs +8 -0
- package/layout/_plugins/scrollreveal.ejs +14 -13
- package/layout/_plugins/swiper.ejs +2 -2
- package/layout/index.ejs +4 -2
- package/layout/index_topic.ejs +4 -2
- package/layout/index_wiki.ejs +6 -4
- package/layout/layout.ejs +3 -2
- package/package.json +2 -1
- package/scripts/commands/new-note.js +49 -0
- package/scripts/filters/lib/img_onerror.js +0 -2
- package/scripts/helpers/json_ld.js +11 -8
- package/scripts/helpers/pretty_url.js +5 -0
- package/scripts/tags/lib/chat.js +16 -9
- package/scripts/tags/lib/frame.js +2 -1
- package/scripts/tags/lib/image.js +6 -5
- package/scripts/tags/lib/link.js +6 -4
- package/scripts/tags/lib/timeline.js +101 -79
- package/source/css/_common/canonical.styl +11 -6
- package/source/css/_common/highlight.styl +4 -1
- package/source/css/_common/html.styl +4 -0
- package/source/css/_common/loading.styl +5 -1
- package/source/css/_components/md.styl +3 -0
- package/source/css/_components/pages/article-story.styl +2 -0
- package/source/css/_components/partial/article-footer.styl +1 -0
- package/source/css/_components/partial/navbar.styl +4 -2
- package/source/css/_components/sidebar/menu.styl +1 -0
- package/source/css/_components/sidebar/search.styl +4 -0
- package/source/css/_components/sidebar/sidebar.styl +12 -5
- package/source/css/_components/tag-plugins/chat.styl +6 -8
- package/source/css/_components/tag-plugins/folding.styl +1 -0
- package/source/css/_components/tag-plugins/gallery.styl +2 -0
- package/source/css/_components/tag-plugins/grid.styl +1 -0
- package/source/css/_components/tag-plugins/image.styl +3 -0
- package/source/css/_components/tag-plugins/link.styl +1 -0
- package/source/css/_components/tag-plugins/navbar.styl +15 -13
- package/source/css/_components/tag-plugins/note.styl +1 -0
- package/source/css/_components/tag-plugins/okr.styl +1 -0
- package/source/css/_components/tag-plugins/sites.styl +2 -0
- package/source/css/_components/tag-plugins/timeline.styl +9 -0
- package/source/css/_components/tag-plugins/vote.styl +2 -0
- package/source/css/_components/widgets/components.styl +1 -0
- package/source/css/_components/widgets/ghuser.styl +19 -3
- package/source/css/_components/widgets/list.styl +1 -0
- package/source/css/_components/widgets/toc.styl +3 -0
- package/source/css/_components/widgets/widgets.styl +4 -0
- package/source/css/_custom.styl +6 -3
- package/source/css/_defines/func.styl +24 -8
- package/source/css/_defines/theme_base.styl +1 -1
- package/source/css/_plugins/comments/artalk.styl +6 -2
- package/source/css/_plugins/comments/twikoo.styl +2 -0
- package/source/css/_plugins/index.styl +2 -0
- package/source/css/_plugins/pjax.styl +61 -0
- package/source/js/main.js +80 -26
- package/source/js/plugins/copycode.js +34 -27
- package/source/js/plugins/pjax.js +646 -0
- package/source/js/search/local-search.js +5 -2
- package/source/js/services/memos.js +42 -4
- package/source/js/services/rss.js +200 -0
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
.widget-wrapper.user-card
|
|
2
2
|
.widget-header+.widget-body
|
|
3
3
|
margin: 0.75rem 0
|
|
4
|
+
.widget-wrapper.user-card .widget-header
|
|
5
|
+
a
|
|
6
|
+
display: flex
|
|
7
|
+
align-items: center
|
|
8
|
+
color: var(--text-p2)
|
|
9
|
+
trans1 all
|
|
10
|
+
svg
|
|
11
|
+
margin-right: 4px
|
|
12
|
+
width 1em
|
|
13
|
+
height: 1em
|
|
14
|
+
&:hover
|
|
15
|
+
color: var(--text)
|
|
16
|
+
|
|
4
17
|
.widget-wrapper.user-card .widget-body
|
|
5
18
|
text-align: center
|
|
6
19
|
background: var(--card)
|
|
@@ -33,7 +46,7 @@
|
|
|
33
46
|
.follow
|
|
34
47
|
font-weight: 500
|
|
35
48
|
border-radius: 64px
|
|
36
|
-
margin: 1rem
|
|
49
|
+
margin-top: 1rem
|
|
37
50
|
padding: 0.5rem 1rem
|
|
38
51
|
background: var(--theme)
|
|
39
52
|
color: white
|
|
@@ -53,7 +66,7 @@
|
|
|
53
66
|
background: var(--accent)
|
|
54
67
|
|
|
55
68
|
.buttons
|
|
56
|
-
margin: 1rem
|
|
69
|
+
margin-top: 1rem
|
|
57
70
|
align-self: stretch
|
|
58
71
|
display: grid
|
|
59
72
|
grid-gap: 2px
|
|
@@ -76,4 +89,7 @@
|
|
|
76
89
|
.desc
|
|
77
90
|
font-size: $fs-12
|
|
78
91
|
color: var(--text-p3)
|
|
79
|
-
font-weight: 500
|
|
92
|
+
font-weight: 500
|
|
93
|
+
|
|
94
|
+
.widget-wrapper.user-card .widget-header+.widget-body
|
|
95
|
+
margin-top: 4px
|
package/source/css/_custom.styl
CHANGED
|
@@ -31,12 +31,15 @@ $fsp3 = 'calc(%s - 3px)' % $fs-body
|
|
|
31
31
|
// site main
|
|
32
32
|
$site-background-image = hexo-config('style.site.background-image')
|
|
33
33
|
$leftbar-background-image = hexo-config('style.leftbar.background-image')
|
|
34
|
-
$leftbar-background-color = hexo-config('style.leftbar.background-color')
|
|
34
|
+
$leftbar-background-color-light = hexo-config('style.leftbar.background-color-light')
|
|
35
|
+
$leftbar-background-color-dark = hexo-config('style.leftbar.background-color-dark')
|
|
35
36
|
|
|
36
37
|
|
|
37
38
|
// colors
|
|
38
|
-
$c-theme =
|
|
39
|
-
$c-accent =
|
|
39
|
+
$c-theme = convert(hexo-config('style.color.theme'))
|
|
40
|
+
$c-accent = convert(hexo-config('style.color.accent'))
|
|
41
|
+
$c-link = convert(hexo-config('style.color.link'))
|
|
42
|
+
|
|
40
43
|
$c-base-hue = 210deg // 背景/文本颜色的主基调(一般看不出来不需要修改)
|
|
41
44
|
|
|
42
45
|
// icons
|
|
@@ -136,6 +136,17 @@ hoverable-card()
|
|
|
136
136
|
newblur()
|
|
137
137
|
box-shadow: 0 0 2px rgba(black, .04), 0 2px 8px rgba(black, .04), 0 4px 16px rgba(black, .04)
|
|
138
138
|
trans1: all
|
|
139
|
+
text-shadow: 0 0 4px rgba(white, 1), 0 0 8px rgba(white, 0.8), 0 0 16px rgba(white, 0.6)
|
|
140
|
+
:root[data-theme="dark"] &
|
|
141
|
+
text-shadow: 0 0 2px rgba(black, 0.2), 0 0 4px rgba(black, 0.4)
|
|
142
|
+
@media (prefers-color-scheme: dark)
|
|
143
|
+
text-shadow: 0 0 2px rgba(black, 0.2), 0 0 4px rgba(black, 0.4)
|
|
144
|
+
nav a:not(.active,:hover)
|
|
145
|
+
filter: drop-shadow(0 0 0 white) drop-shadow(0 0 4px white)
|
|
146
|
+
:root[data-theme="dark"] &
|
|
147
|
+
filter: none
|
|
148
|
+
@media (prefers-color-scheme: dark)
|
|
149
|
+
filter: none
|
|
139
150
|
&:before,&:after
|
|
140
151
|
z-index -1
|
|
141
152
|
position: absolute
|
|
@@ -149,17 +160,22 @@ newblur()
|
|
|
149
160
|
&:before
|
|
150
161
|
backdrop-filter: blur(8px)
|
|
151
162
|
-webkit-backdrop-filter: blur(8px)
|
|
152
|
-
background:
|
|
163
|
+
background: rgba(white, 0.3)
|
|
164
|
+
margin: 1px
|
|
165
|
+
:root[data-theme="dark"] &
|
|
166
|
+
background: rgba(white, 0.2)
|
|
167
|
+
@media (prefers-color-scheme: dark)
|
|
168
|
+
background: rgba(white, 0.2)
|
|
153
169
|
&:after
|
|
154
|
-
--blur-px:
|
|
155
|
-
--blur-sat:
|
|
156
|
-
background: var(--bg-a50)
|
|
170
|
+
--blur-px: 16px
|
|
171
|
+
--blur-sat: 300%
|
|
157
172
|
backdrop-filter: saturate(var(--blur-sat)) blur(var(--blur-px))
|
|
158
173
|
-webkit-backdrop-filter: saturate(var(--blur-sat)) blur(var(--blur-px))
|
|
159
|
-
mask: linear-gradient(
|
|
160
|
-
-webkit-mask: linear-gradient(
|
|
174
|
+
mask: linear-gradient(white, 20%, transparent, 80%, white), linear-gradient(90deg, white, 20%, transparent, 80%, white)
|
|
175
|
+
-webkit-mask-image: linear-gradient(white, 20%, transparent, 80%, white), linear-gradient(90deg, white, 20%, transparent, 80%, white)
|
|
161
176
|
box-shadow: inset 0 0 4px 1px rgba(white, 0.5)
|
|
162
177
|
trans1 all
|
|
178
|
+
:root[data-theme="dark"] &
|
|
179
|
+
box-shadow: inset 0 0 2px 1px rgba(white, 0.2)
|
|
163
180
|
@media (prefers-color-scheme: dark)
|
|
164
|
-
|
|
165
|
-
background: var(--bg-a20)
|
|
181
|
+
box-shadow: inset 0 0 2px 1px rgba(white, 0.2)
|
|
@@ -158,6 +158,7 @@
|
|
|
158
158
|
>img
|
|
159
159
|
margin: var(--gap-p) auto
|
|
160
160
|
border-radius: $border-image-s
|
|
161
|
+
corner-shape: superellipse(1.2)
|
|
161
162
|
a>img
|
|
162
163
|
display: inline
|
|
163
164
|
img[atk-emoticon]
|
|
@@ -175,5 +176,8 @@
|
|
|
175
176
|
padding: 0.25rem 1rem
|
|
176
177
|
p
|
|
177
178
|
color: var(--text-p3)
|
|
178
|
-
.atk-content
|
|
179
|
-
|
|
179
|
+
.atk-content
|
|
180
|
+
a
|
|
181
|
+
--at-color-main: var(--link)
|
|
182
|
+
pre>code
|
|
183
|
+
padding: 0
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
.vemoji, .tk-owo-emotion
|
|
7
7
|
width: unset
|
|
8
8
|
border-radius: $border-image-s
|
|
9
|
+
corner-shape: superellipse(1.2)
|
|
9
10
|
max-height: 24px
|
|
10
11
|
max-width: 100px
|
|
11
12
|
display: inline
|
|
@@ -14,6 +15,7 @@
|
|
|
14
15
|
max-width: 400px
|
|
15
16
|
max-height: 400px
|
|
16
17
|
border-radius: $border-image-s
|
|
18
|
+
corner-shape: superellipse(1.2)
|
|
17
19
|
|
|
18
20
|
.OwO
|
|
19
21
|
.OwO-body
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// PJAX - Seamless page transitions
|
|
2
|
+
|
|
3
|
+
// Custom easing for smooth, natural animations
|
|
4
|
+
$pjax-easing = cubic-bezier(0.4, 0, 0.2, 1)
|
|
5
|
+
$pjax-easing-out = cubic-bezier(0.16, 1, 0.3, 1) // Expo out - more elegant deceleration
|
|
6
|
+
$pjax-duration = 0.4s
|
|
7
|
+
$pjax-translate-distance = convert(hexo-config('plugins.pjax.translate-distance'))
|
|
8
|
+
|
|
9
|
+
.page-loading-bar
|
|
10
|
+
position: fixed
|
|
11
|
+
top: 0
|
|
12
|
+
left: calc(50% - 16px)
|
|
13
|
+
width: 32px
|
|
14
|
+
height: 32px
|
|
15
|
+
display: none
|
|
16
|
+
flex-direction: column
|
|
17
|
+
align-items: center
|
|
18
|
+
img
|
|
19
|
+
height: 100%
|
|
20
|
+
body.pjax-loading
|
|
21
|
+
.page-loading-bar
|
|
22
|
+
display: flex
|
|
23
|
+
|
|
24
|
+
// Main content transition base
|
|
25
|
+
.l_body .l_main, #l_cover
|
|
26
|
+
transition: opacity $pjax-duration $pjax-easing, transform $pjax-duration $pjax-easing
|
|
27
|
+
|
|
28
|
+
// Fade-in animation keyframes
|
|
29
|
+
@keyframes pjax-fade-in
|
|
30
|
+
0%
|
|
31
|
+
opacity: 0
|
|
32
|
+
transform: translateY($pjax-translate-distance)
|
|
33
|
+
100%
|
|
34
|
+
opacity: 1
|
|
35
|
+
transform: translateY(0)
|
|
36
|
+
|
|
37
|
+
// Loading state - content fades out and moves down slightly
|
|
38
|
+
body.pjax-loading
|
|
39
|
+
.l_body .l_main, #l_cover
|
|
40
|
+
opacity: 0.4
|
|
41
|
+
transform: translateY($pjax-translate-distance)
|
|
42
|
+
pointer-events: none
|
|
43
|
+
|
|
44
|
+
// Loaded state - content fades in with upward motion
|
|
45
|
+
body.pjax-loaded
|
|
46
|
+
.l_body .l_main, #l_cover
|
|
47
|
+
animation: pjax-fade-in $pjax-duration $pjax-easing-out forwards
|
|
48
|
+
|
|
49
|
+
// Respect reduced motion preferences
|
|
50
|
+
@media (prefers-reduced-motion: reduce)
|
|
51
|
+
.l_body .l_main, #l_cover
|
|
52
|
+
transition: opacity $pjax-duration ease
|
|
53
|
+
body.pjax-loading .l_body .l_main, body.pjax-loading #l_cover
|
|
54
|
+
transform: none
|
|
55
|
+
body.pjax-loaded .l_body .l_main, body.pjax-loaded #l_cover
|
|
56
|
+
animation: pjax-fade-simple $pjax-duration ease forwards
|
|
57
|
+
@keyframes pjax-fade-simple
|
|
58
|
+
0%
|
|
59
|
+
opacity: 0
|
|
60
|
+
100%
|
|
61
|
+
opacity: 1
|
package/source/js/main.js
CHANGED
|
@@ -37,10 +37,11 @@ const util = {
|
|
|
37
37
|
const el = document.getElementById(id);
|
|
38
38
|
if (el) {
|
|
39
39
|
el.select();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
navigator.clipboard.writeText(el.value).then(() => {
|
|
41
|
+
if (msg && msg.length > 0) {
|
|
42
|
+
hud.toast(msg, 2500);
|
|
43
|
+
}
|
|
44
|
+
}).catch(() => {});
|
|
44
45
|
}
|
|
45
46
|
},
|
|
46
47
|
|
|
@@ -52,11 +53,11 @@ const util = {
|
|
|
52
53
|
},
|
|
53
54
|
|
|
54
55
|
scrollTop: () => {
|
|
55
|
-
window.scrollTo({top: 0, behavior: "smooth"});
|
|
56
|
+
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
56
57
|
},
|
|
57
58
|
|
|
58
59
|
scrollComment: () => {
|
|
59
|
-
document.getElementById('comments').scrollIntoView({behavior: "smooth"});
|
|
60
|
+
document.getElementById('comments').scrollIntoView({ behavior: "smooth" });
|
|
60
61
|
},
|
|
61
62
|
|
|
62
63
|
viewportLazyload: (target, func, enabled = true) => {
|
|
@@ -83,8 +84,8 @@ const hud = {
|
|
|
83
84
|
el.innerHTML = msg;
|
|
84
85
|
document.body.appendChild(el);
|
|
85
86
|
|
|
86
|
-
setTimeout(function(){ document.body.removeChild(el) }, d);
|
|
87
|
-
|
|
87
|
+
setTimeout(function () { document.body.removeChild(el) }, d);
|
|
88
|
+
|
|
88
89
|
},
|
|
89
90
|
|
|
90
91
|
}
|
|
@@ -138,20 +139,20 @@ const init = {
|
|
|
138
139
|
const offsetBottom = e1.getBoundingClientRect().bottom - e0.getBoundingClientRect().bottom + 100;
|
|
139
140
|
const offsetTop = e1.getBoundingClientRect().top - e0.getBoundingClientRect().top - 64;
|
|
140
141
|
if (offsetTop < 0) {
|
|
141
|
-
e0.scrollBy({top: offsetTop, behavior: "smooth"});
|
|
142
|
+
e0.scrollBy({ top: offsetTop, behavior: "smooth" });
|
|
142
143
|
} else if (offsetBottom > 0) {
|
|
143
|
-
e0.scrollBy({top: offsetBottom, behavior: "smooth"});
|
|
144
|
+
e0.scrollBy({ top: offsetBottom, behavior: "smooth" });
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
|
-
|
|
147
|
+
|
|
147
148
|
var timeout = null;
|
|
148
|
-
window.addEventListener('scroll', function() {
|
|
149
|
+
window.addEventListener('scroll', function () {
|
|
149
150
|
activeTOC();
|
|
150
|
-
if(timeout !== null) clearTimeout(timeout);
|
|
151
|
-
timeout = setTimeout(function() {
|
|
151
|
+
if (timeout !== null) clearTimeout(timeout);
|
|
152
|
+
timeout = setTimeout(function () {
|
|
152
153
|
scrollTOC();
|
|
153
154
|
}.bind(this), 50);
|
|
154
|
-
});
|
|
155
|
+
});
|
|
155
156
|
})
|
|
156
157
|
},
|
|
157
158
|
sidebar: () => {
|
|
@@ -202,24 +203,44 @@ const init = {
|
|
|
202
203
|
|
|
203
204
|
canonicalCheck: () => {
|
|
204
205
|
const canonical = window.canonical;
|
|
205
|
-
function
|
|
206
|
+
function originStatusCheck() {
|
|
207
|
+
return new Promise((resolve) => {
|
|
208
|
+
if (window.canonical.originalHost === window.location.hostname) {
|
|
209
|
+
resolve(true);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const scriptUrl = `https://${window.canonical.originalHost}${window.canonical.param.checklink}`;
|
|
213
|
+
const script = document.createElement('script');
|
|
214
|
+
script.src = scriptUrl;
|
|
215
|
+
script.type = 'text/javascript';
|
|
216
|
+
script.onload = function () { resolve(true); };
|
|
217
|
+
script.onerror = function () { resolve(false); };
|
|
218
|
+
document.head.appendChild(script);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
async function showTip(isOfficial = false) {
|
|
206
222
|
const meta = document.createElement('meta');
|
|
207
223
|
meta.name = 'robots';
|
|
208
224
|
meta.content = 'noindex, nofollow';
|
|
209
225
|
document.head.appendChild(meta);
|
|
210
226
|
const notice = document.createElement('div');
|
|
211
227
|
const originalURL = `https://${canonical.originalHost}`;
|
|
228
|
+
const currentURL = canonical.param.permalink.startsWith("http") ? canonical.param.permalink : originalURL;
|
|
212
229
|
if (isOfficial) {
|
|
230
|
+
const closeEnable = window.localStorage.getItem('Stellar.canonical.closeEnable') === 'true'
|
|
231
|
+
const closedToday = window.localStorage.getItem('Stellar.canonical.closeTime') === new Date().toDateString()
|
|
232
|
+
if ((closeEnable && closedToday) || !(await originStatusCheck())) return;
|
|
213
233
|
notice.className = 'canonical-tip official';
|
|
214
234
|
notice.innerHTML = `
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
235
|
+
<a href="${currentURL}" target="_self" rel="noopener noreferrer">
|
|
236
|
+
本站为官方备用站,仅供应急。点击移步主站<br>${originalURL}
|
|
237
|
+
</a>
|
|
238
|
+
${canonical.closeEnable ? '<button id="canonical-close">' + canonical.closeText || '关闭提示' + '</button>' : ''}
|
|
218
239
|
`;
|
|
219
240
|
} else {
|
|
220
241
|
notice.className = 'canonical-tip unofficial';
|
|
221
242
|
notice.innerHTML = `
|
|
222
|
-
<a href="${
|
|
243
|
+
<a href="${currentURL}" target="_self" rel="noopener noreferrer">
|
|
223
244
|
<div class="headline icon">☠️</div>
|
|
224
245
|
本站为非法克隆站,请前往官方源站访问。<br>
|
|
225
246
|
源站:${originalURL}
|
|
@@ -227,6 +248,14 @@ const init = {
|
|
|
227
248
|
`;
|
|
228
249
|
}
|
|
229
250
|
document.body.appendChild(notice);
|
|
251
|
+
const closeBtn = notice.querySelector('#canonical-close');
|
|
252
|
+
if (closeBtn) {
|
|
253
|
+
closeBtn.addEventListener('click', function () {
|
|
254
|
+
window.localStorage.setItem('Stellar.canonical.closeEnable', "true")
|
|
255
|
+
window.localStorage.setItem('Stellar.canonical.closeTime', new Date().toDateString())
|
|
256
|
+
notice.style.display = 'none';
|
|
257
|
+
});
|
|
258
|
+
}
|
|
230
259
|
}
|
|
231
260
|
if (!canonical.originalHost) return;
|
|
232
261
|
const currentURL = new URL(window.location.href);
|
|
@@ -259,9 +288,34 @@ const init = {
|
|
|
259
288
|
}
|
|
260
289
|
|
|
261
290
|
|
|
262
|
-
//
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
291
|
+
// Stellar namespace
|
|
292
|
+
window.stellar = window.stellar || {};
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Initialize page components
|
|
296
|
+
* Called on initial load and after PJAX navigation
|
|
297
|
+
*/
|
|
298
|
+
stellar.initPage = function () {
|
|
299
|
+
init.toc();
|
|
300
|
+
init.sidebar();
|
|
301
|
+
init.relativeDate(document.querySelectorAll('#post-meta time'));
|
|
302
|
+
init.registerTabsTag();
|
|
303
|
+
|
|
304
|
+
// Reinitialize comments after PJAX navigation
|
|
305
|
+
if (stellar.initComments) {
|
|
306
|
+
for (const commentSystem in stellar.initComments) {
|
|
307
|
+
if (typeof stellar.initComments[commentSystem] === 'function') {
|
|
308
|
+
stellar.initComments[commentSystem]();
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
// Initial page load
|
|
315
|
+
stellar.initPage();
|
|
316
|
+
init.canonicalCheck();
|
|
317
|
+
|
|
318
|
+
// Listen for PJAX navigation complete
|
|
319
|
+
document.addEventListener('pjax:complete', function () {
|
|
320
|
+
stellar.initPage();
|
|
321
|
+
});
|
|
@@ -1,32 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
function createCopyButtons(codeElements) {
|
|
2
|
+
codeElements.forEach((codeElement) => {
|
|
3
|
+
if (codeElement.querySelector('.copy-btn')) return;
|
|
4
|
+
// 创建复制按钮
|
|
5
|
+
const codeCopyBtn = document.createElement('div');
|
|
6
|
+
codeCopyBtn.className = 'copy-btn';
|
|
7
|
+
codeCopyBtn.textContent = ctx.copycode.default_text;
|
|
8
|
+
codeElement.appendChild(codeCopyBtn);
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
// 添加点击事件监听
|
|
11
|
+
codeCopyBtn.addEventListener('click', async () => {
|
|
12
|
+
const codeToCopy = codeElement.querySelector('pre')?.innerText || '';
|
|
13
|
+
if (navigator.clipboard) {
|
|
14
|
+
try {
|
|
15
|
+
await navigator.clipboard.writeText(codeToCopy);
|
|
16
|
+
codeCopyBtn.textContent = ctx.copycode.success_text;
|
|
17
|
+
codeCopyBtn.classList.add('success');
|
|
18
|
+
hud.toast(ctx.copycode.toast, 2500);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
codeCopyBtn.textContent = '未获得用户许可';
|
|
21
|
+
codeCopyBtn.classList.add('warning');
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
codeCopyBtn.textContent = '浏览器不支持/非HTTPS';
|
|
19
25
|
codeCopyBtn.classList.add('warning');
|
|
20
26
|
}
|
|
21
|
-
} else {
|
|
22
|
-
codeCopyBtn.textContent = '浏览器不支持/非HTTPS';
|
|
23
|
-
codeCopyBtn.classList.add('warning');
|
|
24
|
-
}
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
// 3秒后恢复默认文本
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
codeCopyBtn.textContent = ctx.copycode.default_text;
|
|
31
|
+
codeCopyBtn.classList.remove('success', 'warning');
|
|
32
|
+
}, 3000);
|
|
33
|
+
});
|
|
31
34
|
});
|
|
32
|
-
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (typeof window.codeElements !== 'undefined') {
|
|
38
|
+
createCopyButtons(window.codeElements);
|
|
39
|
+
}
|