mirror of
https://github.com/JustusPlays78/SectorFileUpdater.git
synced 2025-06-28 04:55:16 +00:00
Folder Select
This commit is contained in:
@ -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>
|
||||
|
@ -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
9
updater/src/preload.js
Normal 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')
|
||||
}
|
||||
})
|
||||
})
|
@ -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
|
Reference in New Issue
Block a user