初始化仓库及v1.0.0提交

This commit is contained in:
2026-05-05 03:21:58 +08:00
commit 813bb02672
67 changed files with 5263 additions and 0 deletions

34
assets/js/markdown.js Normal file
View File

@@ -0,0 +1,34 @@
const MarkdownRenderer = {
init() {
// 配置 marked.js
marked.setOptions({
highlight: function(code, lang) {
if (lang && hljs.getLanguage(lang)) {
return hljs.highlight(code, { language: lang }).value;
}
return hljs.highlightAuto(code).value;
},
breaks: true,
gfm: true
});
},
render(text) {
if (!text) return '';
let html = marked.parse(text);
// 为代码块添加复制按钮
html = html.replace(/<pre><code/g, '<pre><button class="copy-btn" onclick="MarkdownRenderer.copyCode(this)">复制</button><code');
return html;
},
copyCode(btn) {
const code = btn.nextElementSibling;
navigator.clipboard.writeText(code.textContent).then(() => {
btn.textContent = '已复制';
setTimeout(() => { btn.textContent = '复制'; }, 2000);
});
}
};
// 初始化
MarkdownRenderer.init();