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.
50 lines
1.2 KiB
50 lines
1.2 KiB
/**
|
|
* electron 主文件
|
|
*/
|
|
// import "@src/common/patch"
|
|
import Shared from "./share"
|
|
const { join } = require("path")
|
|
const { app, BrowserWindow } = require("electron")
|
|
|
|
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, "\\\\")
|
|
}
|
|
|
|
let win
|
|
|
|
function createWin() {
|
|
// 创建浏览器窗口dsaasdad
|
|
console.log(process.env.NODE_ENV);
|
|
console.log(__dirname);
|
|
console.log(join(__dirname, "../../src/preload/index.js"));
|
|
|
|
win = new BrowserWindow({
|
|
width: 1024,
|
|
height: 768,
|
|
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 启动的服务器地址
|
|
|
|
win?.loadURL(URL)
|
|
}
|
|
|
|
app.whenReady().then(createWin)
|
|
|