tutorial-preload

This commit is contained in:
Mylloon 2023-07-29 16:15:34 +02:00
parent 03618b22e3
commit 6946a7821b
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
4 changed files with 19 additions and 10 deletions

View file

@ -6,9 +6,16 @@
http-equiv="Content-Security-Policy" http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self'" content="default-src 'self'; script-src 'self'"
/> />
<meta
http-equiv="X-Content-Security-Policy"
content="default-src 'self'; script-src 'self'"
/>
<title>Discord Video Sharing</title> <title>Discord Video Sharing</title>
</head> </head>
<body> <body>
<script src="../dist/renderer.js"></script> <h1>Discord Video Sharing</h1>
<p id="info"></p>
<script src="../dist/scripts/renderer.js"></script>
</body> </body>
</html> </html>

View file

@ -1,10 +1,7 @@
window.addEventListener("DOMContentLoaded", () => { import { contextBridge } from "electron";
const replaceText = (selector: string, text: string) => {
const element = document.getElementById(selector);
if (element) element.innerText = text;
};
for (const dependency of ["chrome", "node", "electron"]) { contextBridge.exposeInMainWorld("versions", {
replaceText(`${dependency}-version`, process.versions[dependency]); node: () => process.versions.node,
} chrome: () => process.versions.chrome,
electron: () => process.versions.electron,
}); });

View file

@ -1 +0,0 @@
console.log("hello");

6
src/scripts/renderer.ts Normal file
View file

@ -0,0 +1,6 @@
/* Preload variables */
var versions: any;
const information = document.getElementById("info");
information.innerText = `Cette application utilise Chrome (v${versions.chrome()}), Node.js (v${versions.node()}), et Electron (v${versions.electron()})`;