添加缓存禁用机制,每次刷新加载最新JSON
This commit is contained in:
parent
8a12e984ee
commit
d9f8da5292
@ -317,10 +317,15 @@
|
|||||||
|
|
||||||
let chaptersData = [];
|
let chaptersData = [];
|
||||||
|
|
||||||
|
// 获取带缓存禁用的时间戳
|
||||||
|
function getCacheBuster() {
|
||||||
|
return `?t=${Date.now()}`;
|
||||||
|
}
|
||||||
|
|
||||||
// 加载章节列表
|
// 加载章节列表
|
||||||
async function loadChaptersIndex() {
|
async function loadChaptersIndex() {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('data/chapters.json');
|
const response = await fetch('data/chapters.json' + getCacheBuster());
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
chaptersData = data.chapters;
|
chaptersData = data.chapters;
|
||||||
renderSidebar();
|
renderSidebar();
|
||||||
@ -343,7 +348,7 @@
|
|||||||
currentChapter = id;
|
currentChapter = id;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`data/chapter-${String(id).padStart(2, '0')}.json`);
|
const response = await fetch(`data/chapter-${String(id).padStart(2, '0')}.json` + getCacheBuster());
|
||||||
const chapter = await response.json();
|
const chapter = await response.json();
|
||||||
|
|
||||||
// 将纯文本转换为HTML(每段包裹<p>标签)
|
// 将纯文本转换为HTML(每段包裹<p>标签)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user