mirror of
https://github.com/upscayl/upscayl.git
synced 2024-11-27 17:00:52 +01:00
sending to renderer
This commit is contained in:
parent
0db72d247d
commit
f0cd30ee3b
@ -1,7 +1,7 @@
|
||||
// Native
|
||||
const { join } = require("path");
|
||||
const { format } = require("url");
|
||||
const { spawn } = require("child_process");
|
||||
const { spawn, spawnSync, execFile } = require("child_process");
|
||||
const fs = require("fs");
|
||||
|
||||
const { execPath, modelsPath } = require("./binaries");
|
||||
@ -51,7 +51,7 @@ ipcMain.on("sendMessage", (_, message) => {
|
||||
console.log(message);
|
||||
});
|
||||
|
||||
ipcMain.on("open", async () => {
|
||||
ipcMain.on("open", async (command, payload) => {
|
||||
const { canceled, filePaths } = await dialog.showOpenDialog({
|
||||
properties: ["openFile", "multiSelections"],
|
||||
});
|
||||
@ -78,7 +78,7 @@ ipcMain.on("open", async () => {
|
||||
});
|
||||
|
||||
// UPSCALE
|
||||
let upscayl = spawn(
|
||||
let upscayl = execFile(
|
||||
execPath,
|
||||
[
|
||||
"-i",
|
||||
@ -94,12 +94,15 @@ ipcMain.on("open", async () => {
|
||||
],
|
||||
{
|
||||
cwd: null,
|
||||
detached: false,
|
||||
detached: true,
|
||||
//stdio: 'ignore',
|
||||
}
|
||||
);
|
||||
upscayl.stdout.on("data", (stdout) => {
|
||||
console.log("UPSCAYL: ", stdout.toString());
|
||||
//upscayl.unref()
|
||||
upscayl.stdout.on('data', (stdout) => {
|
||||
console.log("SOME SAMPLE OUTPUT")
|
||||
// TODO: SEND THE STDOUT TO RENDERER FROM HERE
|
||||
command.sender.send("stdout", "this is not working")
|
||||
});
|
||||
|
||||
upscayl.stderr.on("data", (stderr) => {
|
||||
@ -108,6 +111,7 @@ ipcMain.on("open", async () => {
|
||||
|
||||
upscayl.on("close", (code) => {
|
||||
console.log("Done upscaling", code);
|
||||
command.sender.send("stdout", "gelbana")
|
||||
});
|
||||
|
||||
return filePaths[0];
|
||||
|
@ -7,4 +7,10 @@ contextBridge.exposeInMainWorld("electron", {
|
||||
ipcRenderer.on(command, (event, args) => {
|
||||
func(...args);
|
||||
}),
|
||||
startListen: (func) => {
|
||||
ipcRenderer.addListener("stdout",func)
|
||||
},
|
||||
stopListen: (func) => {
|
||||
ipcRenderer.removeListener("stdout",func)
|
||||
},
|
||||
});
|
||||
|
@ -5,6 +5,8 @@ const Home = () => {
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const handleMessage = (_event, args) => console.log(args)
|
||||
window.electron.startListen(handleMessage)
|
||||
// send(command, payload)
|
||||
window.electron.send("sendMessage", { message: "Hello!" });
|
||||
setLoaded(true);
|
||||
@ -12,6 +14,9 @@ const Home = () => {
|
||||
window.electron.on("done", () => {
|
||||
console.log("DONE");
|
||||
});
|
||||
return () => {
|
||||
window.electron.stopListen(handleMessage)
|
||||
}
|
||||
}, []);
|
||||
|
||||
const imageHandler = async () => {
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.5 MiB After Width: | Height: | Size: 2.5 MiB |
Loading…
Reference in New Issue
Block a user