tutorial-preload
This commit is contained in:
parent
03618b22e3
commit
6946a7821b
4 changed files with 19 additions and 10 deletions
|
@ -6,9 +6,16 @@
|
|||
http-equiv="Content-Security-Policy"
|
||||
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>
|
||||
</head>
|
||||
<body>
|
||||
<script src="../dist/renderer.js"></script>
|
||||
<h1>Discord Video Sharing</h1>
|
||||
<p id="info"></p>
|
||||
|
||||
<script src="../dist/scripts/renderer.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
window.addEventListener("DOMContentLoaded", () => {
|
||||
const replaceText = (selector: string, text: string) => {
|
||||
const element = document.getElementById(selector);
|
||||
if (element) element.innerText = text;
|
||||
};
|
||||
import { contextBridge } from "electron";
|
||||
|
||||
for (const dependency of ["chrome", "node", "electron"]) {
|
||||
replaceText(`${dependency}-version`, process.versions[dependency]);
|
||||
}
|
||||
contextBridge.exposeInMainWorld("versions", {
|
||||
node: () => process.versions.node,
|
||||
chrome: () => process.versions.chrome,
|
||||
electron: () => process.versions.electron,
|
||||
});
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
console.log("hello");
|
6
src/scripts/renderer.ts
Normal file
6
src/scripts/renderer.ts
Normal 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()})`;
|
Loading…
Reference in a new issue