pack: add .editorconfig and use tab instead of space
This commit is contained in:
1 parent
be3638b9d3
commit
be7a8ac3ea
27 files changed
+571
-560
No files matched your search
+67
-67
@@ -3,91 +3,91 @@ import Constants from './utils/Constants'
|
||||
import * as electronRemote from '@electron/remote/main'
|
||||
|
||||
const exitApp = (mainWindow: BrowserWindow): void => {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.hide()
|
||||
}
|
||||
mainWindow.destroy()
|
||||
app.exit()
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.hide()
|
||||
}
|
||||
mainWindow.destroy()
|
||||
app.exit()
|
||||
}
|
||||
|
||||
export const createMainWindow = async (mainWindow: BrowserWindow): Promise<BrowserWindow> => {
|
||||
mainWindow = new BrowserWindow({
|
||||
title: Constants.APP_NAME,
|
||||
show: false,
|
||||
width: Constants.IS_DEV_ENV ? 1500 : 1200,
|
||||
height: 650,
|
||||
useContentSize: true,
|
||||
webPreferences: Constants.DEFAULT_WEB_PREFERENCES
|
||||
})
|
||||
mainWindow = new BrowserWindow({
|
||||
title: Constants.APP_NAME,
|
||||
show: false,
|
||||
width: Constants.IS_DEV_ENV ? 1500 : 1200,
|
||||
height: 650,
|
||||
useContentSize: true,
|
||||
webPreferences: Constants.DEFAULT_WEB_PREFERENCES
|
||||
})
|
||||
|
||||
mainWindow.setMenu(null)
|
||||
mainWindow.setMenu(null)
|
||||
|
||||
mainWindow.on('close', (event: Event) => {
|
||||
event.preventDefault()
|
||||
exitApp(mainWindow)
|
||||
})
|
||||
mainWindow.on('close', (event: Event) => {
|
||||
event.preventDefault()
|
||||
exitApp(mainWindow)
|
||||
})
|
||||
|
||||
mainWindow.webContents.on('did-frame-finish-load', () => {
|
||||
if (Constants.IS_DEV_ENV) {
|
||||
mainWindow.webContents.openDevTools()
|
||||
}
|
||||
})
|
||||
mainWindow.webContents.on('did-frame-finish-load', () => {
|
||||
if (Constants.IS_DEV_ENV) {
|
||||
mainWindow.webContents.openDevTools()
|
||||
}
|
||||
})
|
||||
|
||||
mainWindow.once('ready-to-show', () => {
|
||||
mainWindow.setAlwaysOnTop(true)
|
||||
mainWindow.show()
|
||||
mainWindow.focus()
|
||||
mainWindow.setAlwaysOnTop(false)
|
||||
mainWindow.once('ready-to-show', () => {
|
||||
mainWindow.setAlwaysOnTop(true)
|
||||
mainWindow.show()
|
||||
mainWindow.focus()
|
||||
mainWindow.setAlwaysOnTop(false)
|
||||
|
||||
electronRemote.initialize()
|
||||
})
|
||||
electronRemote.initialize()
|
||||
})
|
||||
|
||||
if (Constants.IS_DEV_ENV) {
|
||||
await mainWindow.loadURL(Constants.APP_INDEX_URL_DEV)
|
||||
} else {
|
||||
await mainWindow.loadFile(Constants.APP_INDEX_URL_PROD)
|
||||
}
|
||||
if (Constants.IS_DEV_ENV) {
|
||||
await mainWindow.loadURL(Constants.APP_INDEX_URL_DEV)
|
||||
} else {
|
||||
await mainWindow.loadFile(Constants.APP_INDEX_URL_PROD)
|
||||
}
|
||||
|
||||
return mainWindow
|
||||
return mainWindow
|
||||
}
|
||||
|
||||
export const createErrorWindow = async (
|
||||
errorWindow: BrowserWindow,
|
||||
mainWindow: BrowserWindow,
|
||||
details?: RenderProcessGoneDetails
|
||||
errorWindow: BrowserWindow,
|
||||
mainWindow: BrowserWindow,
|
||||
details?: RenderProcessGoneDetails
|
||||
): Promise<BrowserWindow> => {
|
||||
if (!Constants.IS_DEV_ENV) {
|
||||
mainWindow?.hide()
|
||||
}
|
||||
if (!Constants.IS_DEV_ENV) {
|
||||
mainWindow?.hide()
|
||||
}
|
||||
|
||||
errorWindow = new BrowserWindow({
|
||||
title: Constants.APP_NAME,
|
||||
show: false,
|
||||
resizable: Constants.IS_DEV_ENV,
|
||||
webPreferences: Constants.DEFAULT_WEB_PREFERENCES
|
||||
})
|
||||
errorWindow = new BrowserWindow({
|
||||
title: Constants.APP_NAME,
|
||||
show: false,
|
||||
resizable: Constants.IS_DEV_ENV,
|
||||
webPreferences: Constants.DEFAULT_WEB_PREFERENCES
|
||||
})
|
||||
|
||||
errorWindow.setMenu(null)
|
||||
errorWindow.setMenu(null)
|
||||
|
||||
if (Constants.IS_DEV_ENV) {
|
||||
await errorWindow.loadURL(`${Constants.APP_INDEX_URL_DEV}#/error`)
|
||||
} else {
|
||||
await errorWindow.loadFile(Constants.APP_INDEX_URL_PROD, { hash: 'error' })
|
||||
}
|
||||
if (Constants.IS_DEV_ENV) {
|
||||
await errorWindow.loadURL(`${Constants.APP_INDEX_URL_DEV}#/error`)
|
||||
} else {
|
||||
await errorWindow.loadFile(Constants.APP_INDEX_URL_PROD, { hash: 'error' })
|
||||
}
|
||||
|
||||
errorWindow.on('ready-to-show', () => {
|
||||
if (!Constants.IS_DEV_ENV && mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.destroy()
|
||||
}
|
||||
errorWindow.show()
|
||||
errorWindow.focus()
|
||||
})
|
||||
errorWindow.on('ready-to-show', () => {
|
||||
if (!Constants.IS_DEV_ENV && mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.destroy()
|
||||
}
|
||||
errorWindow.show()
|
||||
errorWindow.focus()
|
||||
})
|
||||
|
||||
errorWindow.webContents.on('did-frame-finish-load', () => {
|
||||
if (Constants.IS_DEV_ENV) {
|
||||
errorWindow.webContents.openDevTools()
|
||||
}
|
||||
})
|
||||
errorWindow.webContents.on('did-frame-finish-load', () => {
|
||||
if (Constants.IS_DEV_ENV) {
|
||||
errorWindow.webContents.openDevTools()
|
||||
}
|
||||
})
|
||||
|
||||
return errorWindow
|
||||
return errorWindow
|
||||
}
|
||||
+15
-15
@@ -7,33 +7,33 @@ let mainWindow
|
||||
let errorWindow
|
||||
|
||||
app.on('ready', () => {
|
||||
macOSDisableDefaultMenuItem()
|
||||
macOSDisableDefaultMenuItem()
|
||||
|
||||
mainWindow = createMainWindow(mainWindow)
|
||||
mainWindow = createMainWindow(mainWindow)
|
||||
})
|
||||
|
||||
app.on('activate', () => {
|
||||
if (!mainWindow) {
|
||||
mainWindow = createMainWindow(mainWindow)
|
||||
}
|
||||
if (!mainWindow) {
|
||||
mainWindow = createMainWindow(mainWindow)
|
||||
}
|
||||
})
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
mainWindow = null
|
||||
errorWindow = null
|
||||
mainWindow = null
|
||||
errorWindow = null
|
||||
|
||||
if (!Constants.IS_MAC) {
|
||||
app.quit()
|
||||
}
|
||||
if (!Constants.IS_MAC) {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
app.on(
|
||||
'render-process-gone',
|
||||
(event: Event, webContents: WebContents, details: RenderProcessGoneDetails) => {
|
||||
errorWindow = createErrorWindow(errorWindow, mainWindow, details)
|
||||
}
|
||||
'render-process-gone',
|
||||
(event: Event, webContents: WebContents, details: RenderProcessGoneDetails) => {
|
||||
errorWindow = createErrorWindow(errorWindow, mainWindow, details)
|
||||
}
|
||||
)
|
||||
|
||||
process.on('uncaughtException', () => {
|
||||
errorWindow = createErrorWindow(errorWindow, mainWindow)
|
||||
errorWindow = createErrorWindow(errorWindow, mainWindow)
|
||||
})
|
||||
+11
-11
@@ -1,19 +1,19 @@
|
||||
import { join } from 'path'
|
||||
|
||||
export default class Constants {
|
||||
static APP_NAME = 'Vutron'
|
||||
static APP_NAME = 'Vutron'
|
||||
|
||||
static IS_DEV_ENV = process.env.NODE_ENV === 'development'
|
||||
static IS_DEV_ENV = process.env.NODE_ENV === 'development'
|
||||
|
||||
static IS_MAC = process.platform === 'darwin'
|
||||
static IS_MAC = process.platform === 'darwin'
|
||||
|
||||
static DEFAULT_WEB_PREFERENCES = {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
nodeIntegrationInWorker: true,
|
||||
enableRemoteModule: true
|
||||
}
|
||||
static DEFAULT_WEB_PREFERENCES = {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
nodeIntegrationInWorker: true,
|
||||
enableRemoteModule: true
|
||||
}
|
||||
|
||||
static APP_INDEX_URL_DEV = 'http://localhost:5173/index.html'
|
||||
static APP_INDEX_URL_PROD = join(__dirname, '../index.html')
|
||||
static APP_INDEX_URL_DEV = 'http://localhost:5173/index.html'
|
||||
static APP_INDEX_URL_PROD = join(__dirname, '../index.html')
|
||||
}
|
||||
@@ -2,12 +2,12 @@ import { systemPreferences } from 'electron'
|
||||
import Constants from './Constants'
|
||||
|
||||
export default class Menus {
|
||||
static macOSDisableDefaultMenuItem(): void {
|
||||
if (Constants.IS_MAC) {
|
||||
systemPreferences.setUserDefault('NSDisabledDictationMenuItem', 'boolean', true)
|
||||
systemPreferences.setUserDefault('NSDisabledCharacterPaletteMenuItem', 'boolean', true)
|
||||
}
|
||||
}
|
||||
static macOSDisableDefaultMenuItem(): void {
|
||||
if (Constants.IS_MAC) {
|
||||
systemPreferences.setUserDefault('NSDisabledDictationMenuItem', 'boolean', true)
|
||||
systemPreferences.setUserDefault('NSDisabledCharacterPaletteMenuItem', 'boolean', true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const { macOSDisableDefaultMenuItem } = Menus
|
||||
Reference in new issue
Block a user