Implemented "openDownloadsFolder" and "selectDownloadFolder"
This commit is contained in:
parent
86aa075c8d
commit
7417e3c325
19
index.js
19
index.js
@ -1,4 +1,4 @@
|
||||
const { app, BrowserWindow, globalShortcut, ipcMain, shell} = require('electron')
|
||||
const { app, BrowserWindow, globalShortcut, ipcMain, shell, dialog} = require('electron')
|
||||
const path = require('path')
|
||||
|
||||
const PORT = process.env.PORT || '6595'
|
||||
@ -7,9 +7,11 @@ function isDev() {
|
||||
return process.argv[2] == '--dev';
|
||||
}
|
||||
|
||||
let win
|
||||
|
||||
function createWindow () {
|
||||
require('./server/dist/app.js')
|
||||
const win = new BrowserWindow({
|
||||
win = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
useContentSize: true,
|
||||
@ -55,3 +57,16 @@ app.on('window-all-closed', () => {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.on('openDownloadsFolder', (event)=>{
|
||||
const { downloadLocation } = require('./server/dist/main.js').settings
|
||||
shell.openPath(downloadLocation)
|
||||
})
|
||||
|
||||
ipcMain.on('selectDownloadFolder', async (event, downloadLocation)=>{
|
||||
let path = await dialog.showOpenDialog(win, {
|
||||
defaultPath: downloadLocation,
|
||||
properties: ["openDirectory", "createDirectory"]
|
||||
})
|
||||
if (path.filePaths[0]) win.webContents.send("downloadFolderSelected", path.filePaths[0])
|
||||
})
|
||||
|
@ -9,13 +9,13 @@ contextBridge.exposeInMainWorld(
|
||||
"api", {
|
||||
send: (channel, data) => {
|
||||
// whitelist channels
|
||||
let validChannels = [];
|
||||
let validChannels = ["openDownloadsFolder", "applogin", "selectDownloadFolder"];
|
||||
if (validChannels.includes(channel)) {
|
||||
ipcRenderer.send(channel, data);
|
||||
}
|
||||
},
|
||||
receive: (channel, func) => {
|
||||
let validChannels = [];
|
||||
let validChannels = ["downloadFolderSelected", "applogin_arl"];
|
||||
if (validChannels.includes(channel)) {
|
||||
// Deliberately strip event as it includes `sender`
|
||||
ipcRenderer.on(channel, (event, ...args) => func(...args));
|
||||
|
@ -15,7 +15,7 @@
|
||||
"dependencies": {
|
||||
"cookie-parser": "1.4.5",
|
||||
"debug": "2.6.9",
|
||||
"deemix": "0.0.7",
|
||||
"deemix": "0.0.9",
|
||||
"deezer-js": "0.0.10",
|
||||
"dotenv": "8.2.0",
|
||||
"express": "4.17.1",
|
||||
|
2
webui
2
webui
@ -1 +1 @@
|
||||
Subproject commit 513f6ca1c25032d17dba8aed175e8c61a152abd4
|
||||
Subproject commit bab72e36d0e7a2e20edbe41ee259ede629eb332d
|
Loading…
Reference in New Issue
Block a user