Skip to content

Commit

Permalink
【新增】优化索引页判断
Browse files Browse the repository at this point in the history
  • Loading branch information
PJ-568 committed Dec 11, 2024
1 parent 74a87e5 commit 2472c10
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- 作者:PJ568 -->
<!-- 项目地址:https://github.com/PJ-568/markdown.html/ -->
<!-- 本项目遵循 CC BY-SA 4.0 International 许可协议 -->
<!-- v 0.6.3 -->
<!-- v 0.7.3 -->

<head>
<meta charset="utf-8">
Expand All @@ -23,6 +23,7 @@
var timer = null;

// 文档解析功能相关
var existIndexPage = true; // 是否存在索引页
var url = new URL(window.location.href);
var params = new URLSearchParams(url.search);
var pValue = formatPath(params.get('p'));
Expand Down Expand Up @@ -317,9 +318,14 @@
if (pValue) {
await showMarkdown(pValue);
} else {
const response = await fetch(getPath() + 'index.md');
if (response.ok) {
await showMarkdown(getPath() + 'index.md', response);
if (existIndexPage) {
const response = await fetch(getPath() + 'index.md');
if (response.ok) {
await showMarkdown(getPath() + 'index.md', response);
} else {
existIndexPage = true;
await showMarkdown(getPath() + 'README.md');
}
} else {
await showMarkdown(getPath() + 'README.md');
}
Expand Down

0 comments on commit 2472c10

Please sign in to comment.