|
1 | 1 | <!doctype html> |
2 | 2 |
|
3 | 3 | <html> |
4 | | -<markdown-html version="1.15.1" author="PJ568" repo="https://github.com/PJ-568/markdown.html" |
| 4 | +<markdown-html version="1.15.2" 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> |
|
460 | 460 | } |
461 | 461 | linkHref = new URL(linkHref, 'http://example.com').pathname; |
462 | 462 | } |
463 | | - const newLink = `[${linkText}](${window.location.pathname}?p=${linkHref})`; |
| 463 | + const newLink = `[${linkText}](?p=${linkHref})`; // 链接格式与 window.location.search 一致 |
464 | 464 | markdown_content = markdown_content.replace(link, newLink); |
465 | 465 | }); |
466 | 466 | } |
|
600 | 600 | } |
601 | 601 | return; |
602 | 602 | } |
603 | | - if (event.target.closest('nav .back-btn')) { |
| 603 | + if (event.target.closest('.back-btn')) { |
604 | 604 | window.history.back(); |
605 | | - } else if (event.target.closest('nav .refresh-btn')) { |
| 605 | + } else if (event.target.closest('.refresh-btn')) { |
606 | 606 | window.location.reload(); |
607 | | - } else if (event.target.closest('nav .dark-btn')) { |
| 607 | + } else if (event.target.closest('.dark-btn')) { |
608 | 608 | darkmode.toggle(); |
609 | | - } else if (event.target.closest('nav .translate-switch')) { |
| 609 | + } else if (event.target.closest('.translate-switch')) { |
610 | 610 | translate.changeLanguage(translate.language.getLocal()); |
611 | | - } else if (event.target.closest('.content a[href^="#"]')) { |
612 | | - // 目录平滑移动 |
613 | | - const href = event.target.getAttribute('href'); |
614 | | - if (href !== '#') { |
615 | | - event.preventDefault(); |
616 | | - const targetElement = document.querySelector(href); |
617 | | - if (targetElement) { |
618 | | - targetElement.scrollIntoView({ |
619 | | - behavior: 'smooth' |
620 | | - }); |
621 | | - } else { |
622 | | - console.error(`ID 为 ${targetId} 的元素不存在。`); |
623 | | - } |
624 | | - } |
625 | | - } else if (event.target.closest('.content a:not([href$=".md"])')) { |
| 611 | + // 跳转。禁用原因是有些带有特殊字符的链接会出错或无法跳转 |
| 612 | + // } else if (event.target.closest('.content a[href^="#"]')) { |
| 613 | + // // 目录平滑移动 |
| 614 | + // const href = event.target.getAttribute('href'); |
| 615 | + // if (href !== '#') { |
| 616 | + // event.preventDefault(); |
| 617 | + // const targetElement = document.querySelector(href); |
| 618 | + // if (targetElement) { |
| 619 | + // targetElement.scrollIntoView({ |
| 620 | + // behavior: 'smooth' |
| 621 | + // }); |
| 622 | + // } else { |
| 623 | + // console.error(`ID 为 ${targetId} 的元素不存在。`); |
| 624 | + // } |
| 625 | + // } |
| 626 | + } else if (event.target.closest('.content a:not([href^="?"]):not([href^="#"]):not([href^="javascript:"])')) { |
626 | 627 | const link = event.target.closest('a'); |
627 | 628 | if (link && link.href) { |
628 | 629 | window.open(link.href, '_blank'); |
|
0 commit comments