-
Notifications
You must be signed in to change notification settings - Fork 947
Expand file tree
/
Copy pathindex.html
More file actions
344 lines (326 loc) · 13.2 KB
/
index.html
File metadata and controls
344 lines (326 loc) · 13.2 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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>Golang面试题大全</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="本项目收集了各个联网大厂常见面试题,以及经典算法题和架构师级别的项目设计题目。">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@latest/lib/themes/vue.css">
<style>
/* 脚注样式 */
.footnote {
margin-top: 20px;
padding: 10px;
background-color: #f8f9fa;
border-left: 4px solid #42b883;
font-size: 0.9em;
line-height: 1.4;
}
.footnote p {
margin: 0;
}
sup a {
color: #42b883;
text-decoration: none;
font-weight: bold;
}
sup a:hover {
text-decoration: underline;
}
.footnote a {
color: #42b883;
text-decoration: none;
margin-left: 5px;
}
.footnote a:hover {
text-decoration: underline;
}
/* Mermaid图表样式 */
.mermaid {
text-align: center;
margin: 20px 0;
}
.mermaid svg {
max-width: 100%;
height: auto;
}
/* Logo样式 */
.app-name-link {
display: flex !important;
align-items: center;
justify-content: center;
width: 100%;
padding: 10px 0;
}
.app-name-link img {
max-height: 60px;
width: auto;
margin: 0 auto;
vertical-align: middle;
display: block !important;
}
.app-name {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
}
/* 隐藏文字,只显示logo */
.app-name-link .app-name-text {
display: none;
}
/* 调整侧边栏logo区域 */
.sidebar .app-name {
text-align: center;
padding: 15px 0;
}
/* 语言切换器样式 */
.app-nav {
position: fixed;
right: 20px;
top: 20px;
z-index: 10;
}
.app-nav ul {
list-style: none;
margin: 0;
padding: 0;
}
.app-nav li {
display: inline-block;
}
#lang-selector {
background: #fff;
border: 1px solid #ddd;
border-radius: 4px;
padding: 6px 12px;
font-size: 14px;
cursor: pointer;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
#lang-selector:hover {
border-color: #42b883;
}
#lang-selector:focus {
outline: none;
border-color: #42b883;
box-shadow: 0 0 0 2px rgba(66, 184, 131, 0.2);
}
/* 修复表格渲染问题:恢复表格的默认布局行为,覆盖 docsify 默认的 display: block */
.markdown-section table {
display: table;
width: auto;
max-width: 100%;
table-layout: auto;
}
</style>
</head>
<body>
<div id="app"></div>
<script src="//cdn.jsdelivr.net/npm/mermaid@8.0.0-rc.8/dist/mermaid.min.js"></script>
<script>
window.$docsify = {
name: 'Golang面试题',
repo: 'https://github.com/lifei6671/interview-go',
logo: './logo.jpg',
loadSidebar: true,
auto2top: true,
subMaxLevel: 3,
alias: {
'/.*/_sidebar.md': '/sidebar.md'
},
search: {
maxAge: 86400000,
paths: 'auto',
placeholder: {
'/en/': '🔍 Search',
'/': '🔍 搜索'
},
noData: {
'/en/': '😞 No Results',
'/': '😞 找不到结果'
},
depth: 6
},
pagination: {
previousText: {
'/en/': 'Previous',
'/': '上一章节'
},
nextText: {
'/en/': 'Next',
'/': '下一章节'
}
},
count: {
countable: true,
fontsize: '0.9em',
color: 'rgb(90,90,90)',
language: 'chinese'
},
plugins: [
function(hook, vm) {
hook.beforeEach(function (html) {
// 渲染前仅处理脚注“引用”,并避免匹配定义行 [^x]:
html = html.replace(/\[\^([^\]]+)\](?!:)/g, '<sup class="footnote-ref"><a href="#fn-$1" data-footnote-ref="$1" id="fnref-$1">$1</a></sup>');
return html;
});
// 渲染后处理脚注“定义”,保留 Markdown 已生成的外链等 HTML
hook.afterEach(function (html, next) {
try {
html = html.replace(/<p>\s*\[\^([^\]]+)\]:\s*([\s\S]*?)<\/p>/g, function(_, id, content) {
return '<div class="footnote" id="fn-' + id + '"><p>' + content + ' <a href="#fnref-' + id + '">↩</a></p></div>';
});
} catch (e) { /* 忽略 */ }
next(html);
});
hook.doneEach(function () {
try {
// 重新绑定点击事件,拦截脚注链接,平滑滚动到同页目标
var prev = window.__footnoteContainer;
var prevHandler = window.__footnoteHandler;
if (prev && prevHandler) {
prev.removeEventListener('click', prevHandler, true);
}
var container = document.querySelector('.markdown-section');
if (!container) return;
var handler = function (e) {
var a = e.target && e.target.closest ? e.target.closest('a') : null;
if (!a) return;
var href = a.getAttribute('href') || '';
if (!/^#(fn-|fnref-)/.test(href)) return;
var targetId = href.slice(1);
var el = document.getElementById(targetId);
if (!el) return;
e.preventDefault();
e.stopPropagation();
try { el.scrollIntoView({ behavior: 'smooth', block: 'start' }); }
catch (_) { el.scrollIntoView(true); }
};
container.addEventListener('click', handler, true);
window.__footnoteContainer = container;
window.__footnoteHandler = handler;
} catch (e) {
// 忽略脚注绑定中的异常
}
});
},
// 语言切换插件
function(hook, vm) {
hook.mounted(function() {
// 添加语言切换按钮到导航栏
var nav = document.querySelector('.app-nav');
if (!nav) {
nav = document.createElement('nav');
nav.className = 'app-nav';
document.querySelector('main').appendChild(nav);
}
var langSwitcher = document.createElement('ul');
langSwitcher.innerHTML = `
<li>
<select id="lang-selector" style="background: transparent; border: 1px solid #ccc; border-radius: 4px; padding: 4px 8px;">
<option value="">中文</option>
</select>
</li>
`;
nav.appendChild(langSwitcher);
// 监听语言切换
var selector = document.getElementById('lang-selector');
selector.addEventListener('change', function(e) {
var lang = e.target.value;
var currentPath = location.hash.replace('#/', '');
if (lang === '') {
// 切换到中文
if (currentPath.startsWith('en/')) {
location.hash = '#/' + currentPath.replace('en/', '');
} else {
location.hash = '#/';
}
} else {
// 切换到英文
if (currentPath === '' || currentPath === '/') {
location.hash = '#/en/';
} else if (currentPath.startsWith('en/')) {
// 已经在英文页面
return;
} else {
location.hash = '#/en/' + currentPath;
}
}
});
// 根据当前路径设置选择器状态
function updateSelector() {
var currentPath = location.hash.replace('#/', '');
if (currentPath.startsWith('en/')) {
selector.value = 'en';
} else {
selector.value = '';
}
}
updateSelector();
// 监听路由变化
window.addEventListener('hashchange', updateSelector);
});
},
// 重写原始 HTML <img> 的相对路径,使其与 docsify 的 Markdown 图片解析一致
function(hook, vm) {
function getRouteDir() {
var hash = decodeURIComponent(window.location.hash || '');
if (!hash || hash === '#/' || hash === '#') return '';
var path = hash.replace(/^#\//, '').replace(/(\?.*|#.*)/g, '');
if (path && !path.endsWith('/')) {
path = path.replace(/[^\/]*$/, '');
}
return path;
}
hook.doneEach(function() {
try {
var routeDir = getRouteDir();
// location.pathname 例如: /all-in-rag/
var base = window.location.origin + window.location.pathname + routeDir;
var selector = '.markdown-section img:not([data-origin])';
var imgs = document.querySelectorAll(selector);
imgs.forEach(function(img) {
var src = img.getAttribute('src');
if (!src) return;
// 跳过已是绝对路径或以 / 开头的路径
if (/^(https?:)?\/\//i.test(src) || src.startsWith('/')) return;
try {
// 利用 URL 自动规范化 ./ 和 ../
var abs = new URL(src, base).pathname;
img.setAttribute('src', abs);
} catch (e) {
// 忽略单个元素的失败
}
});
} catch (e) {
// 忽略整体处理失败,避免影响页面其他功能
}
});
}
]
}
</script>
<!-- Put them above docsify.min.js -->
<script src="//cdn.jsdelivr.net/npm/docsify@latest/lib/docsify.min.js"></script>
<!-- 搜索功能 -->
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script>
<!-- code render-->
<script src="//cdn.jsdelivr.net/npm/prismjs@latest/components/prism-bash.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@latest/components/prism-python.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify-pagination@latest/dist/docsify-pagination.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify-copy-code"></script>
<script src="https://cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.js"></script>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.css" />
<script src="https://cdn.jsdelivr.net/npm/marked@3"></script>
<!-- CDN files for docsify-katex -->
<script src="//cdn.jsdelivr.net/npm/docsify-katex@latest/dist/docsify-katex.js"></script>
<!-- 字数统计 -->
<script src="//unpkg.com/docsify-count/dist/countable.js"></script>
<!-- Mermaid -->
<script src="//cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
<script src="//unpkg.com/docsify-mermaid@latest/dist/docsify-mermaid.js"></script>
<script>mermaid.initialize({ startOnLoad: true });</script>
</body>
</html>