-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhscript_docs_example.html
More file actions
766 lines (663 loc) · 25.3 KB
/
Copy pathhscript_docs_example.html
File metadata and controls
766 lines (663 loc) · 25.3 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
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=1200, initial-scale=1.0">
<title>NovaFlare Engine | HScript 开发文档</title>
<link rel="stylesheet" href="../../../css/themes.css">
<link rel="stylesheet" href="../../../css/styles.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Noto+Sans+SC:wght@400;500;700&display=swap" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css" rel="stylesheet">
<style>
* {
box-sizing: border-box;
}
body {
font-family: 'Inter', 'Noto Sans SC', sans-serif;
margin: 0;
padding: 0;
background: var(--bg-primary);
color: var(--text-primary);
overflow-x: auto;
min-width: 1200px;
transition: all 0.3s ease;
}
#starfield {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
#theme-toggle, .lang-toggle {
background: var(--bg-button);
border: none;
color: var(--text-primary);
width: 40px;
height: 40px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.3s ease;
}
#theme-toggle:hover, .lang-toggle:hover {
background: var(--bg-button-hover);
transform: translateY(-2px);
}
.lang-toggle {
text-decoration: none;
font-weight: 600;
}
.docs-main {
max-width: 1200px;
margin: 0 auto;
padding: 30px 20px;
min-width: 1200px;
}
.docs-container {
display: flex;
min-height: calc(100vh - 200px);
margin-top: 30px;
gap: 30px;
}
.sidebar {
width: 280px;
background: var(--bg-card);
border-radius: 12px;
padding: 20px;
border: 1px solid var(--border-color);
height: fit-content;
position: sticky;
top: 100px;
backdrop-filter: blur(10px);
}
.sidebar-section {
margin-bottom: 20px;
}
.sidebar-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 0;
cursor: pointer;
font-weight: 600;
color: var(--accent-color);
border-bottom: 1px solid var(--border-color);
transition: all 0.3s ease;
}
.sidebar-header:hover {
color: var(--accent-hover);
}
.sidebar-header i {
transition: transform 0.3s ease;
}
.sidebar-header.active i {
transform: rotate(90deg);
}
.sidebar-items {
padding-left: 15px;
max-height: 0;
overflow: hidden;
transition: max-height 0.5s ease;
}
.sidebar-section.active .sidebar-items {
max-height: 500px;
}
.sidebar-item {
display: block;
padding: 8px 10px;
color: var(--text-secondary);
text-decoration: none;
border-radius: 6px;
margin: 5px 0;
transition: all 0.2s ease;
font-size: 0.9rem;
position: relative;
overflow: hidden;
}
.sidebar-item:before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, var(--accent-transparent), transparent);
transition: left 0.5s ease;
}
.sidebar-item:hover:before, .sidebar-item.active:before {
left: 100%;
}
.sidebar-item:hover, .sidebar-item.active {
background: var(--accent-transparent);
color: var(--accent-color);
}
/* 文档内容样式 */
.docs-content {
flex: 1;
background: var(--bg-card);
border-radius: 12px;
padding: 30px;
border: 1px solid var(--border-color);
backdrop-filter: blur(10px);
position: relative;
overflow: hidden;
min-height: 600px;
}
/* 修改文档内容动画方向 */
.doc-section {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
padding: 30px;
opacity: 0;
transform: translateX(0);
transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
pointer-events: none;
overflow-y: auto;
}
.doc-section.active {
opacity: 1;
transform: translateX(0);
pointer-events: all;
}
/* 下一页进入动画 - 从右侧进入 */
.doc-section.enter-right {
transform: translateX(100%);
opacity: 0;
}
/* 上一页进入动画 - 从左侧进入 */
.doc-section.enter-left {
transform: translateX(-100%);
opacity: 0;
}
/* 下一页退出动画 - 向左侧退出 */
.doc-section.exit-right {
transform: translateX(-100%);
opacity: 0;
}
/* 上一页退出动画 - 向右侧退出 */
.doc-section.exit-left {
transform: translateX(100%);
opacity: 0;
}
.doc-section h2 {
color: var(--accent-color);
margin-bottom: 20px;
font-size: 1.8rem;
border-bottom: 2px solid var(--accent-color);
padding-bottom: 10px;
}
.doc-section h3 {
color: var(--text-primary);
margin: 25px 0 15px;
font-size: 1.4rem;
}
.function-name {
background: var(--accent-color);
color: white;
padding: 6px 12px;
border-radius: 4px;
font-family: monospace;
font-size: 1.1rem;
display: inline-block;
margin-bottom: 15px;
}
.function-explanation, .function-notes {
margin: 15px 0;
line-height: 1.6;
}
.function-notes {
background: rgba(255, 193, 7, 0.1);
border-left: 4px solid #ffc107;
padding: 15px;
border-radius: 4px;
}
.code-block {
margin: 20px 0;
border-radius: 8px;
overflow: hidden;
}
.code-header {
background: #2d2d2d;
color: #ccc;
padding: 10px 15px;
font-family: monospace;
font-size: 0.9rem;
display: flex;
justify-content: space-between;
align-items: center;
}
.code-copy {
background: none;
border: none;
color: #ccc;
cursor: pointer;
font-size: 0.8rem;
}
.function-warning {
background: var(--warning-bg);
border-left: 4px solid var(--warning-color);
padding: 15px;
border-radius: 4px;
animation: fadeIn 0.5s ease;
}
.function-tip {
background: var(--tip-bg);
border-left: 4px solid var(--tip-color);
padding: 15px;
border-radius: 4px;
animation: fadeIn 0.5s ease;
}
pre[class*="language-"] {
margin: 0;
border-radius: 0;
background: var(--code-bg) !important;
}
/* 导航按钮 */
.doc-navigation {
display: flex;
justify-content: space-between;
margin-top: 40px;
padding-top: 20px;
border-top: 1px solid var(--border-color);
}
.nav-btn {
display: flex;
align-items: center;
gap: 8px;
padding: 12px 24px;
background: var(--accent-color);
color: white;
border: none;
border-radius: 6px;
cursor: pointer;
transition: all 0.3s ease;
text-decoration: none;
font-weight: 500;
box-shadow: 0 4px 6px var(--shadow-color);
}
.nav-btn:hover {
background: var(--accent-hover);
transform: translateY(-2px);
box-shadow: 0 6px 12px var(--shadow-hover);
}
.nav-btn.prev {
background: var(--bg-button);
color: var(--text-primary);
}
.nav-btn.prev:hover {
background: var(--bg-button-hover);
}
.footer {
background: var(--bg-footer);
border-top: 1px solid var(--border-color);
padding: 40px 0 20px;
margin-top: 50px;
min-width: 1200px;
}
.footer .container {
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
display: flex;
flex-direction: column;
align-items: center;
gap: 20px;
}
.footer-content p {
margin: 0;
font-size: 1.2rem;
font-weight: 600;
}
.footer-links {
display: flex;
gap: 20px;
list-style: none;
padding: 0;
margin: 0;
}
.footer-links a {
color: var(--text-secondary);
text-decoration: none;
transition: color 0.3s ease;
}
.footer-links a:hover {
color: var(--accent-color);
}
.footer-social {
display: flex;
gap: 15px;
}
.footer-social a {
color: var(--text-secondary);
font-size: 1.2rem;
transition: all 0.3s ease;
}
.footer-social a:hover {
color: var(--accent-color);
transform: translateY(-3px);
}
/* 动画 */
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes slideUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.fade-in {
animation: fadeIn 0.5s ease;
}
.slide-up {
animation: slideUp 0.5s ease;
}
</style>
</head>
<body>
<canvas id="starfield"></canvas>
<div class="particles" id="particles"></div>
<nav class="navbar">
<div class="container navbar-container">
<div class="navbar-logo">
<h1>新星闪耀引擎</h1>
</div>
<div class="navbar-menu">
<div class="navbar-actions">
<button id="theme-toggle" aria-label="切换主题">
<i class="fas fa-moon"></i>
</button>
<a href="../../en/hscript/hscript_readme.html" class="lang-toggle" aria-label="切换到英文">
<span>EN</span>
</a>
</div>
</div>
</div>
</nav>
<main class="docs-main">
<div class="container">
<div class="docs-container">
<aside class="sidebar">
<!-- 侧边栏将由JavaScript生成 -->
</aside>
<!-- 文档内容区域 -->
<div class="docs-content">
<!-- 文档抽屉块将在这里动态生成 -->
</div>
</div>
</div>
</main>
<footer class="footer">
<div class="container">
<div class="footer-content">
<p>NovaFlare Engine 开发文档</p>
</div>
<ul class="footer-links">
<li><a href="../../../index.html">首页</a></li>
<li><a href="../../../docs-choose.html">文档</a></li>
<li><a href="../../../index.html#download">下载</a></li>
<li><a href="../../../index.html#community">社区</a></li>
</ul>
<div class="footer-social">
<a href="https://discord.gg/FkEwvRW2YZ" target="_blank" aria-label="Discord"><i class="fab fa-discord"></i></a>
<a href="https://github.com/NovaFlare-Engine-Concentration/FNF-NovaFlare-Engine/" target="_blank" aria-label="GitHub"><i class="fab fa-github"></i></a>
<a href="https://youtube.com/@beihu235" target="_blank" aria-label="YouTube"><i class="fab fa-youtube"></i></a>
</div>
<div class="footer-copyright">
<!--<p>© 2025 NovaFlare Engine. <span>保留所有权利。</span></p>-->
</div>
</div>
</footer>
<!-- 代码高亮脚本 -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-javascript.min.js"></script>
<script>
// 侧边栏数据
const sidebarData = [
{
title: "大标题",
icon: "fa-code",
items: [
{ name: "标题", id: "intro" },
]
}
];
// 文档内容数据
const contentData = {
"intro": {
title: "大标题",
content: `
<div class="doc-section" id="array-example">
<h2>小标题</h2>
<div class="function-notes slide-up">
<h3>提示</h3>
<ul>
<li>
提示内容
</li>
</ul>
</div>
<div class="function-example slide-up">
<h3>标题</h3>
<div class="code-block">
<div class="code-header">
<span>代码类型</span>
<button class="code-copy">复制</button>
</div>
<pre><code class="language-javascript">
</code></pre>
</div>
</div>
<div class="doc-navigation">
<button class="nav-btn prev" data-prev="上一页标签">
<i class="fas fa-arrow-left"></i> 上一页
</button>
<button class="nav-btn next" data-next="下一页标签">
下一页 <i class="fas fa-arrow-right"></i>
</button>
</div>
</div>
`
}
};
// 初始化文档
document.addEventListener('DOMContentLoaded', function() {
// 生成侧边栏
generateSidebar();
// 生成文档内容
generateContent();
// 显示默认内容
showContent('intro');
// 初始化交互功能
initInteractions();
// 强制电脑模式
forceDesktopMode();
});
// 强制电脑模式
function forceDesktopMode() {
// 设置视口为固定宽度
const viewport = document.querySelector('meta[name="viewport"]');
if (viewport) {
viewport.setAttribute('content', 'width=1200, initial-scale=1.0');
}
}
// 生成侧边栏
function generateSidebar() {
const sidebar = document.querySelector('.sidebar');
sidebarData.forEach(section => {
const sectionElement = document.createElement('div');
sectionElement.className = 'sidebar-section active';
sectionElement.innerHTML = `
<div class="sidebar-header">
<span><i class="fas ${section.icon} me-2"></i> ${section.title}</span>
<i class="fas fa-chevron-down"></i>
</div>
<div class="sidebar-items">
${section.items.map(item =>
`<a href="#" class="sidebar-item" data-id="${item.id}">${item.name}</a>`
).join('')}
</div>
`;
sidebar.appendChild(sectionElement);
});
}
// 生成文档内容
function generateContent() {
const contentElement = document.querySelector('.docs-content');
// 将所有内容添加到文档中
Object.keys(contentData).forEach(key => {
contentElement.innerHTML += contentData[key].content;
});
}
function showContent(contentId, direction = 'next') {
// 获取当前活动的内容
const currentActive = document.querySelector('.doc-section.active');
if (currentActive && currentActive.id !== contentId) {
// 根据方向设置不同的动画类
const exitClass = direction === 'next' ? 'exit-right' : 'exit-left';
const enterClass = direction === 'next' ? 'enter-right' : 'enter-left';
// 添加退出动画类
currentActive.classList.add(exitClass);
// 等待退出动画完成
setTimeout(() => {
currentActive.classList.remove('active', exitClass);
// 显示新内容
const targetSection = document.getElementById(contentId);
if (targetSection) {
// 添加进入动画类
targetSection.classList.add(enterClass);
targetSection.classList.add('active');
// 强制重绘,确保动画生效
targetSection.offsetHeight;
// 移除进入动画类,触发过渡
setTimeout(() => {
targetSection.classList.remove(enterClass);
}, 10);
// 更新页面标题
document.title = `NovaFlare Engine | ${contentData[contentId].title}`;
// 高亮当前菜单项
document.querySelectorAll('.sidebar-item').forEach(item => {
item.classList.remove('active');
if (item.getAttribute('data-id') === contentId) {
item.classList.add('active');
}
});
// 重新高亮代码
setTimeout(() => {
if (window.Prism) {
Prism.highlightAllUnder(targetSection);
}
}, 100);
}
}, 300);
} else if (!currentActive) {
// 首次加载
const targetSection = document.getElementById(contentId);
if (targetSection) {
targetSection.classList.add('active');
// 更新页面标题
document.title = `NovaFlare Engine | ${contentData[contentId].title}`;
// 高亮当前菜单项
document.querySelectorAll('.sidebar-item').forEach(item => {
item.classList.remove('active');
if (item.getAttribute('data-id') === contentId) {
item.classList.add('active');
}
});
// 重新高亮代码
setTimeout(() => {
if (window.Prism) {
Prism.highlightAllUnder(targetSection);
}
}, 100);
}
}
}
// 初始化交互功能
function initInteractions() {
// 侧边栏展开/折叠
const sidebarHeaders = document.querySelectorAll('.sidebar-header');
sidebarHeaders.forEach(header => {
header.addEventListener('click', function() {
const section = this.parentElement;
section.classList.toggle('active');
this.querySelector('i:last-child').classList.toggle('fa-chevron-down');
this.querySelector('i:last-child').classList.toggle('fa-chevron-right');
});
});
// 侧边栏项点击
const sidebarItems = document.querySelectorAll('.sidebar-item');
sidebarItems.forEach(item => {
item.addEventListener('click', function(e) {
e.preventDefault();
const contentId = this.getAttribute('data-id');
showContent(contentId);
});
});
document.addEventListener('click', function(e) {
if (e.target.closest('.nav-btn.next')) {
const nextId = e.target.closest('.nav-btn.next').getAttribute('data-next');
showContent(nextId, 'next'); // 传递方向参数
} else if (e.target.closest('.nav-btn.prev')) {
const prevId = e.target.closest('.nav-btn.prev').getAttribute('data-prev');
showContent(prevId, 'prev'); // 传递方向参数
}
});
// 侧边栏项点击使用默认方向
sidebarItems.forEach(item => {
item.addEventListener('click', function(e) {
e.preventDefault();
const contentId = this.getAttribute('data-id');
showContent(contentId, 'next'); // 侧边栏点击使用下一页动画
});
});
// 代码复制功能
initCodeCopy();
// 主题切换
document.getElementById('theme-toggle').addEventListener('click', function() {
document.body.classList.toggle('light-theme');
this.querySelector('i').classList.toggle('fa-moon');
this.querySelector('i').classList.toggle('fa-sun');
});
}
// 初始化代码复制功能
function initCodeCopy() {
const copyButtons = document.querySelectorAll('.code-copy');
copyButtons.forEach(button => {
button.addEventListener('click', function() {
const codeBlock = this.closest('.code-block').querySelector('code');
const textArea = document.createElement('textarea');
textArea.value = codeBlock.textContent;
document.body.appendChild(textArea);
textArea.select();
document.execCommand('copy');
document.body.removeChild(textArea);
// 显示复制成功提示
const originalText = this.textContent;
this.textContent = '已复制!';
setTimeout(() => {
this.textContent = originalText;
}, 2000);
});
});
}
</script>
<script src="../../../js/starfield.js"></script>
<script src="../../../js/theme.js"></script>
</body>
</html>