add ffmpeg to context bridge
This commit is contained in:
parent
0255515f77
commit
8829b9fe92
6 changed files with 37 additions and 21 deletions
13
css/style.css
Normal file
13
css/style.css
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
body {
|
||||||
|
background: rgb(18, 18, 18);
|
||||||
|
color: rgb(240, 240, 240);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: light) {
|
||||||
|
body {
|
||||||
|
background: rgb(240, 240, 240);
|
||||||
|
color: rgb(18, 18, 18);
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,9 @@
|
||||||
http-equiv="X-Content-Security-Policy"
|
http-equiv="X-Content-Security-Policy"
|
||||||
content="default-src 'self'; script-src 'self'"
|
content="default-src 'self'; script-src 'self'"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="../css/style.css" />
|
||||||
|
|
||||||
<title>Discord Video Sharing</title>
|
<title>Discord Video Sharing</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
17
src/main.ts
17
src/main.ts
|
@ -1,29 +1,34 @@
|
||||||
import { BrowserWindow, app, ipcMain } from "electron";
|
import { BrowserWindow, app, ipcMain } from "electron";
|
||||||
import path = require("path");
|
import path = require("path");
|
||||||
/* import ffmpegPath = require("ffmpeg-static"); */
|
import ffmpegPath = require("ffmpeg-static");
|
||||||
|
|
||||||
const createWindow = () => {
|
const createWindow = () => {
|
||||||
const win = new BrowserWindow({
|
const win = new BrowserWindow({
|
||||||
width: 800,
|
width: 1280,
|
||||||
height: 600,
|
height: 720,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, "preload.js"),
|
preload: path.join(__dirname, "preload.js"),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
win.loadFile(path.join(path.resolve(__dirname, ".."), "pages", "index.html"));
|
win.loadFile(path.join(path.resolve(__dirname, ".."), "pages", "index.html"));
|
||||||
|
win.webContents.openDevTools(); // debug
|
||||||
};
|
};
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
ipcMain.handle("ping", () => "pong");
|
ipcMain.handle("ffmpeg", () => ffmpegPath);
|
||||||
|
|
||||||
createWindow();
|
createWindow();
|
||||||
|
|
||||||
app.on("activate", () => {
|
app.on("activate", () => {
|
||||||
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
if (BrowserWindow.getAllWindows().length === 0) {
|
||||||
|
createWindow();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on("window-all-closed", () => {
|
app.on("window-all-closed", () => {
|
||||||
if (process.platform !== "darwin") app.quit();
|
if (process.platform !== "darwin") {
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
import { contextBridge, ipcRenderer } from "electron";
|
import { contextBridge, ipcRenderer } from "electron";
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld("versions", {
|
contextBridge.exposeInMainWorld("internals", {
|
||||||
node: () => process.versions.node,
|
ffmpeg: () => ipcRenderer.invoke("ffmpeg"),
|
||||||
chrome: () => process.versions.chrome,
|
|
||||||
electron: () => process.versions.electron,
|
|
||||||
ping: () => ipcRenderer.invoke("ping"),
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
/* Preload variables */
|
/* Context bridge */
|
||||||
var versions: any;
|
let internals: {
|
||||||
|
ffmpeg: () => Promise<string>;
|
||||||
|
};
|
||||||
|
|
||||||
const information = document.getElementById("info");
|
const get_ffmpeg = async () => {
|
||||||
|
const response = await internals.ffmpeg();
|
||||||
information.innerText = `Cette application utilise Chrome (v${versions.chrome()}), Node.js (v${versions.node()}), et Electron (v${versions.electron()})`;
|
|
||||||
|
|
||||||
const func = async () => {
|
|
||||||
const response = await versions.ping();
|
|
||||||
console.log(response);
|
console.log(response);
|
||||||
};
|
};
|
||||||
|
|
||||||
func();
|
get_ffmpeg();
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
"*": ["node_modules/*"]
|
"*": ["node_modules/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["src/**/*"]
|
"include": ["src/**/*.ts"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue