mirror of
https://github.com/JustusPlays78/SectorFileUpdater.git
synced 2025-06-28 04:55:16 +00:00
bissel hier, bissel da
This commit is contained in:
9
updater/src/copy/copy.js
Normal file
9
updater/src/copy/copy.js
Normal file
@ -0,0 +1,9 @@
|
||||
app.on('copy-me', () => {
|
||||
const fs = require('fs');
|
||||
|
||||
// File destination.txt will be created or overwritten by default.
|
||||
fs.copyFile('source.txt', 'destination.txt', (err) => {
|
||||
if (err) throw err;
|
||||
console.log('source.txt was copied to destination.txt');
|
||||
});
|
||||
});
|
21
updater/src/download/downloader.js
Normal file
21
updater/src/download/downloader.js
Normal file
@ -0,0 +1,21 @@
|
||||
const { app, BrowserWindow, ipcMain } = require("electron");
|
||||
const { download } = require("electron-dl");
|
||||
let window;
|
||||
app.on("ready", () => {
|
||||
window = new BrowserWindow({
|
||||
width: someWidth,
|
||||
height: someHeight
|
||||
});
|
||||
window.loadURL(`file://${__dirname}/index.html`);
|
||||
ipcMain.on("download", (event, info) => {
|
||||
download(BrowserWindow.getFocusedWindow(), info.url, info.properties)
|
||||
.then(dl => window.webContents.send("download complete", dl.getSavePath()));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
ipcMain.on("download", (event, info) => {
|
||||
info.properties.onProgress = status => window.webContents.send("download progress", status);
|
||||
download(BrowserWindow.getFocusedWindow(), info.url, info.properties)
|
||||
.then(dl => window.webContents.send("download complete", dl.getSavePath()));
|
||||
});
|
16
updater/src/download/renderer.js
Normal file
16
updater/src/download/renderer.js
Normal file
@ -0,0 +1,16 @@
|
||||
ipcRenderer.send("download", {
|
||||
url: "URL is here",
|
||||
properties: { directory: "Directory is here" }
|
||||
});
|
||||
|
||||
const { ipcRenderer } = require("electron");
|
||||
ipcRenderer.on("download complete", (event, file) => {
|
||||
console.log(file); // Full file path
|
||||
});
|
||||
|
||||
|
||||
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
|
||||
});
|
@ -1,27 +1,28 @@
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
const { app, BrowserWindow, ipcMain } = require('electron');
|
||||
const path = require('path');
|
||||
|
||||
const { download } = require("electron-dl");
|
||||
let window;
|
||||
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
||||
// eslint-disable-next-line global-require
|
||||
if (require('electron-squirrel-startup')) {
|
||||
app.quit();
|
||||
app.quit();
|
||||
}
|
||||
|
||||
const createWindow = () => {
|
||||
// Create the browser window.
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
},
|
||||
});
|
||||
// Create the browser window.
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
},
|
||||
});
|
||||
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadFile(path.join(__dirname, 'index.html'));
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadFile(path.join(__dirname, 'index.html'));
|
||||
|
||||
// Open the DevTools.
|
||||
mainWindow.webContents.openDevTools();
|
||||
// Open the DevTools.
|
||||
mainWindow.webContents.openDevTools();
|
||||
};
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
@ -33,18 +34,25 @@ app.on('ready', createWindow);
|
||||
// for applications and their menu bar to stay active until the user quits
|
||||
// explicitly with Cmd + Q.
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
app.on('activate', () => {
|
||||
// On OS X it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
}
|
||||
// On OS X it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// In this file you can include the rest of your app's specific main process
|
||||
// code. You can also put them in separate files and import them here.
|
||||
// code. You can also put them in separate files and import them here.
|
28
updater/src/unzip/unzip.js
Normal file
28
updater/src/unzip/unzip.js
Normal file
@ -0,0 +1,28 @@
|
||||
var ZIP_FILE_PATH = "C:/path/to/file/myzipfile.zip";
|
||||
var DESTINATION_PATH = "C:/desktop/examplefolder";
|
||||
var unzipper = new DecompressZip(ZIP_FILE_PATH);
|
||||
|
||||
// Add the error event listener
|
||||
unzipper.on('error', function(err) {
|
||||
console.log('Caught an error', err);
|
||||
});
|
||||
|
||||
// Notify when everything is extracted
|
||||
unzipper.on('extract', function(log) {
|
||||
console.log('Finished extracting', log);
|
||||
});
|
||||
|
||||
// Notify "progress" of the decompressed files
|
||||
unzipper.on('progress', function(fileIndex, fileCount) {
|
||||
console.log('Extracted file ' + (fileIndex + 1) + ' of ' + fileCount);
|
||||
});
|
||||
|
||||
// Start extraction of the content
|
||||
unzipper.extract({
|
||||
path: DESTINATION_PATH
|
||||
// You can filter the files that you want to unpack using the filter option
|
||||
//filter: function (file) {
|
||||
//console.log(file);
|
||||
//return file.type !== "SymbolicLink";
|
||||
//}
|
||||
});
|
Reference in New Issue
Block a user