diff --git a/src/client/pages/[locale]/live-painting.tsx b/src/client/pages/[locale]/live-painting.tsx index 2ef643832..bbf69ed6d 100644 --- a/src/client/pages/[locale]/live-painting.tsx +++ b/src/client/pages/[locale]/live-painting.tsx @@ -11,6 +11,8 @@ import { useTranslation } from "next-i18next"; import type { PointerEvent as ReactPointerEvent } from "react"; import { useEffect, useRef, useState } from "react"; +import { buildKey } from "#/build-key"; +import { ID } from "#/enums"; import { makeStaticProperties } from "@/ions/i18n/get-static"; export type ViewType = "side-by-side" | "overlay"; @@ -55,6 +57,7 @@ function DrawingArea() { context.current?.stroke(); const dataUrl = canvas.current.toDataURL(); setImage(dataUrl); + window.ipc.send(buildKey([ID.LIVE_PAINT], { suffix: ":dataUrl" }), dataUrl); } function handleMouseUp() { @@ -184,6 +187,23 @@ export default function Page(_properties: InferGetStaticPropsType {t("labels:livePainting")} + + + + + { ipcMain.on(buildKey([ID.USER], { suffix: ":language" }), (_event, language) => { userStore.set("language", language); }); + +let process: ExecaChildProcess; + +ipcMain.on(buildKey([ID.LIVE_PAINT], { suffix: ":dataUrl" }), (_event, dataUrl) => { + console.log("image input"); +}); + +ipcMain.on(buildKey([ID.LIVE_PAINT], { suffix: ":start" }), () => { + if (!process) { + process = execa("echo", ["hello", "world", "!"], { stdout: "inherit" }); + console.log("alive"); + } +}); + +ipcMain.on(buildKey([ID.LIVE_PAINT], { suffix: ":stop" }), () => { + if (!process.killed) { + const result = process.kill(); + console.log("killed", result); + } + + console.log(process.pid); +}); diff --git a/src/shared/enums.ts b/src/shared/enums.ts index 248cafbff..223034d49 100644 --- a/src/shared/enums.ts +++ b/src/shared/enums.ts @@ -15,6 +15,7 @@ export enum ID { STORE = "STORE", USER = "USER", WINDOW = "WINDOW", + LIVE_PAINT = "LIVE_PAINT", } /**