Movatterモバイル変換


[0]ホーム

URL:


Skip to content
Search Gists
Sign in Sign up

Instantly share code, notes, and snippets.

@RareScrap
CreatedDecember 10, 2025 07:41
    • Star(0)You must be signed in to star a gist
    • Fork(0)You must be signed in to fork a gist

    Select an option

    Save RareScrap/0a3fa1470f2c483f18f022ae3ce9b4e9 to your computer and use it in GitHub Desktop.
    Incorrect Electron documentation showcase
    <!DOCTYPE html>
    <html>
    <head>
    <metacharset="UTF-8">
    <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
    <metahttp-equiv="Content-Security-Policy"content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'">
    <title>Hello World!</title>
    </head>
    <body>
    <h1>Hello World!</h1>
    We are using Node.js<spanid="node-version"></span>,
    Chromium<spanid="chrome-version"></span>,
    and Electron<spanid="electron-version"></span>.
    <buttonid="myButton">Click Me!</button>
    <!-- You can also require other files to run in this process -->
    <scriptsrc="./renderer.js"></script>
    </body>
    </html>
    const{ app, BrowserWindow, ipcMain}=require('electron')
    constpath=require('node:path')
    functioncreateWindow(){
    constmainWindow=newBrowserWindow({
    width:800,
    height:600,
    roundedCorners:false,// Docs says that setting this property to false will prevent the window from being fullscreenable on macOS but it's not true
    frame:false,
    webPreferences:{
    preload:path.join(__dirname,'preload.js')
    }
    })
    mainWindow.loadFile('index.html')
    mainWindow.webContents.openDevTools()
    returnmainWindow
    }
    app.whenReady().then(()=>{
    constmainWindow=createWindow()
    ipcMain.on("enable-fullscreen",()=>{
    mainWindow.setFullScreen(true)
    })
    app.on('activate',function(){
    // On macOS it's common to re-create a window in the app when the
    // dock icon is clicked and there are no other windows open.
    if(BrowserWindow.getAllWindows().length===0)createWindow()
    })
    })
    // Quit when all windows are closed, except on macOS. There, it's common
    // for applications and their menu bar to stay active until the user quits
    // explicitly with Cmd + Q.
    app.on('window-all-closed',function(){
    if(process.platform!=='darwin')app.quit()
    })
    {
    "name":"understood-gate-chop-vba1s",
    "productName":"understood-gate-chop-vba1s",
    "description":"My Electron application description",
    "keywords": [],
    "main":"./main.js",
    "version":"1.0.0",
    "author":"rarescrap",
    "scripts": {
    "start":"electron ."
    },
    "dependencies": {},
    "devDependencies": {
    "electron":"39.0.0"
    }
    }
    // import { contextBridge, ipcRenderer } from 'electron';
    const{ contextBridge}=require('electron')
    const{ ipcRenderer}=require('electron')
    contextBridge.exposeInMainWorld("ipc",{
    "enableFullscreen":()=>ipcRenderer.send("enable-fullscreen")
    })
    constbutton=document.getElementById("myButton");
    button.addEventListener("click",function(){
    window.ipc.enableFullscreen()
    });
    Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

    [8]ページ先頭

    ©2009-2025 Movatter.jp