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"
|
||||
content="default-src 'self'; script-src 'self'"
|
||||
/>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../css/style.css" />
|
||||
|
||||
<title>Discord Video Sharing</title>
|
||||
</head>
|
||||
<body>
|
||||
|
|
17
src/main.ts
17
src/main.ts
|
@ -1,29 +1,34 @@
|
|||
import { BrowserWindow, app, ipcMain } from "electron";
|
||||
import path = require("path");
|
||||
/* import ffmpegPath = require("ffmpeg-static"); */
|
||||
import ffmpegPath = require("ffmpeg-static");
|
||||
|
||||
const createWindow = () => {
|
||||
const win = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
width: 1280,
|
||||
height: 720,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, "preload.js"),
|
||||
},
|
||||
});
|
||||
|
||||
win.loadFile(path.join(path.resolve(__dirname, ".."), "pages", "index.html"));
|
||||
win.webContents.openDevTools(); // debug
|
||||
};
|
||||
|
||||
app.whenReady().then(() => {
|
||||
ipcMain.handle("ping", () => "pong");
|
||||
ipcMain.handle("ffmpeg", () => ffmpegPath);
|
||||
|
||||
createWindow();
|
||||
|
||||
app.on("activate", () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
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";
|
||||
|
||||
contextBridge.exposeInMainWorld("versions", {
|
||||
node: () => process.versions.node,
|
||||
chrome: () => process.versions.chrome,
|
||||
electron: () => process.versions.electron,
|
||||
ping: () => ipcRenderer.invoke("ping"),
|
||||
contextBridge.exposeInMainWorld("internals", {
|
||||
ffmpeg: () => ipcRenderer.invoke("ffmpeg"),
|
||||
});
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
/* Preload variables */
|
||||
var versions: any;
|
||||
/* Context bridge */
|
||||
let internals: {
|
||||
ffmpeg: () => Promise<string>;
|
||||
};
|
||||
|
||||
const information = document.getElementById("info");
|
||||
|
||||
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();
|
||||
const get_ffmpeg = async () => {
|
||||
const response = await internals.ffmpeg();
|
||||
console.log(response);
|
||||
};
|
||||
|
||||
func();
|
||||
get_ffmpeg();
|
||||
|
|
|
@ -9,5 +9,5 @@
|
|||
"*": ["node_modules/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue