Folder Select

This commit is contained in:
PaulaBras
2022-09-21 18:25:29 +02:00
parent f2ae18fba8
commit 0dc02629e6
10 changed files with 613 additions and 30 deletions

View File

@ -19,5 +19,7 @@
<button id="selectPathBtn" class"button is-warning">Path</button>
<h1>Hello World!</h1>
<p>Welcome to your Electron application.</p>
<input type="file" id="dirs" webkitdirectory directory/>
</body>
</html>

View File

@ -1,6 +1,6 @@
const { app, BrowserWindow, Menu, ipcMain, nativeTheme } = require('electron');
const { app, BrowserWindow, Menu, dialog, ipcMain, nativeTheme } = require('electron');
const path = require('path');
Menu.setApplicationMenu(false);
//Menu.setApplicationMenu(false);
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
// eslint-disable-next-line global-require
@ -14,9 +14,11 @@ const createWindow = () => {
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: true,
},
});
mainWindow.loadFile(path.join(__dirname, 'index.html'));
};
@ -46,7 +48,12 @@ app.on('activate', () => {
ipcMain.on('select-dirs', async(event, arg) => {
const result = await dialog.showOpenDialog(mainWindow, {
properties: ['openDirectory']
})
console.log('directories selected', result.filePaths)
})

9
updater/src/preload.js Normal file
View File

@ -0,0 +1,9 @@
const { ipcRenderer } = require('electron')
process.once('loaded', () => {
window.addEventListener('message', evt => {
if (evt.data.type === 'select-dirs') {
ipcRenderer.send('select-dirs')
}
})
})

View File

@ -6,6 +6,7 @@ const stopUnzip = document.querySelector('stopUnzip');
const selectVersionBtn = document.querySelector('selectVersion');
const selectPathBtn = document.querySelector('selectPathBtn');
var directoryPath = "C:";
const { remote } = require('electron');
const { Menu } = remote;
@ -59,8 +60,8 @@ async function downloadVersion(e) {
ipcRenderer.send("download", {
url: "URL is here",
properties: { directory: "Directory is here" }
url: "https://dms.pabr.de/s/SpBiQYADTNak7R5/download",
properties: { directory: directoryPath }
});
const { ipcRenderer } = require("electron");
@ -73,4 +74,19 @@ ipcRenderer.on("download progress", (event, progress) => {
console.log(progress); // Progress in fraction, between 0 and 1
const progressInPercentages = progress * 100; // With decimal point and a bunch of numbers
const cleanProgressInPercentages = Math.floor(progress * 100); // Without decimal point
});
});
// Select Folder
document.getElementById('dirs').addEventListener('click', (evt) => {
evt.preventDefault()
window.postMessage({
type: 'select-dirs',
})
})
// Get releases from Gitlab