mirror of
https://github.com/JustusPlays78/SectorFileUpdater.git
synced 2025-04-29 19:24:24 +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>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>Sectorfile Updater</title>
|
<title>Sectorfile Updater</title>
|
||||||
<link
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
|
||||||
rel="stylesheet"
|
|
||||||
href="https://cdn.jsdelivr.net/npm/bulma@0.8.0/css/bulma.min.css"
|
|
||||||
/>
|
|
||||||
<link rel="stylesheet" href="index.css" />
|
<link rel="stylesheet" href="index.css" />
|
||||||
<script defer src="render.js"></script>
|
<script src="./renderer.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<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="startDownload" class"button is-primary">Start Download</button>
|
||||||
<button id="stopDownload" class"button is-warning">Stop Download</button>
|
<button id="stopDownload" class"button is-warning">Stop Download</button>
|
||||||
<button id="startUnzip" class"button is-primary">Start Unzip</button>
|
<button id="startUnzip" class"button is-primary">Start Unzip</button>
|
||||||
<button id="stopUnzip" class"button is-warning">Stop Unzip</button>
|
<button id="stopUnzip" class"button is-warning">Stop Unzip</button>
|
||||||
<button id="selectVersionBtn" class"button is-warning">Version</button>
|
<button id="selectVersionBtn" class"button is-warning">Version</button>
|
||||||
<button id="selectPathBtn" class"button is-warning">Path</button>
|
<button id="selectPathBtn" class"button is-warning">Path</button> -->
|
||||||
<h1>Hello World!</h1>
|
<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>Welcome to your Electron application.</p>
|
||||||
<p>Input Text</p>
|
<p>Input Text</p>
|
||||||
<input type="text" id="txtBox" name="name" size="80">
|
<input type="text" id="txtBox" name="name" size="80">
|
||||||
@ -26,7 +25,10 @@
|
|||||||
<input type="text" id="urlBox" name="name" size="80">
|
<input type="text" id="urlBox" name="name" size="80">
|
||||||
<p>Input Directory</p>
|
<p>Input Directory</p>
|
||||||
<input type="text" id="dirBox" name="name" size="80">
|
<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/>
|
<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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -11,18 +11,29 @@ if (require('electron-squirrel-startup')) {
|
|||||||
app.quit();
|
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 = () => {
|
const createWindow = () => {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
const mainWindow = new BrowserWindow({
|
const mainWindow = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, 'preload.js'),
|
preload: path.join(__dirname, 'preload.js')
|
||||||
nodeIntegration: true,
|
|
||||||
contextIsolation: true,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
mainWindow.loadFile(path.join(__dirname, 'index.html'));
|
mainWindow.loadFile(path.join(__dirname, 'index.html'));
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -70,9 +81,9 @@ ipcMain.on('select-dirs', async(event, arg) => {
|
|||||||
|
|
||||||
|
|
||||||
// Download a file
|
// Download a file
|
||||||
ipcMain.on("download", (event, url, properties) => {
|
ipcMain.on("download", async(event, url) => {
|
||||||
properties.onProgress = status => window.webContents.send("download progress", status);
|
//properties.onProgress = status => window.webContents.send("download progress", status);
|
||||||
download(BrowserWindow.getFocusedWindow(), url, properties)
|
download(BrowserWindow.getFocusedWindow(), url)
|
||||||
.then(dl => window.webContents.send("download complete", dl.getSavePath()));
|
.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
|
// Change me for file save
|
||||||
@ -28,7 +34,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
// Change me for select directory
|
// Change me for select directory
|
||||||
process.once('loaded', () => {
|
process.once('loaded', () => {
|
||||||
@ -37,4 +43,4 @@ process.once('loaded', () => {
|
|||||||
ipcRenderer.send('select-dirs')
|
ipcRenderer.send('select-dirs')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});*/
|
@ -10,8 +10,12 @@ const writeFile = document.querySelector('writeFile');
|
|||||||
const { remote, ipcRenderer } = require('electron');
|
const { remote, ipcRenderer } = require('electron');
|
||||||
const { writeFile } = require('fs');
|
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) => {
|
ipcRenderer.on("download complete", (event, file) => {
|
||||||
console.log(file); // Full file path
|
console.log(file); // Full file path
|
||||||
});
|
});
|
||||||
@ -29,3 +33,10 @@ document.getElementById('dirs').addEventListener('click', (evt) => {
|
|||||||
type: 'select-dirs',
|
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