1.1.18 - imagine useful commit messages
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
const express = require('express');
|
||||
const cors = require('cors');
|
||||
const path = require('path');
|
||||
const packageJson = require('../package.json');
|
||||
const fs = require('fs');
|
||||
@ -11,7 +12,6 @@ const {Track, Album, Artist, Playlist, DeezerProfile, SearchResults, DeezerLibra
|
||||
const {DownloadManager} = require('./downloads');
|
||||
const {Integrations} = require('./integrations');
|
||||
const {Importer} = require('./importer');
|
||||
const { url } = require('inspector');
|
||||
|
||||
let settings;
|
||||
let deezer;
|
||||
@ -24,6 +24,7 @@ let sockets = [];
|
||||
const app = express();
|
||||
app.use(express.json({limit: '50mb'}));
|
||||
app.use(express.static(path.join(__dirname, '../client', 'dist')));
|
||||
app.use(cors({origin: 'http://localhost:8080'}));
|
||||
//Server
|
||||
const server = require('http').createServer(app);
|
||||
const io = require('socket.io').listen(server, {
|
||||
@ -632,6 +633,15 @@ app.get('/updates', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
//Background image
|
||||
app.get('/background', async (req, res) => {
|
||||
//Missing
|
||||
if (!settings.backgroundImage && !fs.existsSync(settings.backgroundImage)) {
|
||||
return res.status(404).end();
|
||||
}
|
||||
res.sendFile(path.resolve(settings.backgroundImage));
|
||||
});
|
||||
|
||||
//Redirect to index on unknown path
|
||||
app.all('*', (req, res) => {
|
||||
res.redirect('/');
|
||||
|
@ -44,6 +44,10 @@ class Settings {
|
||||
this.contentLanguage = 'en';
|
||||
this.contentCountry = 'US';
|
||||
this.sidebarOpen = false;
|
||||
|
||||
//Has to be local path
|
||||
this.backgroundImage = null;
|
||||
this.lightTheme = false;
|
||||
}
|
||||
|
||||
//Based on electorn app.getPath
|
||||
@ -121,7 +125,7 @@ class Settings {
|
||||
await fs.promises.mkdir(Settings.getDir(), {recursive: true});
|
||||
} catch (_) {}
|
||||
|
||||
await fs.promises.writeFile(Settings.getPath(), JSON.stringify(this), 'utf-8');
|
||||
await fs.promises.writeFile(Settings.getPath(), JSON.stringify(this, null, 2), 'utf-8');
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user