From 18fbfe428920d6d033401585f074ffeb46cf4386 Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Mon, 25 May 2020 17:13:59 -0400 Subject: [PATCH] Move backgrounds to static, get dynamic backgrounds to work. TODO: Add loading spinner and make background load ease in. --- .eslintrc.json | 1 - package-lock.json | 32 ++++++++++---------- package.json | 4 +-- src/common/config/configmanager.ts | 1 + src/main/index.ts | 6 ++-- src/renderer/components/login/Login.tsx | 1 + src/renderer/index.css | 2 +- src/renderer/index.tsx | 13 ++++++++ {assets => static}/images/backgrounds/0.jpg | Bin {assets => static}/images/backgrounds/1.jpg | Bin {assets => static}/images/backgrounds/2.jpg | Bin {assets => static}/images/backgrounds/3.jpg | Bin {assets => static}/images/backgrounds/4.jpg | Bin {assets => static}/images/backgrounds/5.jpg | Bin {assets => static}/images/backgrounds/6.jpg | Bin {assets => static}/images/backgrounds/7.jpg | Bin 16 files changed, 36 insertions(+), 24 deletions(-) rename {assets => static}/images/backgrounds/0.jpg (100%) rename {assets => static}/images/backgrounds/1.jpg (100%) rename {assets => static}/images/backgrounds/2.jpg (100%) rename {assets => static}/images/backgrounds/3.jpg (100%) rename {assets => static}/images/backgrounds/4.jpg (100%) rename {assets => static}/images/backgrounds/5.jpg (100%) rename {assets => static}/images/backgrounds/6.jpg (100%) rename {assets => static}/images/backgrounds/7.jpg (100%) diff --git a/.eslintrc.json b/.eslintrc.json index 3005dee..2eae6d4 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -6,7 +6,6 @@ ], "extends": [ "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended", "plugin:react/recommended" ], diff --git a/package-lock.json b/package-lock.json index 6b49706..a25cbe2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1892,12 +1892,12 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.0.0.tgz", - "integrity": "sha512-lcZ0M6jD4cqGccYOERKdMtg+VWpoq3NSnWVxpc/AwAy0zhkUYVioOUZmfNqiNH8/eBNGhCn6HXd6mKIGRgNc1Q==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.0.1.tgz", + "integrity": "sha512-RxGldRQD3hgOK2xtBfNfA5MMV3rn5gVChe+MIf14hKm51jO2urqF64xOyVrGtzThkrd4rS1Kihqx2nkSxkXHvA==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "3.0.0", + "@typescript-eslint/experimental-utils": "3.0.1", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", "semver": "^7.3.2", @@ -1905,33 +1905,33 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.0.0.tgz", - "integrity": "sha512-BN0vmr9N79M9s2ctITtChRuP1+Dls0x/wlg0RXW1yQ7WJKPurg6X3Xirv61J2sjPif4F8SLsFMs5Nzte0WYoTQ==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.0.1.tgz", + "integrity": "sha512-GdwOVz80MOWxbc/br1DC30eeqlxfpVzexHgHtf3L0hcbOu1xAs1wSCNcaBTLMOMZbh1gj/cKZt0eB207FxWfFA==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "3.0.0", + "@typescript-eslint/typescript-estree": "3.0.1", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } }, "@typescript-eslint/parser": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.0.0.tgz", - "integrity": "sha512-8RRCA9KLxoFNO0mQlrLZA0reGPd/MsobxZS/yPFj+0/XgMdS8+mO8mF3BDj2ZYQj03rkayhSJtF1HAohQ3iylw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.0.1.tgz", + "integrity": "sha512-Pn2tDmOc4Ri93VQnT70W0pqQr6i/pEZqIPXfWXm4RuiIprL0t6SG13ViVXHgfScknL2Fm2G4IqXhUzxSRCWXCw==", "dev": true, "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "3.0.0", - "@typescript-eslint/typescript-estree": "3.0.0", + "@typescript-eslint/experimental-utils": "3.0.1", + "@typescript-eslint/typescript-estree": "3.0.1", "eslint-visitor-keys": "^1.1.0" } }, "@typescript-eslint/typescript-estree": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.0.0.tgz", - "integrity": "sha512-nevQvHyNghsfLrrByzVIH4ZG3NROgJ8LZlfh3ddwPPH4CH7W4GAiSx5qu+xHuX5pWsq6q/eqMc1io840ZhAnUg==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.0.1.tgz", + "integrity": "sha512-FrbMdgVCeIGHKaP9OYTttFTlF8Ds7AkjMca2GzYCE7pVch10PAJc1mmAFt+DfQPgu/2TrLAprg2vI0PK/WTdcg==", "dev": true, "requires": { "debug": "^4.1.1", diff --git a/package.json b/package.json index 2a4dd45..d7affa3 100644 --- a/package.json +++ b/package.json @@ -62,8 +62,8 @@ "@types/tar-fs": "^2.0.0", "@types/triple-beam": "^1.3.1", "@types/winreg": "^1.2.30", - "@typescript-eslint/eslint-plugin": "^3.0.0", - "@typescript-eslint/parser": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^3.0.1", + "@typescript-eslint/parser": "^3.0.1", "chai": "^4.2.0", "cross-env": "^7.0.2", "electron": "^8.3.0", diff --git a/src/common/config/configmanager.ts b/src/common/config/configmanager.ts index c4d2b21..fb8b185 100644 --- a/src/common/config/configmanager.ts +++ b/src/common/config/configmanager.ts @@ -175,6 +175,7 @@ export class ConfigManager { * @param {Object} destObj The destination object. * @returns {Object} A validated destination object. */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any private static validateKeySet(srcObj: any, destObj: any){ if(srcObj == null){ srcObj = {} diff --git a/src/main/index.ts b/src/main/index.ts index fbbd290..2e04872 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -1,16 +1,16 @@ import { ipcMain, app, BrowserWindow, Menu, MenuItem } from 'electron' import { prerelease } from 'semver' import { join } from 'path' -import { readdirSync } from 'fs-extra' import { format } from 'url' import { autoUpdater } from 'electron-updater' import isdev from '../common/util/isdev' const installExtensions = async () => { + // eslint-disable-next-line @typescript-eslint/no-var-requires const installer = require('electron-devtools-installer') const forceDownload = !!process.env.UPGRADE_EXTENSIONS const extensions = ['REACT_DEVELOPER_TOOLS', 'REDUX_DEVTOOLS'] - + return Promise.all( extensions.map(name => installer.default(installer[name], forceDownload)) ).catch(console.log) // eslint-disable-line no-console @@ -116,8 +116,6 @@ async function createWindow() { backgroundColor: '#171614' }) - // ejse.data('bkid', Math.floor((Math.random() * readdirSync(join(__dirname, '..', 'assets', 'images', 'backgrounds')).length))) - if (isdev) { win.loadURL(`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`) } diff --git a/src/renderer/components/login/Login.tsx b/src/renderer/components/login/Login.tsx index d529b2d..0d0b7ae 100644 --- a/src/renderer/components/login/Login.tsx +++ b/src/renderer/components/login/Login.tsx @@ -104,6 +104,7 @@ export default class Login extends React.Component event.preventDefault() } + // eslint-disable-next-line @typescript-eslint/no-unused-vars handleLoginButtonClick = (event: React.MouseEvent): void => { console.log(this.userRef.current!.getValue()) console.log(this.passRef.current!.getValue()) diff --git a/src/renderer/index.css b/src/renderer/index.css index e522b30..7a394e8 100644 --- a/src/renderer/index.css +++ b/src/renderer/index.css @@ -27,7 +27,7 @@ /* TODO: Temp for development */ body { - background-image: url('../../assets/images/backgrounds/3.jpg'); + /* background-image: url('../../static/images/backgrounds/3.jpg'); */ background-size: cover; } diff --git a/src/renderer/index.tsx b/src/renderer/index.tsx index d5e1528..2681370 100644 --- a/src/renderer/index.tsx +++ b/src/renderer/index.tsx @@ -6,6 +6,19 @@ import './index.css' import Application from './components/Application' import { Provider } from 'react-redux' +import { readdirSync } from 'fs-extra' +import { join } from 'path' + +declare const __static: string + +function setBackground(id: number) { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const bk = require('../../static/images/backgrounds/' + id + '.jpg') + document.body.style.backgroundImage = `url('${bk.default}')` +} + +const id = Math.floor((Math.random() * readdirSync(join(__static, 'images', 'backgrounds')).length)) +setBackground(id) // Create main element const mainElement = document.createElement('div') diff --git a/assets/images/backgrounds/0.jpg b/static/images/backgrounds/0.jpg similarity index 100% rename from assets/images/backgrounds/0.jpg rename to static/images/backgrounds/0.jpg diff --git a/assets/images/backgrounds/1.jpg b/static/images/backgrounds/1.jpg similarity index 100% rename from assets/images/backgrounds/1.jpg rename to static/images/backgrounds/1.jpg diff --git a/assets/images/backgrounds/2.jpg b/static/images/backgrounds/2.jpg similarity index 100% rename from assets/images/backgrounds/2.jpg rename to static/images/backgrounds/2.jpg diff --git a/assets/images/backgrounds/3.jpg b/static/images/backgrounds/3.jpg similarity index 100% rename from assets/images/backgrounds/3.jpg rename to static/images/backgrounds/3.jpg diff --git a/assets/images/backgrounds/4.jpg b/static/images/backgrounds/4.jpg similarity index 100% rename from assets/images/backgrounds/4.jpg rename to static/images/backgrounds/4.jpg diff --git a/assets/images/backgrounds/5.jpg b/static/images/backgrounds/5.jpg similarity index 100% rename from assets/images/backgrounds/5.jpg rename to static/images/backgrounds/5.jpg diff --git a/assets/images/backgrounds/6.jpg b/static/images/backgrounds/6.jpg similarity index 100% rename from assets/images/backgrounds/6.jpg rename to static/images/backgrounds/6.jpg diff --git a/assets/images/backgrounds/7.jpg b/static/images/backgrounds/7.jpg similarity index 100% rename from assets/images/backgrounds/7.jpg rename to static/images/backgrounds/7.jpg