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