mirror of
https://github.com/JustusPlays78/SectorFileUpdater.git
synced 2025-04-29 10:10:57 +00:00
kaputt
This commit is contained in:
parent
efc63943c3
commit
a409778fa6
@ -1,9 +0,0 @@
|
||||
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');
|
||||
});
|
||||
});
|
@ -1,21 +0,0 @@
|
||||
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()));
|
||||
});
|
@ -3,22 +3,21 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Sectorfile Updater</title>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/bulma@0.8.0/css/bulma.min.css"
|
||||
/>
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
|
||||
<link rel="stylesheet" href="index.css" />
|
||||
<script defer src="render.js"></script>
|
||||
<script src="./renderer.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<button id="writeFile" class"button is-primary">Write File</button>
|
||||
<!--<button id="writeFile" class"button is-primary">Write File</button>
|
||||
<button id="startDownload" class"button is-primary">Start Download</button>
|
||||
<button id="stopDownload" class"button is-warning">Stop Download</button>
|
||||
<button id="startUnzip" class"button is-primary">Start Unzip</button>
|
||||
<button id="stopUnzip" class"button is-warning">Stop Unzip</button>
|
||||
<button id="selectVersionBtn" class"button is-warning">Version</button>
|
||||
<button id="selectPathBtn" class"button is-warning">Path</button>
|
||||
<h1>Hello World!</h1>
|
||||
<button id="selectPathBtn" class"button is-warning">Path</button> -->
|
||||
<button id="download" class"button is-primary">Download</button>
|
||||
<button id="openButton">Open</button>
|
||||
<!--<h1>Hello World!</h1>
|
||||
<p>Welcome to your Electron application.</p>
|
||||
<p>Input Text</p>
|
||||
<input type="text" id="txtBox" name="name" size="80">
|
||||
@ -26,7 +25,10 @@
|
||||
<input type="text" id="urlBox" name="name" size="80">
|
||||
<p>Input Directory</p>
|
||||
<input type="text" id="dirBox" name="name" size="80">
|
||||
<progress id="file" max="100" value="70"></progress>
|
||||
<progress id="file" max="100" value="70"></progress>-->
|
||||
<input type="file" id="dirs" webkitdirectory directory/>
|
||||
<button type="button" id="btn">Open a File</button>
|
||||
File path: <strong id="filePath"></strong>
|
||||
<script src="./renderer.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -11,18 +11,29 @@ if (require('electron-squirrel-startup')) {
|
||||
app.quit();
|
||||
}
|
||||
|
||||
|
||||
async function handleFileOpen() {
|
||||
const { canceled, filePaths } = await dialog.showOpenDialog()
|
||||
if (canceled) {
|
||||
return
|
||||
} else {
|
||||
return filePaths[0]
|
||||
}
|
||||
}
|
||||
app.whenReady(() => {
|
||||
ipcMain.handle('dialog:openFile', handleFileOpen)
|
||||
createWindow()
|
||||
})
|
||||
|
||||
const createWindow = () => {
|
||||
// Create the browser window.
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
nodeIntegration: true,
|
||||
contextIsolation: true,
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
},
|
||||
});
|
||||
|
||||
mainWindow.loadFile(path.join(__dirname, 'index.html'));
|
||||
};
|
||||
|
||||
@ -70,9 +81,9 @@ ipcMain.on('select-dirs', async(event, arg) => {
|
||||
|
||||
|
||||
// Download a file
|
||||
ipcMain.on("download", (event, url, properties) => {
|
||||
properties.onProgress = status => window.webContents.send("download progress", status);
|
||||
download(BrowserWindow.getFocusedWindow(), url, properties)
|
||||
ipcMain.on("download", async(event, url) => {
|
||||
//properties.onProgress = status => window.webContents.send("download progress", status);
|
||||
download(BrowserWindow.getFocusedWindow(), url)
|
||||
.then(dl => window.webContents.send("download complete", dl.getSavePath()));
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,10 @@
|
||||
const { ipcRenderer } = require('electron')
|
||||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
openFile: () => ipcRenderer.invoke('dialog:openFile')
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// Change me for file save
|
||||
@ -28,7 +34,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
});
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
// Change me for select directory
|
||||
process.once('loaded', () => {
|
||||
@ -37,4 +43,4 @@ process.once('loaded', () => {
|
||||
ipcRenderer.send('select-dirs')
|
||||
}
|
||||
});
|
||||
});
|
||||
});*/
|
@ -10,8 +10,12 @@ const writeFile = document.querySelector('writeFile');
|
||||
const { remote, ipcRenderer } = require('electron');
|
||||
const { writeFile } = require('fs');
|
||||
|
||||
document.getElementById('btn').addEventListener('click', () => {
|
||||
const filePath = window.electronAPI.openFile()
|
||||
document.getElementById('filePath').innerText = filePath
|
||||
});
|
||||
|
||||
|
||||
const { ipcRenderer } = require("electron");
|
||||
ipcRenderer.on("download complete", (event, file) => {
|
||||
console.log(file); // Full file path
|
||||
});
|
||||
@ -28,4 +32,11 @@ document.getElementById('dirs').addEventListener('click', (evt) => {
|
||||
window.postMessage({
|
||||
type: 'select-dirs',
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
|
||||
document.getElementById('openButton').addEventListener('click', () => {
|
||||
console.log("Test");
|
||||
ipcRenderer.send('openFile', {})
|
||||
});
|
@ -1,28 +0,0 @@
|
||||
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";
|
||||
//}
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user