custom private server background and build steps

This commit is contained in:
SpikeHD 2022-04-20 16:46:46 -07:00
parent ed8148bfac
commit 3821f5c95a
4 changed files with 10 additions and 6 deletions

2
.gitignore vendored
View File

@ -5,7 +5,7 @@ dist/
ext/
temp/
resources/js/neutralino.js
resources/bg
resources/bg/official
.storage/
.tmp/

View File

@ -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"
}

BIN
resources/bg/private/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@ -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() {