docs: enable contextIsolation in fiddles (#39613)
This commit is contained in:
parent
2e79f34c84
commit
9280b79112
61 changed files with 206 additions and 233 deletions
|
@ -18,9 +18,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// You can also require other files to run in this process
|
||||
require('./renderer.js')
|
||||
</script>
|
||||
<script src="renderer.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,4 +1,5 @@
|
|||
const { app, BrowserWindow, ipcMain, shell } = require('electron/main')
|
||||
const path = require('node:path')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
|
@ -10,8 +11,7 @@ function createWindow () {
|
|||
height: 400,
|
||||
title: 'Get app information',
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
const { contextBridge, ipcRenderer } = require('electron/renderer')
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
getAppPath: () => ipcRenderer.invoke('get-app-path')
|
||||
})
|
|
@ -1,9 +1,7 @@
|
|||
const { ipcRenderer } = require('electron/renderer')
|
||||
|
||||
const appInfoBtn = document.getElementById('app-info')
|
||||
|
||||
appInfoBtn.addEventListener('click', async () => {
|
||||
const path = await ipcRenderer.invoke('get-app-path')
|
||||
const path = await window.electronAPI.getAppPath()
|
||||
const message = `This app is located at: ${path}`
|
||||
document.getElementById('got-app-info').innerHTML = message
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue