-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocumentation.html
More file actions
729 lines (626 loc) · 25 KB
/
documentation.html
File metadata and controls
729 lines (626 loc) · 25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ColorFulCraft | 技术文档中心</title>
<link rel="icon" href="pictures/favicon.ico">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
<style>
:root {
--primary-color: #667eea;
--secondary-color: #764ba2;
--text-color: #333;
--bg-color: rgba(255, 255, 255, 0.95);
--sidebar-bg: rgba(255, 255, 255, 0.95);
--border-color: rgba(0, 0, 0, 0.1);
--code-bg: #f6f8fa;
--gradient-start: #ee7752;
--gradient-middle1: #e73c7e;
--gradient-middle2: #23a6d5;
--gradient-end: #23d5ab;
}
.dark-mode {
--primary-color: #5b8def;
--secondary-color: #6a4bd1;
--text-color: #f0f0f0;
--bg-color: rgba(30, 30, 40, 0.95);
--sidebar-bg: rgba(30, 30, 40, 0.95);
--border-color: rgba(255, 255, 255, 0.1);
--code-bg: #2d2d3d;
--gradient-start: #667eea;
--gradient-middle1: #764ba2;
--gradient-middle2: #23a6d5;
--gradient-end: #23d5ab;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body, #app { height: 100%; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
color: var(--text-color);
background: #fff;
transition: all 0.3s ease;
}
/* 渐变背景 - 保持与主页一致 */
.gradient-bg {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(-45deg,
var(--gradient-start),
var(--gradient-middle1),
var(--gradient-middle2),
var(--gradient-end));
background-size: 400% 400%;
animation: gradientFlow 15s ease infinite;
z-index: -2;
}
@keyframes gradientFlow {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
.content-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.7);
backdrop-filter: blur(3px);
z-index: -1;
transition: background 0.3s ease;
}
.dark-mode .gradient-bg {
filter: brightness(0.7) saturate(1.3);
}
.dark-mode .content-overlay {
background: rgba(0, 0, 0, 0.7);
}
/* 🔧 返回按钮样式 - 跟随主页主题 */
.back-button {
position: fixed;
top: 20px;
left: 20px;
z-index: 1000;
}
.back-btn {
padding: 12px 24px;
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
color: white;
border: none;
border-radius: 25px;
transition: all 0.3s ease;
backdrop-filter: blur(10px);
border: 2px solid rgba(255, 255, 255, 0.3);
cursor: pointer;
display: flex;
align-items: center;
gap: 8px;
font-weight: 600;
font-size: 0.95rem;
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
animation: btnPulse 2.5s infinite ease-in-out;
}
@keyframes btnPulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.05); }
}
.back-btn:hover {
transform: translateY(-2px) scale(1.05);
box-shadow: 0 6px 25px rgba(102, 126, 234, 0.4);
animation: none;
}
#app {
position: relative;
z-index: 1;
min-height: 100vh;
padding: 80px 16px 40px;
}
/* 📝 修复 markdown 文字颜色 */
.markdown-section {
max-width: 980px !important;
margin: 0 auto !important;
padding: 40px !important;
background: var(--bg-color) !important;
backdrop-filter: blur(10px) !important;
border-radius: 15px !important;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1) !important;
border: 1px solid var(--border-color) !important;
color: var(--text-color) !important;
transition: all 0.3s ease !important;
}
/* 确保所有文本元素都使用正确的颜色 */
.markdown-section h1,
.markdown-section h2,
.markdown-section h3,
.markdown-section h4,
.markdown-section h5,
.markdown-section h6,
.markdown-section p,
.markdown-section li,
.markdown-section td,
.markdown-section th,
.markdown-section blockquote {
color: var(--text-color) !important;
}
.markdown-section a {
color: var(--primary-color) !important;
transition: color 0.2s ease !important;
}
.markdown-section a:hover {
color: var(--secondary-color) !important;
text-decoration: underline !important;
}
.markdown-section code {
background: var(--code-bg) !important;
color: var(--text-color) !important;
padding: 2px 6px !important;
border-radius: 4px !important;
}
.markdown-section pre {
background: var(--code-bg) !important;
border: 1px solid var(--border-color) !important;
color: var(--text-color) !important;
}
/* 📚 侧边栏样式 */
.sidebar {
background: var(--sidebar-bg) !important;
backdrop-filter: blur(10px) !important;
border-right: 1px solid var(--border-color) !important;
transition: all 0.3s ease !important;
}
.sidebar ul li a {
color: var(--text-color) !important;
transition: all 0.2s ease !important;
}
.sidebar ul li a:hover {
color: var(--primary-color) !important;
background: rgba(var(--primary-color), 0.1) !important;
}
/* 🔍 搜索框样式调整 */
.search {
position: relative !important;
z-index: 1001 !important;
}
.search input {
background: var(--bg-color) !important;
color: var(--text-color) !important;
border: 1px solid var(--border-color) !important;
backdrop-filter: blur(10px) !important;
}
.search input::placeholder {
color: rgba(var(--text-color), 0.6) !important;
}
/* 搜索结果样式 */
.search .results-panel {
background: var(--bg-color) !important;
border: 1px solid var(--border-color) !important;
color: var(--text-color) !important;
}
.search .matching-post {
border-bottom: 1px solid var(--border-color) !important;
}
.search .matching-post a {
color: var(--text-color) !important;
}
.search .matching-post a:hover {
color: var(--primary-color) !important;
background: rgba(var(--primary-color), 0.1) !important;
}
/* 🎨 其他元素颜色修复 */
.markdown-section blockquote {
border-left-color: var(--primary-color) !important;
background: rgba(var(--primary-color), 0.05) !important;
}
.markdown-section table {
border-color: var(--border-color) !important;
}
.markdown-section table th {
background: rgba(var(--primary-color), 0.1) !important;
}
.markdown-section table td {
border-color: var(--border-color) !important;
}
/* 主题切换按钮 */
.theme-toggle-btn {
position: fixed;
top: 20px;
right: 20px;
width: 50px;
height: 50px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.2);
backdrop-filter: blur(10px);
border: none;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
transition: all 0.3s ease;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
font-size: 1.5rem;
}
.theme-toggle-btn:hover {
transform: scale(1.1);
background: rgba(255, 255, 255, 0.3);
}
.dark-mode .theme-toggle-btn {
background: rgba(255, 165, 0, 0.3);
}
.dark-mode .theme-toggle-btn:hover {
background: rgba(255, 165, 0, 0.5);
}
/* 📱 响应式调整 */
@media (max-width: 768px) {
.markdown-section {
margin: 10px !important;
padding: 20px !important;
}
.back-button {
top: 10px;
left: 10px;
}
.back-btn {
padding: 10px 16px;
font-size: 0.9rem;
}
#app {
padding: 70px 10px 20px;
}
.theme-toggle-btn {
top: 10px;
right: 10px;
width: 40px;
height: 40px;
font-size: 1.2rem;
}
}
/* 大屏幕调整返回按钮位置 */
@media (min-width: 769px) {
/* 动态调整返回按钮位置,避免遮挡搜索框 */
.sidebar ~ .back-button {
left: 320px; /* 侧边栏宽度 + 边距 */
}
}
/* Docsify 特定样式修复 */
.app-nav,
.app-name,
.sidebar-toggle,
.sidebar-nav,
.anchor {
color: var(--text-color) !important;
}
.sidebar-toggle span {
background-color: var(--text-color) !important;
}
/* 确保代码块内的文字可见 */
.dark-mode pre[class*="language-"] {
text-shadow: none !important;
}
/* 链接在暗色模式下的hover效果 */
.dark-mode a:hover {
color: #71b7ff !important;
}
/* 图片缩放插件的暗色模式适配 */
.medium-zoom-overlay,
.medium-zoom-image--opened {
background: rgba(0, 0, 0, 0.9) !important;
z-index: 9999 !important;
}
/* 确保侧边栏滚动条可见 */
.sidebar::-webkit-scrollbar {
width: 6px;
}
.sidebar::-webkit-scrollbar-track {
background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
background: rgba(var(--text-color), 0.2);
border-radius: 3px;
}
.dark-mode .sidebar::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.2);
}
</style>
</head>
<body>
<div class="gradient-bg"></div>
<div class="content-overlay"></div>
<div class="back-button" id="backButton">
<button class="back-btn" onclick="goToHomePage()">
<span>←</span> 返回主页
</button>
</div>
<!-- 主题切换按钮 -->
<button class="theme-toggle-btn" id="themeToggle">🌙</button>
<div id="app">正在加载文档系统...</div>
<script>
// 🎯 从主页同步主题
function syncThemeFromHomePage() {
try {
// 1. 首先检查URL参数
const urlParams = new URLSearchParams(window.location.search);
const themeFromUrl = urlParams.get('theme');
// 2. 检查localStorage(主页使用的键名)
const themeFromStorage = localStorage.getItem('theme');
// 3. 检查主页通过localStorage传递的主题
const themeFromHome = localStorage.getItem('cfc-theme-sync');
let parsedTheme = null;
if (themeFromHome) {
try {
parsedTheme = JSON.parse(themeFromHome);
} catch(e) { /* 忽略解析错误 */ }
}
// 优先级:URL参数 > 主页同步 > localStorage存储
let theme = themeFromUrl ||
(parsedTheme && parsedTheme.theme) ||
themeFromStorage ||
'dark'; // 默认暗色模式
console.log('🎨 主题同步:', {
themeFromUrl,
themeFromStorage,
parsedTheme,
finalTheme: theme
});
setTheme(theme);
// 保存主题到主页可能使用的键名,确保一致性
localStorage.setItem('theme', theme);
localStorage.setItem('cfc-theme-sync', JSON.stringify({
type: 'theme-change',
theme: theme,
timestamp: Date.now(),
source: 'documentation-page'
}));
} catch (e) {
console.warn('主题同步失败:', e);
setTheme('dark');
}
}
function setTheme(theme) {
const body = document.body;
const themeToggle = document.getElementById('themeToggle');
if (theme === 'dark') {
body.classList.add('dark-mode');
themeToggle.textContent = '☀️';
} else {
body.classList.remove('dark-mode');
themeToggle.textContent = '🌙';
}
// 保存主题设置
localStorage.setItem('theme', theme);
localStorage.setItem('cfc-docs-theme', theme);
console.log('🎨 主题已设置为:', theme);
}
// 返回主页函数 - 同步主题
function goToHomePage() {
const currentTheme = document.body.classList.contains('dark-mode') ? 'dark' : 'light';
// 保存主题状态,供主页读取
localStorage.setItem('last-docs-theme', JSON.stringify({
theme: currentTheme,
timestamp: Date.now(),
source: 'documentation-page'
}));
// 使用主页可能检查的键名
localStorage.setItem('theme', currentTheme);
// 跳转回主页
window.location.href = `index.html?theme=${currentTheme}`;
}
// 主题切换功能
function toggleTheme() {
const isDark = document.body.classList.contains('dark-mode');
const newTheme = isDark ? 'light' : 'dark';
setTheme(newTheme);
// 发送主题变化事件到主页
const themeEvent = {
type: 'theme-change',
theme: newTheme,
timestamp: Date.now(),
source: 'documentation-toggle'
};
localStorage.setItem('docs-theme-update', JSON.stringify(themeEvent));
localStorage.setItem('cfc-theme-sync', JSON.stringify(themeEvent));
// 触发 storage 事件,让主页监听
window.dispatchEvent(new StorageEvent('storage', {
key: 'docs-theme-update',
newValue: JSON.stringify(themeEvent)
}));
// 3秒后清理
setTimeout(() => {
localStorage.removeItem('docs-theme-update');
}, 3000);
}
// 📱 动态调整返回按钮位置,避免遮挡搜索框
function adjustBackButtonPosition() {
const backButton = document.getElementById('backButton');
if (!backButton) return;
const searchInput = document.querySelector('.search input');
const sidebar = document.querySelector('.sidebar');
if (searchInput && window.innerWidth > 768) {
const searchRect = searchInput.getBoundingClientRect();
// 如果搜索框存在且可能会被遮挡
if (searchRect.left < 220) { // 返回按钮大约宽度
backButton.style.left = (searchRect.right + 20) + 'px';
} else {
backButton.style.left = '20px';
}
} else if (sidebar && window.innerWidth > 768) {
// 有侧边栏时,放在侧边栏右边
const sidebarRect = sidebar.getBoundingClientRect();
backButton.style.left = (sidebarRect.right + 20) + 'px';
} else {
// 默认位置
backButton.style.left = '20px';
}
}
// 🎯 docsify 配置 - 修复的关键部分
window.$docsify = {
name: '🏛️ ColorFulCraft 技术文档中心',
repo: 'ColorFulCraft/CFCHistory',
// 📁 文档配置 - 修复路径设置
basePath: './docs/', // 改为相对路径
loadSidebar: true,
subMaxLevel: 3,
auto2top: true,
homepage: 'README.md', // 明确指定首页
alias: {
'/.*/_sidebar.md': '/_sidebar.md',
'/': '/README.md', // 根路径映射到README
'': '/README.md' // 空路径也映射
},
// 🔍 搜索配置
search: {
paths: 'auto',
placeholder: '🔍 搜索文档...',
noData: '😅 没有找到相关结果',
depth: 3,
namespace: 'cfc-docs',
hideOtherSidebarContent: false
},
// 📄 侧边栏配置
sidebarDisplayLevel: 2,
loadNavbar: false,
// 📖 封面页配置
coverpage: false,
notFoundPage: {
'/': '/404.md', // 根路径404时显示404页面
'default': '/404.md' // 默认404页面
},
// ⚙️ 插件配置 - 完全简化,让 docsify 处理路由
plugins: [
function(hook, vm) {
hook.init(function() {
// 从主页同步主题
syncThemeFromHomePage();
});
hook.beforeEach(function(content, next) {
const file = vm.route.file || 'README.md';
// 修复编辑链接
const editUrl = `https://github.com/ColorFulCraft/CFCHistory/blob/main/docs/${file}`;
// 添加页脚信息(所有页面都添加)
content += '\n\n---\n\n' +
'> **📂 文档信息** | 最后更新: ' + new Date().toLocaleDateString('zh-CN') +
' | [在 GitHub 上编辑此页](' + editUrl + ')\n';
next(content);
});
hook.mounted(function() {
// 添加主题切换按钮事件
document.getElementById('themeToggle').addEventListener('click', toggleTheme);
// 初始化调整按钮位置
setTimeout(() => {
adjustBackButtonPosition();
// 监听搜索框的出现
const observer = new MutationObserver(() => {
adjustBackButtonPosition();
});
observer.observe(document.body, {
childList: true,
subtree: true
});
}, 500);
});
hook.doneEach(function() {
// 确保所有文字颜色正确
document.querySelectorAll('.markdown-section *').forEach(el => {
if (getComputedStyle(el).color === 'rgb(51, 51, 51)' ||
getComputedStyle(el).color === 'rgb(68, 68, 68)' ||
getComputedStyle(el).color === 'rgb(0, 0, 0)') {
el.style.color = 'var(--text-color)';
}
});
// 动态调整返回按钮位置
setTimeout(adjustBackButtonPosition, 100);
// 为图片添加主题适配
document.querySelectorAll('.markdown-section img').forEach(img => {
img.style.maxWidth = '100%';
img.style.borderRadius = '8px';
img.style.boxShadow = '0 2px 8px rgba(0,0,0,0.1)';
});
// 为外部链接添加标识
document.querySelectorAll('.markdown-section a[href^="http"]').forEach(link => {
if (!link.href.includes(window.location.hostname)) {
link.target = '_blank';
link.rel = 'noopener noreferrer';
if (!link.querySelector('.external-icon')) {
link.innerHTML += ' <span style="font-size:0.8em;">↗</span>';
}
}
});
// 移除之前的链接修复逻辑,让 docsify 处理
// 只添加一个简单的404处理
setTimeout(() => {
const markdownSection = document.querySelector('.markdown-section');
if (markdownSection && markdownSection.textContent.includes('找不到该页面')) {
console.log('检测到404页面');
// 可以在这里添加自定义404处理
}
}, 500);
});
hook.afterEach(function() {
// 文档切换时重新调整按钮位置
setTimeout(() => {
adjustBackButtonPosition();
}, 300);
});
}
]
};
// 页面加载
document.addEventListener('DOMContentLoaded', function() {
console.log('📚 文档页面加载 - 当前URL:', window.location.href);
console.log('当前哈希:', location.hash);
// 同步主题
syncThemeFromHomePage();
// 设置主题切换按钮事件
document.getElementById('themeToggle').addEventListener('click', toggleTheme);
// 监听窗口大小变化
window.addEventListener('resize', adjustBackButtonPosition);
// 监听侧边栏切换
document.addEventListener('click', function(e) {
if (e.target.closest('.sidebar-toggle')) {
setTimeout(adjustBackButtonPosition, 500);
}
});
// 监听来自主页的主题变化
window.addEventListener('storage', function(e) {
if (e.key === 'cfc-theme-sync') {
try {
const themeData = JSON.parse(e.newValue);
if (themeData && themeData.theme && themeData.source !== 'documentation-page') {
console.log('📱 收到主页主题更新:', themeData.theme);
setTheme(themeData.theme);
}
} catch (error) {
console.warn('主题同步解析错误:', error);
}
}
});
// 初始调整按钮位置
setTimeout(adjustBackButtonPosition, 1000);
// 简化初始加载逻辑
function ensureInitialLoad() {
const hash = location.hash;
console.log('初始加载检查 - 当前哈希:', hash);
// 只在完全为空时才重定向到首页
if (!hash || hash === '#' || hash === '') {
console.log('空哈希,重定向到首页');
location.hash = '#/README.md';
}
}
// 延迟执行,确保 docsify 已初始化
setTimeout(ensureInitialLoad, 100);
// 监听哈希变化,用于调试
window.addEventListener('hashchange', function() {
console.log('哈希变化到:', location.hash);
});
});
</script>
<!-- 📚 Docsify 核心库 -->
<script src="https://cdn.jsdelivr.net/npm/docsify@4"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify@4/lib/plugins/search.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify@4/lib/plugins/zoom-image.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify-copy-code@2"></script>
</body>
</html>