feat(electron): add Electron desktop wrapper
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
const path = require('path')
|
||||
|
||||
const ENV_URLS = {
|
||||
dev: 'http://192.168.1.14:7033',
|
||||
uat: 'http://nas.wjl-work.top:7034',
|
||||
}
|
||||
|
||||
function getWindowUrl() {
|
||||
const envArg = process.argv.find(a => a.startsWith('--env='))
|
||||
if (envArg) {
|
||||
const env = envArg.split('=')[1]
|
||||
return ENV_URLS[env] || ENV_URLS.dev
|
||||
}
|
||||
return ENV_URLS.dev
|
||||
}
|
||||
|
||||
function createWindow() {
|
||||
const win = new BrowserWindow({
|
||||
width: 1280,
|
||||
height: 800,
|
||||
minWidth: 960,
|
||||
minHeight: 600,
|
||||
title: 'Game Group',
|
||||
autoHideMenuBar: true,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
contextIsolation: true,
|
||||
webSecurity: false,
|
||||
},
|
||||
})
|
||||
|
||||
const url = getWindowUrl()
|
||||
win.loadURL(url)
|
||||
|
||||
// 页面标题同步
|
||||
win.on('page-title-updated', (event, title) => {
|
||||
event.preventDefault()
|
||||
win.setTitle(`Game Group - ${title}`)
|
||||
})
|
||||
}
|
||||
|
||||
app.whenReady().then(createWindow)
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
app.quit()
|
||||
})
|
||||
Reference in New Issue
Block a user