-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoc.html
More file actions
129 lines (115 loc) · 4.4 KB
/
Copy pathdoc.html
File metadata and controls
129 lines (115 loc) · 4.4 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
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>文档查看 - Hybrid Talent Computing</title>
<link rel="stylesheet" href="styles/main.css">
<link rel="stylesheet" href="styles/docs.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/themes/prism-tomorrow.min.css">
<style>
.doc-container {
max-width: 900px;
margin: 2rem auto;
padding: 2rem;
background: rgba(0, 0, 0, 0.7);
border-radius: 10px;
box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
}
.doc-title {
color: #7fffd4;
text-align: center;
font-size: 2.5rem;
margin-bottom: 2rem;
text-shadow: 0 0 10px rgba(127, 255, 212, 0.5);
}
.doc-content {
color: #fff;
line-height: 1.8;
font-size: 1.1rem;
}
.doc-content h1, .doc-content h2, .doc-content h3 {
color: #7fffd4;
margin-top: 2rem;
margin-bottom: 1rem;
}
.doc-content code {
background: rgba(0, 0, 0, 0.5);
padding: 0.2em 0.4em;
border-radius: 3px;
font-family: 'Courier New', monospace;
}
.doc-content pre {
background: rgba(0, 0, 0, 0.5);
padding: 1rem;
border-radius: 5px;
overflow-x: auto;
margin: 1rem 0;
}
.back-button {
position: fixed;
top: 2rem;
left: 2rem;
padding: 0.5rem 1rem;
background: rgba(127, 255, 212, 0.2);
color: #7fffd4;
border: 1px solid #7fffd4;
border-radius: 5px;
cursor: pointer;
transition: all 0.3s ease;
text-decoration: none;
}
.back-button:hover {
background: rgba(127, 255, 212, 0.3);
box-shadow: 0 0 10px rgba(127, 255, 212, 0.5);
}
</style>
</head>
<body>
<a href="index.html" class="back-button">返回首页</a>
<div class="doc-container">
<h1 class="doc-title" id="doc-title"></h1>
<div class="doc-content" id="doc-content"></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/4.0.2/marked.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/prism.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/components/prism-javascript.min.js"></script>
<script>
async function loadDocument() {
const urlParams = new URLSearchParams(window.location.search);
const docId = urlParams.get('id');
if (!docId) {
window.location.href = 'index.html';
return;
}
try {
const response = await fetch(`/docs/${docId}.md`);
const content = await response.text();
const title = content.split('\n')[0].replace('#', '').trim();
document.getElementById('doc-title').textContent = title;
const markedOptions = {
gfm: true,
breaks: true,
highlight: function(code, lang) {
if (Prism && lang) {
try {
return Prism.highlight(code, Prism.languages[lang], lang);
} catch (e) {
return code;
}
}
return code;
}
};
marked.setOptions(markedOptions);
document.getElementById('doc-content').innerHTML = marked.parse(content);
} catch (error) {
console.error('加载文档失败:', error);
document.getElementById('doc-title').textContent = '文档加载失败';
document.getElementById('doc-content').innerHTML = '<p>抱歉,无法加载所请求的文档。</p>';
}
}
document.addEventListener('DOMContentLoaded', loadDocument);
</script>
</body>
</html>