docs: use electron/main & electron/renderer imports in fiddles (#39666)
This commit is contained in:
parent
d42a94ddde
commit
f2f83a73fc
70 changed files with 78 additions and 88 deletions
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow, ipcMain, nativeTheme } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, nativeTheme } = require('electron/main')
|
||||
const path = require('node:path')
|
||||
|
||||
function createWindow () {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
const { contextBridge, ipcRenderer } = require('electron/renderer')
|
||||
|
||||
contextBridge.exposeInMainWorld('darkMode', {
|
||||
toggle: () => ipcRenderer.invoke('dark-mode:toggle'),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow, ipcMain } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain } = require('electron/main')
|
||||
const path = require('node:path')
|
||||
const fs = require('node:fs')
|
||||
const https = require('node:https')
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
const { contextBridge, ipcRenderer } = require('electron/renderer')
|
||||
|
||||
contextBridge.exposeInMainWorld('electron', {
|
||||
startDrag: (fileName) => {
|
||||
ipcRenderer.send('ondragstart', fileName)
|
||||
}
|
||||
startDrag: (fileName) => ipcRenderer.send('ondragstart', fileName)
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow, globalShortcut } = require('electron')
|
||||
const { app, BrowserWindow, globalShortcut } = require('electron/main')
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow } = require('electron/main')
|
||||
|
||||
app.whenReady().then(() => {
|
||||
const win = new BrowserWindow({ width: 800, height: 600 })
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow, Menu, MenuItem } = require('electron')
|
||||
const { app, BrowserWindow, Menu, MenuItem } = require('electron/main')
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow } = require('electron/main')
|
||||
|
||||
function createWindow () {
|
||||
// Create the browser window.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow, Menu } = require('electron')
|
||||
const { app, BrowserWindow, Menu } = require('electron/main')
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow, Notification } = require('electron')
|
||||
const { app, BrowserWindow, Notification } = require('electron/main')
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow } = require('electron/main')
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow } = require('electron/main')
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow } = require('electron/main')
|
||||
|
||||
function createWindow () {
|
||||
const onlineStatusWindow = new BrowserWindow({
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow } = require('electron/main')
|
||||
|
||||
let progressInterval
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow } = require('electron/main')
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow } = require('electron/main')
|
||||
const os = require('node:os')
|
||||
|
||||
function createWindow () {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow, ipcMain } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain } = require('electron/main')
|
||||
const path = require('node:path')
|
||||
|
||||
let bluetoothPinCallback
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
const { contextBridge, ipcRenderer } = require('electron/renderer')
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
cancelBluetoothRequest: (callback) => ipcRenderer.send('cancel-bluetooth-request', callback),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow } = require('electron/main')
|
||||
|
||||
function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow } = require('electron/main')
|
||||
|
||||
function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow } = require('electron/main')
|
||||
|
||||
function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow, ipcMain } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain } = require('electron/main')
|
||||
const path = require('node:path')
|
||||
|
||||
function createWindow () {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
const { contextBridge, ipcRenderer } = require('electron/renderer')
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
setTitle: (title) => ipcRenderer.send('set-title', title)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow, ipcMain, dialog } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, dialog } = require('electron/main')
|
||||
const path = require('node:path')
|
||||
|
||||
async function handleFileOpen () {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
const { contextBridge, ipcRenderer } = require('electron/renderer')
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
openFile: () => ipcRenderer.invoke('dialog:openFile')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow, Menu, ipcMain } = require('electron')
|
||||
const { app, BrowserWindow, Menu, ipcMain } = require('electron/main')
|
||||
const path = require('node:path')
|
||||
|
||||
function createWindow () {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
const { contextBridge, ipcRenderer } = require('electron/renderer')
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
handleCounter: (callback) => ipcRenderer.on('update-counter', callback)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow } = require('electron/main')
|
||||
const path = require('node:path')
|
||||
|
||||
function createWindow () {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { ipcRenderer } = require('electron')
|
||||
const { ipcRenderer } = require('electron/renderer')
|
||||
const webview = document.getElementById('webview')
|
||||
ipcRenderer.on('webview-new-window', (e, webContentsId, details) => {
|
||||
console.log('webview-new-window', webContentsId, details)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { BrowserWindow, app, screen, ipcMain, desktopCapturer } = require('electron')
|
||||
const { BrowserWindow, app, screen, ipcMain, desktopCapturer } = require('electron/main')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { shell, ipcRenderer } = require('electron')
|
||||
const { shell, ipcRenderer } = require('electron/renderer')
|
||||
|
||||
const fs = require('node:fs').promises
|
||||
const os = require('node:os')
|
||||
|
|
|
@ -6,8 +6,9 @@ const {
|
|||
ipcMain,
|
||||
app,
|
||||
shell,
|
||||
dialog
|
||||
} = require('electron')
|
||||
dialog,
|
||||
autoUpdater
|
||||
} = require('electron/main')
|
||||
|
||||
const menu = new Menu()
|
||||
menu.append(new MenuItem({ label: 'Hello' }))
|
||||
|
@ -185,7 +186,7 @@ function addUpdateMenuItems (items, position) {
|
|||
visible: false,
|
||||
key: 'checkForUpdate',
|
||||
click: () => {
|
||||
require('electron').autoUpdater.checkForUpdates()
|
||||
autoUpdater.checkForUpdates()
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -194,7 +195,7 @@ function addUpdateMenuItems (items, position) {
|
|||
visible: false,
|
||||
key: 'restartToUpdate',
|
||||
click: () => {
|
||||
require('electron').autoUpdater.quitAndInstall()
|
||||
autoUpdater.quitAndInstall()
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { ipcRenderer } = require('electron')
|
||||
const { ipcRenderer } = require('electron/renderer')
|
||||
|
||||
// Tell main process to show the menu when demo button is clicked
|
||||
const contextMenuBtn = document.getElementById('context-menu')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, globalShortcut, dialog, shell } = require('electron')
|
||||
const { app, BrowserWindow, globalShortcut, dialog, shell } = require('electron/main')
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron/main')
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { ipcRenderer } = require('electron')
|
||||
const { ipcRenderer } = require('electron/renderer')
|
||||
|
||||
const errorBtn = document.getElementById('error-dialog')
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron/main')
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { ipcRenderer } = require('electron')
|
||||
const { ipcRenderer } = require('electron/renderer')
|
||||
|
||||
const informationBtn = document.getElementById('information-dialog')
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron/main')
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { ipcRenderer } = require('electron')
|
||||
const { ipcRenderer } = require('electron/renderer')
|
||||
|
||||
const selectDirBtn = document.getElementById('select-directory')
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron/main')
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { ipcRenderer } = require('electron')
|
||||
const { ipcRenderer } = require('electron/renderer')
|
||||
|
||||
const saveBtn = document.getElementById('save-dialog')
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain, nativeImage, shell } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, nativeImage, shell } = require('electron/main')
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
let mainWindow
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { ipcRenderer } = require('electron')
|
||||
const { ipcRenderer } = require('electron/renderer')
|
||||
|
||||
const dragFileLink = document.getElementById('drag-file-link')
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, shell } = require('electron')
|
||||
const { app, BrowserWindow, shell } = require('electron/main')
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { shell } = require('electron')
|
||||
const { shell } = require('electron/renderer')
|
||||
const os = require('node:os')
|
||||
|
||||
const exLinksBtn = document.getElementById('open-ex-links')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, shell } = require('electron')
|
||||
const { app, BrowserWindow, shell } = require('electron/main')
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, Tray, Menu, nativeImage } = require('electron')
|
||||
const { app, Tray, Menu, nativeImage } = require('electron/main')
|
||||
|
||||
let tray
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow } = require('electron/main')
|
||||
const path = require('node:path')
|
||||
|
||||
function createWindow () {
|
||||
|
|
|
@ -3,14 +3,11 @@
|
|||
// For more info, see:
|
||||
// https://www.electronjs.org/docs/latest/api/screen
|
||||
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow, screen } = require('electron/main')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
app.whenReady().then(() => {
|
||||
// We cannot require the screen module until the app is ready.
|
||||
const { screen } = require('electron')
|
||||
|
||||
// Create a window that fills the screen's available work area.
|
||||
const primaryDisplay = screen.getPrimaryDisplay()
|
||||
const { width, height } = primaryDisplay.workAreaSize
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow, ipcMain, clipboard } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, clipboard } = require('electron/main')
|
||||
const path = require('node:path')
|
||||
|
||||
let mainWindow = null
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
const { contextBridge, ipcRenderer } = require('electron/renderer')
|
||||
|
||||
contextBridge.exposeInMainWorld('clipboard', {
|
||||
writeText: (text) => ipcRenderer.invoke('clipboard:writeText', text)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow, ipcMain, clipboard } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, clipboard } = require('electron/main')
|
||||
const path = require('node:path')
|
||||
|
||||
let mainWindow = null
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
const { contextBridge, ipcRenderer } = require('electron/renderer')
|
||||
|
||||
contextBridge.exposeInMainWorld('clipboard', {
|
||||
readText: () => ipcRenderer.invoke('clipboard:readText'),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain, shell, dialog } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, shell, dialog } = require('electron/main')
|
||||
const path = require('node:path')
|
||||
|
||||
let mainWindow
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
// All of the Node.js APIs are available in the preload process.
|
||||
// It has the same sandbox as a Chrome extension.
|
||||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
const { contextBridge, ipcRenderer } = require('electron/renderer')
|
||||
|
||||
// Set up context bridge between the renderer process and the main process
|
||||
contextBridge.exposeInMainWorld(
|
||||
'shell',
|
||||
{
|
||||
open: () => ipcRenderer.send('shell:open')
|
||||
}
|
||||
)
|
||||
contextBridge.exposeInMainWorld('shell', {
|
||||
open: () => ipcRenderer.send('shell:open')
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow, ipcMain, shell } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, shell } = require('electron/main')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { ipcRenderer } = require('electron')
|
||||
const { ipcRenderer } = require('electron/renderer')
|
||||
|
||||
const appInfoBtn = document.getElementById('app-info')
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow, shell } = require('electron')
|
||||
const { app, BrowserWindow, shell } = require('electron/main')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow } = require('electron/main')
|
||||
|
||||
const createWindow = () => {
|
||||
const win = new BrowserWindow({
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow } = require('electron/main')
|
||||
const path = require('node:path')
|
||||
|
||||
const createWindow = () => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { contextBridge } = require('electron')
|
||||
const { contextBridge } = require('electron/renderer')
|
||||
|
||||
contextBridge.exposeInMainWorld('versions', {
|
||||
node: () => process.versions.node,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain, shell } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, shell } = require('electron/main')
|
||||
|
||||
ipcMain.on('create-frameless-window', (event, { url }) => {
|
||||
const win = new BrowserWindow({ frame: false })
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { ipcRenderer } = require('electron')
|
||||
const { ipcRenderer } = require('electron/renderer')
|
||||
|
||||
const newWindowBtn = document.getElementById('frameless-window')
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain, shell } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, shell } = require('electron/main')
|
||||
|
||||
ipcMain.on('create-demo-window', (event) => {
|
||||
const win = new BrowserWindow({ width: 400, height: 275 })
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { ipcRenderer } = require('electron')
|
||||
const { ipcRenderer } = require('electron/renderer')
|
||||
|
||||
const manageWindowBtn = document.getElementById('manage-window')
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain, shell } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, shell } = require('electron/main')
|
||||
|
||||
ipcMain.on('new-window', (event, { url, width, height }) => {
|
||||
const win = new BrowserWindow({ width, height })
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { ipcRenderer } = require('electron')
|
||||
const { ipcRenderer } = require('electron/renderer')
|
||||
|
||||
const newWindowBtn = document.getElementById('new-window')
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain, shell } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, shell } = require('electron/main')
|
||||
|
||||
function createWindow () {
|
||||
// Create the browser window.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { ipcRenderer } = require('electron')
|
||||
const { ipcRenderer } = require('electron/renderer')
|
||||
|
||||
const listenToWindowBtn = document.getElementById('listen-to-window')
|
||||
const focusModalBtn = document.getElementById('focus-on-modal-window')
|
||||
|
|
Loading…
Reference in a new issue