|
1 | 1 | <!doctype html> |
2 | 2 |
|
3 | 3 | <html> |
4 | | -<markdown-html version="1.17.9" author="PJ568" repo="https://github.com/PJ-568/markdown.html" |
| 4 | +<markdown-html version="1.18.0" author="PJ568" repo="https://github.com/PJ-568/markdown.html" |
5 | 5 | license="CC BY-SA 4.0 International"></markdown-html> |
6 | 6 |
|
7 | 7 | <head> |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 |
|
| 329 | + // 加载 CSS |
| 330 | + function loadCSS(url) { |
| 331 | + return new Promise((resolve, reject) => { |
| 332 | + //// 检查是否已加载 |
| 333 | + const existingLinks = document.querySelectorAll(`link[href="${url}"]`); |
| 334 | + if (existingLinks.length > 0) { |
| 335 | + return resolve(url); |
| 336 | + } |
| 337 | + |
| 338 | + //// 创建新的 link 元素 |
| 339 | + const link = document.createElement('link'); |
| 340 | + link.rel = 'stylesheet'; |
| 341 | + link.type = 'text/css'; |
| 342 | + link.href = url; |
| 343 | + |
| 344 | + //// 成功加载处理 |
| 345 | + link.onload = () => { |
| 346 | + link.onload = null; |
| 347 | + link.onerror = null; |
| 348 | + resolve(url); |
| 349 | + }; |
| 350 | + |
| 351 | + //// 加载失败处理 |
| 352 | + link.onerror = () => { |
| 353 | + link.onerror = null; |
| 354 | + link.onload = null; |
| 355 | + document.head.removeChild(link); |
| 356 | + reject(new Error(`无法加载CSS文件: ${url}`)); |
| 357 | + }; |
| 358 | + |
| 359 | + //// 添加到文档头部 |
| 360 | + document.head.appendChild(link); |
| 361 | + }); |
| 362 | + } |
| 363 | + |
329 | 364 | // 等待动画结束 |
330 | 365 | function waitForAnimationsEnd(parentElement, selector, animationNames) { |
331 | 366 | return new Promise(resolve => { |
|
494 | 529 | const images = linkDoc.querySelectorAll('img'); |
495 | 530 | images.forEach(img => { |
496 | 531 | const src = img.getAttribute('src'); |
| 532 | + img.setAttribute('loading', 'lazy'); |
497 | 533 | if (src && !isExternalLink(src) && isRelativePath(src)) { |
498 | 534 | var absolutePath = pValue ? getDirectory(mdPath) + src : getPath() + src; |
499 | 535 | absolutePath = new URL(absolutePath, 'http://example.com').pathname; |
|
590 | 626 |
|
591 | 627 | // 初始化 |
592 | 628 | function initialize() { |
| 629 | + startLoad(); //// 开始加载动画 |
593 | 630 | initDarkmode(); //// 初始化深色模式 |
594 | 631 | initHomeBtn(); //// 初始化返回首页按钮 |
595 | 632 | initAboutBtn(); //// 初始化关于按钮 |
|
598 | 635 | initPJAX(); //// 初始化 PJAX |
599 | 636 | initCustomPJAXResponse(); //// 初始化自定义 PJAX 响应 |
600 | 637 | initCustomPJAXEventListener(); //// 初始化自定义 PJAX 事件监听器 |
| 638 | + loadCSS('https://chinese-fonts-cdn.deno.dev/packages/maple-mono-cn/dist/MapleMono-CN-Regular/result.css'); //// 加载字体 CSS |
| 639 | + endLoad(); //// 结束加载动画 |
601 | 640 | } |
602 | 641 |
|
603 | 642 | // 触发器 |
|
1017 | 1056 | </style> |
1018 | 1057 | <link href="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-y/highlight.js/11.4.0/styles/default.min.css" |
1019 | 1058 | type="text/css" rel="stylesheet" /> |
1020 | | - <link rel="stylesheet" |
1021 | | - href="https://chinese-fonts-cdn.deno.dev/packages/maple-mono-cn/dist/MapleMono-CN-Regular/result.css" /> |
1022 | 1059 | </head> |
1023 | 1060 |
|
1024 | 1061 | <body> |
|
0 commit comments