💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 示例1.无边框窗口 ## 1.项目目录结构: ~~~ frameless-window/ ├── assets //一些资源 ├── lib // 核心代码 └── package.json // 包描述文件 ~~~ ## 2.package.json ~~~ { "name":"frameless-window", "main":"./lib/index.js", "version":"0.1.0" } ~~~ ## 3.配置VSCode 调试 在项目下 .vscode/ 目录下增加 launch.json : ~~~ { "version": "0.2.0", "configurations": [ { "name": "Electron 主进程调试", "type": "node", "request": "launch", "cwd": "${workspaceRoot}", "runtimeExecutable": "path/to/electron.exe", "program": "${workspaceRoot}/lib/index.js" } ] } ~~~ ## 4.index.js ~~~ const {app, BrowserWindow} = require('electron') let win function createWindow(){ win = new BrowserWindow({ width:360, height:640, frame:false, show:false, center: true, minWidth:220, minHeight:220 }) // win.openDevTools() win.loadURL(`file://${__dirname}/../resources/index.html`) win.on('ready-to-show',()=>{ win.show() }) // win.on('closed',()=>{ win = null }) } app.on('ready',createWindow) app.on('window-all-closed',()=>{ if(process.platform !== 'darwin'){ app.quit() } }) //处理 Mac 的 Dock 图标点击 app.on('activate', ()=>{ if(win === null){ createWindow() } }) ~~~