diff --git a/.gitignore b/.gitignore index c32966e..2ccb550 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ dist/ ext/ temp/ resources/js/neutralino.js -resources/bg +resources/bg/official .storage/ .tmp/ diff --git a/package.json b/package.json index 1a386ef..6c6342b 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,9 @@ "license": "Apache-2.0", "scripts": { "dev": "neu run", - "build": "npm run clean_dist && neu build && npm run move_files && npm run rename_exe", + "build": "npm run clean_dist && neu build && npm run move_files && npm run move_bgs && npm run rename_exe", "move_files": "cp -r ./ext ./dist/GrassClipper && cp -r ./proxy ./dist/GrassClipper && cp install.cmd ./dist/GrassClipper && cp -r ./scripts ./dist/GrassClipper", + "move_bgs": "mkdir dist\\GrassClipper\\resources\\bg\\private && cp -r ./resources/bg/private ./dist/GrassClipper/resources/bg/private", "rename_exe": "mv ./dist/GrassClipper/GrassClipper-win_x64.exe ./dist/GrassClipper/GrassClipper.exe", "clean_dist": "rm -rf ./dist" } diff --git a/resources/bg/private/1.png b/resources/bg/private/1.png new file mode 100644 index 0000000..ab34051 Binary files /dev/null and b/resources/bg/private/1.png differ diff --git a/resources/js/index.js b/resources/js/index.js index c613b1f..1927d97 100644 --- a/resources/js/index.js +++ b/resources/js/index.js @@ -33,10 +33,12 @@ async function displayGenshinFolder() { async function setBackgroundImage() { const config = await getCfg() - const images = (await Neutralino.filesystem.readDirectory(config.genshinImpactFolder + '/bg')).filter(file => file.type === 'FILE') + const officialImages = (await Neutralino.filesystem.readDirectory(config.genshinImpactFolder + '/bg')).filter(file => file.type === 'FILE') + const privImages = (await Neutralino.filesystem.readDirectory(NL_CWD + '/resources/bg/private')).filter(file => file.type === 'FILE') // Pick one of the images - const image = images[Math.floor(Math.random() * images.length)].entry + const image = officialImages[Math.floor(Math.random() * officialImages.length)].entry + const privImage = privImages[Math.floor(Math.random() * privImages.length)].entry const path = config.genshinImpactFolder.replace('\\', '/') + '/bg/' + image // Check if resources folder exists @@ -58,14 +60,15 @@ async function setBackgroundImage() { } // Copy to backgrounds folder - const bgs = (await Neutralino.filesystem.readDirectory(NL_CWD + '/resources/bg/official/')).filter(file => file.type === 'FILE') + const officialBgs = (await Neutralino.filesystem.readDirectory(NL_CWD + '/resources/bg/official/')).filter(file => file.type === 'FILE') - if (!bgs.find(file => file.entry === image)) { + if (!officialBgs.find(file => file.entry === image)) { await Neutralino.filesystem.copyFile(path, NL_CWD + '/resources/bg/official/' + image) } // Set the background image document.querySelector('#firstHalf').style.backgroundImage = `url("../bg/official/${image}")` + document.querySelector('#secondHalf').style.backgroundImage = `url("../bg/private/${privImage}")` } async function setGenshinImpactFolder() {