You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

54 lines
1.4 KiB

/**
* electron 主文件
*/
// import "@src/common/patch"
import Shared from "./share"
const { join } = require("path")
const { app, BrowserWindow } = require("electron")
import "./menu"
Shared.data = {
mainWindow: null,
floatWindow: null,
miniWindow: null,
forceClose: false,
}
let isDev = process.env.NODE_ENV == "development" ? true : false
if (!isDev) {
// @ts-ignore
global.__static = require("path").join(__dirname, "/static").replace(/\\/g, "\\\\")
}
function createWin() {
// 创建浏览器窗口dsaasdad
Shared.data.mainWindow = new BrowserWindow({
height: 800,
useContentSize: true,
width: 900,
// resizable: false,
// minWidth: 450,
// minHeight: 400,
// frame: false,
// transparent: true,
alwaysOnTop: true,
icon: __static + "/icon.png",
webPreferences: {
// 下面两个必须这么用,看a.md的文档
nodeIntegration: true,
contextIsolation: false,
// 预加载动画
// preload: join(__dirname, "../../src/preload/index.js"),
},
})
const URL = app.isPackaged
? `file://${__dirname}/index.html` // vite 构建后的静态文件地址
// : `http://localhost:${process.env.PORT}/#/` // vite 启动的服务器地址
: `http://localhost:8080/#/` // vite 启动的服务器地址
Shared.data.mainWindow?.loadURL(URL)
}
app.whenReady().then(createWin)