feat: add bg image and random select bg

This commit is contained in:
Zichao Lin 2024-08-23 12:35:48 +08:00
parent 564f2c13e6
commit 1d47d34518
Signed by: earthjasonlin
GPG Key ID: 406D9913DE2E42FB
4 changed files with 8 additions and 1 deletions

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
img/bg/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

@ -2,11 +2,19 @@ let currentLang = "zh";
let data, i18n;
document.addEventListener("DOMContentLoaded", () => {
setRandomBackground();
loadData("data.json", loadBlockchainOptions);
changeLanguage(currentLang);
updateCopyrightYear();
});
function setRandomBackground() {
const images = ['1.jpg', '2.jpg'];
const randomIndex = Math.floor(Math.random() * images.length);
const selectedImage = images[randomIndex];
document.body.style.backgroundImage = `url('img/bg/${selectedImage}')`;
}
function updateCopyrightYear() {
const currentYear = new Date().getFullYear();
let copyrightText;

@ -1,7 +1,6 @@
body {
font-family: Microsoft YaHei;
font-weight: bold;
background-image: url("img/bg.jpg");
background-size: cover;
background-position: center;
background-repeat: no-repeat;