Skip to content

Commit

Permalink
fix(boot): background is moving
Browse files Browse the repository at this point in the history
  • Loading branch information
SWREI committed Jul 25, 2024
1 parent 71ee993 commit e760b78
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/backend/src/server/web/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@
document.documentElement.classList.add('useSystemFont');
}

const wallpaper = localStorage.getItem('wallpaper');
const wallpaper = localStorage.getItem('wallpaper') ?? meta.backgroundImageUrl;
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');
Expand Down
19 changes: 17 additions & 2 deletions packages/frontend/src/_dev_boot_.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ async function main() {
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

// dev-modeの場合は常に取り直す
Expand Down Expand Up @@ -77,9 +91,10 @@ async function main() {
document.documentElement.classList.add('useSystemFont');
}

const wallpaper = localStorage.getItem('wallpaper');
const wallpaper = localStorage.getItem('wallpaper') ?? meta.backgroundImageUrl;
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');
Expand Down

0 comments on commit e760b78

Please sign in to comment.