1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- import { app, BrowserWindow } from 'electron'
- import { resolve } from 'path'
- import installDevTool, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'
- import path from 'path'
- if (!app.requestSingleInstanceLock()) {
- app.quit()
- process.exit(0)
- }
- async function createWindow() {
- const loadingView = new BrowserWindow({
- width: 520,
- height: 150,
- frame: false,
- icon: path.join(__dirname, './icons/icon.png'),
- resizable: false,
- transparent: true,
- show: true,
- webPreferences: {
- preload: path.join(__dirname, '../preload/preload'),
- },
- })
- loadingView.loadFile(resolve(__dirname, 'loading.html'))
- const mainWin = new BrowserWindow({
- show: false,
- width: 1680,
- height: 880,
- frame: false,
- center: true,
- icon: path.join(__dirname, './icons/icon.png'),
- resizable: false,
- fullscreen: true,
- fullscreenable: true,
- alwaysOnTop: false,
- useContentSize: true,
- transparent: true,
- webPreferences: {
- devTools: true,
- nodeIntegration: false,
- contextIsolation: true,
- webSecurity: false,
- experimentalFeatures: true,
- navigateOnDragDrop: false,
- disableHtmlFullscreenWindowResize: false,
- preload: path.join(__dirname, '../preload/preload'),
- },
- })
- mainWin.setMenu(null)
- if (!app.isPackaged) {
- mainWin.webContents.on('before-input-event', (event, input) => {
- if (input.key === 'F12') {
- mainWin.webContents.openDevTools()
- }
- })
- }
- mainWin.on('ready-to-show', () => {
- loadingView.destroy()
- mainWin.show()
- })
- if (app.isPackaged) {
- mainWin.loadURL('http://cet-test.markingtool.cn')
- } else {
- installDevTool(VUEJS_DEVTOOLS)
- process.env.WEB_DEV_INDEX_URL && mainWin.loadURL(process.env.WEB_DEV_INDEX_URL)
- }
- }
- app.on('window-all-closed', () => {
- if (process.platform !== 'darwin') app.quit()
- })
- app.whenReady().then(createWindow)
|