fix(boot): background is moving

This commit is contained in:
무라쿠모 2024-07-25 19:23:09 +09:00
parent 71ee993f05
commit e760b78963
No known key found for this signature in database
GPG key ID: 139D6573F92DA9F7
2 changed files with 20 additions and 4 deletions

View file

@ -137,9 +137,10 @@
document.documentElement.classList.add('useSystemFont'); document.documentElement.classList.add('useSystemFont');
} }
const wallpaper = localStorage.getItem('wallpaper'); const wallpaper = localStorage.getItem('wallpaper') ?? meta.backgroundImageUrl;
if (wallpaper) { if (wallpaper) {
document.documentElement.style.backgroundImage = `url(${wallpaper})`; document.documentElement.style.background = `url(${wallpaper}) no-repeat fixed center`;
document.documentElement.style.backgroundSize = 'cover';
} }
const customCss = localStorage.getItem('customCss'); const customCss = localStorage.getItem('customCss');

View file

@ -21,6 +21,20 @@ async function main() {
renderError('FORCED_ERROR', 'This error is forced by having forceError in local storage.'); renderError('FORCED_ERROR', 'This error is forced by having forceError in local storage.');
} }
const metaRes = await window.fetch('/api/meta', {
method: 'POST',
body: JSON.stringify({}),
credentials: 'omit',
cache: 'no-cache',
headers: {
'Content-Type': 'application/json',
},
});
if (metaRes.status !== 200) {
renderError('META_FETCH');
return;
}
const meta = await metaRes.json();
//#region Detect language & fetch translations //#region Detect language & fetch translations
// dev-modeの場合は常に取り直す // dev-modeの場合は常に取り直す
@ -77,9 +91,10 @@ async function main() {
document.documentElement.classList.add('useSystemFont'); document.documentElement.classList.add('useSystemFont');
} }
const wallpaper = localStorage.getItem('wallpaper'); const wallpaper = localStorage.getItem('wallpaper') ?? meta.backgroundImageUrl;
if (wallpaper) { if (wallpaper) {
document.documentElement.style.backgroundImage = `url(${wallpaper})`; document.documentElement.style.background = `url(${wallpaper}) no-repeat fixed center`;
document.documentElement.style.backgroundSize = 'cover';
} }
const customCss = localStorage.getItem('customCss'); const customCss = localStorage.getItem('customCss');