webxc 1.0.25 → 1.0.27
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/butterfly/css/site.min.css +199 -8
- package/butterfly/fonts/fontawesome/fa-brands-400.woff2 +0 -0
- package/butterfly/fonts/fontawesome/fa-regular-400.woff2 +0 -0
- package/butterfly/fonts/fontawesome/fa-solid-900.woff2 +0 -0
- package/butterfly/js/site-init.js +111 -0
- package/butterfly/js/swiper-init.js +7 -0
- package/package.json +1 -1
|
@@ -71,17 +71,208 @@ body{background-color:#f4f4f4!important;background-image:url(../img/postssback.s
|
|
|
71
71
|
* 原则:原站(Butterfly 4.4.0 编译产物 + webxc 魔改样式)已有的视觉,
|
|
72
72
|
* 一律不在本文件重复声明;这里只修原站自身就存在的缺陷。
|
|
73
73
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
74
|
+
* 1) 隐藏导航栏里那个「居中页名」容器
|
|
75
|
+
* 原站 center#name-container 同时写了 top:15% 与 bottom:60px,
|
|
76
|
+
* 在 60px 高的遮罩里高度算成负数,标题被挤到导航条下方,
|
|
77
|
+
* 只露出一条白底文字(滚动时的白条 / 与菜单重叠都来自这里)。
|
|
78
|
+
* 源站的这个页名本来就没法正常显示,直接不渲染最干净:
|
|
79
|
+
* 导航条保持完整可用(站名 + 搜索 + 夜间模式 + 居中菜单),
|
|
80
|
+
* 回到顶部继续走右下角按钮和标题 hover。
|
|
81
|
+
*
|
|
82
|
+
* 2) 首页文章卡片在窄屏改成单列
|
|
83
|
+
* 07-theme-vars.css 的卡片是「PC 两列 + 卡内左右分栏」的固定写法:
|
|
84
|
+
* 卡片 49%、封面 44%、信息栏 float:right 固定 198px、标题 margin-left:-25px。
|
|
85
|
+
* 这些规则不带媒体查询,768px 以下照样生效,于是窄屏上封面被压到 44%、
|
|
86
|
+
* 标题只剩 198px、标签和「发表于」挤成两行,没有封面的卡片左边还空一块。
|
|
87
|
+
*
|
|
88
|
+
* 这里只改卡片内部的封面与信息栏,不改 .recent-post-item 本身:
|
|
89
|
+
* 轮播 banner 是插件以 .recent-post-item 的身份插进 #recent-posts 的,
|
|
90
|
+
* 动父元素会把它一起改坏。父元素在 768px 以下本来就是 width:100%,
|
|
91
|
+
* 把两个子元素的 float 去掉、宽度拉满,自然就上下堆叠成单列了。
|
|
92
|
+
*
|
|
93
|
+
* 3) 窄屏下的分页按钮、正文宽元素
|
|
82
94
|
* ============================================================ */
|
|
83
95
|
|
|
84
96
|
#page-header .mask-name-container,
|
|
85
97
|
#page-header center#name-container {
|
|
86
98
|
display: none !important;
|
|
87
99
|
}
|
|
100
|
+
|
|
101
|
+
/* ---------- 首页 / 分类 / 标签:窄屏单列卡片 ---------- */
|
|
102
|
+
@media screen and (max-width: 768px) {
|
|
103
|
+
/* 卡片间距:窄屏不再用虚线分隔,卡片自身有底色和阴影。
|
|
104
|
+
04-nav-and-posts.css 里那条带 .layout 前缀,特异性更高,这里要跟着加 */
|
|
105
|
+
#recent-posts > .recent-post-item,
|
|
106
|
+
.layout #recent-posts > .recent-post-item,
|
|
107
|
+
.layout #recent-posts > .recent-post-item:not(:first-child) {
|
|
108
|
+
margin-top: 12px !important;
|
|
109
|
+
border-bottom: none !important;
|
|
110
|
+
overflow: hidden;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
#recent-posts > .recent-post-item:first-child {
|
|
114
|
+
margin-top: 0 !important;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* 封面:整宽、固定比例,不再被 44% 挤压 */
|
|
118
|
+
#recent-posts > .recent-post-item .post_cover {
|
|
119
|
+
float: none !important;
|
|
120
|
+
width: 100% !important;
|
|
121
|
+
height: auto !important;
|
|
122
|
+
aspect-ratio: 16 / 9;
|
|
123
|
+
max-height: 240px;
|
|
124
|
+
border-radius: 0 !important;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* 封面内的图片:铺满,去掉桌面端那圈 15px / 10px 的内缩 */
|
|
128
|
+
#recent-posts > .recent-post-item .post_cover img.post_bg {
|
|
129
|
+
width: 100% !important;
|
|
130
|
+
height: 100% !important;
|
|
131
|
+
margin: 0 !important;
|
|
132
|
+
border-radius: 0 !important;
|
|
133
|
+
object-fit: cover;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* 文字区:整宽、正常内边距,清掉 float 与负边距 */
|
|
137
|
+
#recent-posts > .recent-post-item > .recent-post-info {
|
|
138
|
+
float: none !important;
|
|
139
|
+
width: 100% !important;
|
|
140
|
+
margin: 0 !important;
|
|
141
|
+
padding: 12px 14px 14px !important;
|
|
142
|
+
box-sizing: border-box;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
#recent-posts > .recent-post-item > .recent-post-info > .article-title {
|
|
146
|
+
display: -webkit-box !important;
|
|
147
|
+
-webkit-box-orient: vertical;
|
|
148
|
+
-webkit-line-clamp: 2 !important;
|
|
149
|
+
white-space: normal !important;
|
|
150
|
+
overflow: hidden;
|
|
151
|
+
margin: 0 0 8px !important;
|
|
152
|
+
padding: 0 !important;
|
|
153
|
+
font-size: 1.02rem !important;
|
|
154
|
+
line-height: 1.5 !important;
|
|
155
|
+
font-weight: 600 !important;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* 「发表于 / 分类 / 标签」整行换行,不再被 198px 截断 */
|
|
159
|
+
#recent-posts > .recent-post-item > .recent-post-info > .article-meta-wrap {
|
|
160
|
+
display: flex !important;
|
|
161
|
+
flex-wrap: wrap;
|
|
162
|
+
align-items: center;
|
|
163
|
+
gap: 2px 12px;
|
|
164
|
+
margin: 0 !important;
|
|
165
|
+
font-size: 0.8rem !important;
|
|
166
|
+
line-height: 1.9;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
#recent-posts > .recent-post-item > .recent-post-info > .article-meta-wrap .article-meta-separator {
|
|
170
|
+
display: none !important;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/* 「最新」角标贴到封面右上角,别压在标题上 */
|
|
174
|
+
#recent-posts > .recent-post-item .newPost-right {
|
|
175
|
+
right: 0 !important;
|
|
176
|
+
border-radius: 0 0 0 10px;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/* 窄屏不显示摘要,保持与 PC 一致的「标题 + 元信息」卡片 */
|
|
180
|
+
#recent-posts > .recent-post-item > .recent-post-info > .content {
|
|
181
|
+
display: none !important;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* ---------- 分页按钮:PC 上是固定 300px,窄屏要能收缩 ---------- */
|
|
185
|
+
.layout > div .pagination a.extend.next,
|
|
186
|
+
.layout > div .pagination a.extend.prev,
|
|
187
|
+
.layout > .recent-posts .pagination > *:not(.space),
|
|
188
|
+
.layout > div:not(.recent-posts) .pagination > *:not(.space) {
|
|
189
|
+
width: auto !important;
|
|
190
|
+
min-width: 8em;
|
|
191
|
+
max-width: 100% !important;
|
|
192
|
+
box-sizing: border-box;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/* ---------- 文章页头部元信息:窄屏整块换行,日期不被拆开 ---------- */
|
|
197
|
+
@media screen and (max-width: 768px) {
|
|
198
|
+
#post-meta .meta-firstline,
|
|
199
|
+
#post-meta .meta-secondline {
|
|
200
|
+
display: flex !important;
|
|
201
|
+
flex-wrap: wrap;
|
|
202
|
+
align-items: center;
|
|
203
|
+
gap: 4px 12px;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
#post-meta .meta-firstline > span,
|
|
207
|
+
#post-meta .meta-secondline > span {
|
|
208
|
+
display: inline-flex;
|
|
209
|
+
flex-wrap: wrap;
|
|
210
|
+
align-items: center;
|
|
211
|
+
gap: 0 4px;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/* 「2026-12-03」这种不能被折成两行 */
|
|
215
|
+
#post-meta time,
|
|
216
|
+
#post-meta .post-meta-label,
|
|
217
|
+
#post-meta .post-meta-icon {
|
|
218
|
+
white-space: nowrap;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/* 窄屏去掉竖线分隔,靠间距区分,省出一行高度 */
|
|
222
|
+
#post-meta .post-meta-separator {
|
|
223
|
+
display: none !important;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/* ---------- 正文里的宽元素:表格 / 代码块 / 图片不撑破卡片 ---------- */
|
|
228
|
+
@media screen and (max-width: 768px) {
|
|
229
|
+
#article-container {
|
|
230
|
+
word-break: break-word;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
#article-container img {
|
|
234
|
+
max-width: 100%;
|
|
235
|
+
height: auto;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* 表格默认不换行,窄屏会顶出容器;这里允许单元格内折行并兜住横向滚动 */
|
|
239
|
+
#article-container table {
|
|
240
|
+
display: block;
|
|
241
|
+
width: 100%;
|
|
242
|
+
overflow-x: auto;
|
|
243
|
+
-webkit-overflow-scrolling: touch;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
#article-container table th,
|
|
247
|
+
#article-container table td {
|
|
248
|
+
white-space: normal;
|
|
249
|
+
word-break: break-word;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/* 代码块内部的 table/td 是 highlight 自己的排版结构,别被上面的规则带走:
|
|
253
|
+
恢复成「整块横向滚动、代码不折行」,长命令才能看全 */
|
|
254
|
+
#article-container figure.highlight table {
|
|
255
|
+
width: auto;
|
|
256
|
+
display: block;
|
|
257
|
+
overflow: auto;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
#article-container figure.highlight table th,
|
|
261
|
+
#article-container figure.highlight table td {
|
|
262
|
+
white-space: pre;
|
|
263
|
+
word-break: normal;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
#article-container figure.highlight,
|
|
267
|
+
#article-container pre {
|
|
268
|
+
max-width: 100%;
|
|
269
|
+
overflow-x: auto;
|
|
270
|
+
word-break: normal;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/* 超长英文串 / URL 不撑破正文 */
|
|
274
|
+
#article-container a,
|
|
275
|
+
#article-container code {
|
|
276
|
+
word-break: break-word;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -187,11 +187,122 @@ function bindScrollPercent () {
|
|
|
187
187
|
window.addEventListener('resize', percent, { passive: true })
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
/* ---------- 页面预取:把 pjax 的 700ms 往返提前到「还没点」的时候 ----------
|
|
191
|
+
*
|
|
192
|
+
* 现状:站点走 pjax,切页时要先 XHR 拉一整页 HTML。线上 HTML 由 Cloudflare
|
|
193
|
+
* 回源 GitHub Pages(cf-cache-status: DYNAMIC),TTFB 1.0~2.3s,实测切一次页
|
|
194
|
+
* 内容出现要 730ms,其中 719ms 全花在这一个 XHR 上,DOM 渲染本身只要几十毫秒。
|
|
195
|
+
*
|
|
196
|
+
* 而 HTML 带 Cache-Control: max-age=600 —— 只要提前把页面抓进 HTTP 缓存,
|
|
197
|
+
* pjax 的同一个 XHR 就会命中缓存(实测 11ms)。所以这里做三件事:
|
|
198
|
+
*
|
|
199
|
+
* 1) 视口预取:滚动到可见的文章链接,进视口就预取,最多 4 个(手机 3 个);
|
|
200
|
+
* 2) 悬停 / 按下预取:鼠标移上去、手指按下立刻预取,兜住视口没覆盖到的链接;
|
|
201
|
+
* 3) 省流量:saveData 或 2G/慢速网络直接不预取,避免拿用户流量换速度。
|
|
202
|
+
*
|
|
203
|
+
* 只用 fetch(),响应体丢掉,浏览器把结果留在 HTTP 缓存里给 pjax 用。
|
|
204
|
+
*/
|
|
205
|
+
function bindPrefetch () {
|
|
206
|
+
if (window.__btfPrefetchBound) return
|
|
207
|
+
window.__btfPrefetchBound = true
|
|
208
|
+
|
|
209
|
+
var conn = navigator.connection || navigator.mozConnection || navigator.webkitConnection
|
|
210
|
+
if (navigator.onLine === false) return
|
|
211
|
+
if (conn && (conn.saveData || /(^|-)2g$/.test(conn.effectiveType || ''))) return
|
|
212
|
+
|
|
213
|
+
var isPhone = window.matchMedia('(max-width: 768px)').matches
|
|
214
|
+
var LIMIT = isPhone ? 3 : 4
|
|
215
|
+
var seen = Object.create(null)
|
|
216
|
+
var count = 0
|
|
217
|
+
|
|
218
|
+
// 只预取「页面」,不预取图片 / 附件 / 锚点 / 外链
|
|
219
|
+
function target (a) {
|
|
220
|
+
if (!a || !a.href) return ''
|
|
221
|
+
if (a.target && a.target !== '_self') return ''
|
|
222
|
+
if (a.hasAttribute('download') || a.getAttribute('rel') === 'nofollow') return ''
|
|
223
|
+
if (a.host !== location.host) return ''
|
|
224
|
+
var url = a.href.split('#')[0]
|
|
225
|
+
if (!url || url === location.href.split('#')[0]) return ''
|
|
226
|
+
if (!/\/($|\?)|\/index\.html$|\.html$/.test(url)) return ''
|
|
227
|
+
return url
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function warm (url) {
|
|
231
|
+
if (!url || seen[url] || count >= LIMIT) return
|
|
232
|
+
seen[url] = 1
|
|
233
|
+
count++
|
|
234
|
+
try {
|
|
235
|
+
// priority 只在较新的 Chrome 上生效,其余浏览器会忽略这个字段
|
|
236
|
+
fetch(url, { credentials: 'same-origin', priority: 'low' })['catch'](function () {})
|
|
237
|
+
} catch (e) {}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function warmFrom (el) {
|
|
241
|
+
var a = el && el.closest ? el.closest('a[href]') : null
|
|
242
|
+
if (a) warm(target(a))
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// 1) 视口预取。按「用户最可能点的顺序」挑候选:
|
|
246
|
+
// 文章卡片 > 翻页 > 侧栏 > 其余(导航菜单排在最后,
|
|
247
|
+
// 因为菜单一共就几个链接,用户很少连着点两次)。
|
|
248
|
+
if ('IntersectionObserver' in window) {
|
|
249
|
+
var GROUPS = [
|
|
250
|
+
'#recent-posts .article-title',
|
|
251
|
+
'#recent-posts .post_cover a[href]',
|
|
252
|
+
'.pagination a[href]',
|
|
253
|
+
'#aside-content a[href]',
|
|
254
|
+
'a[href]'
|
|
255
|
+
]
|
|
256
|
+
|
|
257
|
+
var io = new IntersectionObserver(function (entries) {
|
|
258
|
+
for (var i = 0; i < entries.length; i++) {
|
|
259
|
+
if (!entries[i].isIntersecting) continue
|
|
260
|
+
warm(target(entries[i].target))
|
|
261
|
+
io.unobserve(entries[i].target)
|
|
262
|
+
if (count >= LIMIT) break
|
|
263
|
+
}
|
|
264
|
+
}, { rootMargin: '200px 0px' })
|
|
265
|
+
|
|
266
|
+
var observe = function () {
|
|
267
|
+
// 只观察优先级最高的若干个,避免 200 个链接全挂上观察器
|
|
268
|
+
var picked = []
|
|
269
|
+
var pickedSet = Object.create(null)
|
|
270
|
+
for (var g = 0; g < GROUPS.length && picked.length < LIMIT + 2; g++) {
|
|
271
|
+
var links = document.querySelectorAll(GROUPS[g])
|
|
272
|
+
for (var i = 0; i < links.length && picked.length < LIMIT + 2; i++) {
|
|
273
|
+
var url = target(links[i])
|
|
274
|
+
if (!url || pickedSet[url] || seen[url]) continue
|
|
275
|
+
pickedSet[url] = 1
|
|
276
|
+
picked.push(links[i])
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
for (var k = 0; k < picked.length; k++) io.observe(picked[k])
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// 等首屏渲染完再扫,别和图片抢带宽
|
|
283
|
+
if (window.requestIdleCallback) requestIdleCallback(observe, { timeout: 1500 })
|
|
284
|
+
else setTimeout(observe, 800)
|
|
285
|
+
|
|
286
|
+
document.addEventListener('pjax:complete', function () {
|
|
287
|
+
count = 0
|
|
288
|
+
if (window.requestIdleCallback) requestIdleCallback(observe, { timeout: 1500 })
|
|
289
|
+
else setTimeout(observe, 500)
|
|
290
|
+
})
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// 2) 悬停 / 按下:即时兜底
|
|
294
|
+
var onIntent = function (e) { warmFrom(e.target) }
|
|
295
|
+
document.addEventListener('mouseover', onIntent, { passive: true })
|
|
296
|
+
document.addEventListener('pointerdown', onIntent, { passive: true })
|
|
297
|
+
document.addEventListener('touchstart', onIntent, { passive: true })
|
|
298
|
+
}
|
|
299
|
+
|
|
190
300
|
function initLegacyStyle () {
|
|
191
301
|
categoriesBarActive()
|
|
192
302
|
topCategoriesBarScroll()
|
|
193
303
|
bindScrollPercent()
|
|
194
304
|
bindNavSticky()
|
|
305
|
+
bindPrefetch()
|
|
195
306
|
percent()
|
|
196
307
|
}
|
|
197
308
|
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* themes/butterfly/scripts/filters/perf.js 把 URL 挂到本标签的 data-swiper-*
|
|
13
13
|
* 上,pjax 切回首页时在这里按需补下载。
|
|
14
14
|
* 3) 容器上已有实例时先销毁再重建,避免 pjax 重复初始化。
|
|
15
|
+
* 4) 打开 fadeEffect.crossFade —— 原站配置下(fade + loop)旧幻灯片不会淡出,
|
|
16
|
+
* 切几次就叠成一片,这是之前「banner 偶尔糊掉」的真因,详见下方构造参数处的注释。
|
|
15
17
|
*/
|
|
16
18
|
(function () {
|
|
17
19
|
var self = document.currentScript
|
|
@@ -37,6 +39,11 @@
|
|
|
37
39
|
passiveListeners: true,
|
|
38
40
|
spaceBetween: 30,
|
|
39
41
|
effect: 'fade',
|
|
42
|
+
// 不加 crossFade 的话,Swiper 5.4.5 在 loop + fade 下只给新幻灯片加透明度,
|
|
43
|
+
// 老幻灯片永远停在不透明状态:切 3 次就有 4 张叠在一起,标题糊成一团。
|
|
44
|
+
// 实测(computed opacity):旧幻灯片 1.00 保持不动,新幻灯片 0→1 淡入;
|
|
45
|
+
// 加上之后才是真正的交叉淡入淡出(1.00 → 0.89 → 0.33 → 0.05 → 0)。
|
|
46
|
+
fadeEffect: { crossFade: true },
|
|
40
47
|
loop: true,
|
|
41
48
|
autoplay: {
|
|
42
49
|
disableOnInteraction: false,
|