mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-11-25 07:25:12 +00:00
fix(client): Vite related boot mechanism revision (#8753)
* preload app css * remove salt * APP_FETCH_FAILED error * set max-age to 15s
This commit is contained in:
parent
4917961736
commit
f1d2398eac
3 changed files with 14 additions and 17 deletions
|
@ -54,14 +54,10 @@
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region Script
|
//#region Script
|
||||||
const salt = localStorage.getItem('salt')
|
import(`/assets/${CLIENT_ENTRY}`)
|
||||||
? `?salt=${localStorage.getItem('salt')}`
|
.catch(async e => {
|
||||||
: '';
|
|
||||||
|
|
||||||
import(`/assets/${CLIENT_ENTRY}${salt}`)
|
|
||||||
.catch(async () => {
|
|
||||||
await checkUpdate();
|
await checkUpdate();
|
||||||
renderError('APP_FETCH_FAILED');
|
renderError('APP_FETCH_FAILED', JSON.stringify(e));
|
||||||
})
|
})
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
@ -142,9 +138,6 @@
|
||||||
|
|
||||||
// eslint-disable-next-line no-inner-declarations
|
// eslint-disable-next-line no-inner-declarations
|
||||||
function refresh() {
|
function refresh() {
|
||||||
// Random
|
|
||||||
localStorage.setItem('salt', Math.random().toString().substr(2, 8));
|
|
||||||
|
|
||||||
// Clear cache (service worker)
|
// Clear cache (service worker)
|
||||||
try {
|
try {
|
||||||
navigator.serviceWorker.controller.postMessage('clear');
|
navigator.serviceWorker.controller.postMessage('clear');
|
||||||
|
|
|
@ -247,7 +247,7 @@ router.get(['/@:user', '/@:user/:sub'], async (ctx, next) => {
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
});
|
});
|
||||||
ctx.set('Cache-Control', 'public, max-age=30');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
} else {
|
} else {
|
||||||
// リモートユーザーなので
|
// リモートユーザーなので
|
||||||
// モデレータがAPI経由で参照可能にするために404にはしない
|
// モデレータがAPI経由で参照可能にするために404にはしない
|
||||||
|
@ -292,7 +292,7 @@ router.get('/notes/:note', async (ctx, next) => {
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.set('Cache-Control', 'public, max-age=180');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,7 @@ router.get('/@:user/pages/:page', async (ctx, next) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (['public'].includes(page.visibility)) {
|
if (['public'].includes(page.visibility)) {
|
||||||
ctx.set('Cache-Control', 'public, max-age=180');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
} else {
|
} else {
|
||||||
ctx.set('Cache-Control', 'private, max-age=0, must-revalidate');
|
ctx.set('Cache-Control', 'private, max-age=0, must-revalidate');
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ router.get('/clips/:clip', async (ctx, next) => {
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.set('Cache-Control', 'public, max-age=180');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,7 @@ router.get('/gallery/:post', async (ctx, next) => {
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.set('Cache-Control', 'public, max-age=180');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -409,7 +409,7 @@ router.get('/channels/:channel', async (ctx, next) => {
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.set('Cache-Control', 'public, max-age=180');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -468,7 +468,7 @@ router.get('(.*)', async ctx => {
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
});
|
});
|
||||||
ctx.set('Cache-Control', 'public, max-age=300');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Register router
|
// Register router
|
||||||
|
|
|
@ -37,6 +37,10 @@ html
|
||||||
link(rel='prefetch' href='https://xn--931a.moe/assets/not-found.jpg')
|
link(rel='prefetch' href='https://xn--931a.moe/assets/not-found.jpg')
|
||||||
link(rel='prefetch' href='https://xn--931a.moe/assets/error.jpg')
|
link(rel='prefetch' href='https://xn--931a.moe/assets/error.jpg')
|
||||||
link(rel='stylesheet' href='/assets/fontawesome/css/all.css')
|
link(rel='stylesheet' href='/assets/fontawesome/css/all.css')
|
||||||
|
link(rel='modulepreload' href=`/assets/${clientEntry.file}`)
|
||||||
|
|
||||||
|
each href in clientEntry.css
|
||||||
|
link(rel='preload' href=`/assets/${href}` as='style')
|
||||||
|
|
||||||
each href in clientEntry.css
|
each href in clientEntry.css
|
||||||
link(rel='preload' href=`/assets/${href}` as='style')
|
link(rel='preload' href=`/assets/${href}` as='style')
|
||||||
|
|
Loading…
Reference in a new issue