feat: improvement to template

This commit is contained in:
xhayper
2022-12-22 00:58:54 +07:00
parent 67bbe33498
commit bafa8ae8ae
23 changed files with 189 additions and 120 deletions

View File

@@ -1,3 +1,7 @@
import { app, BrowserWindow, shell, ipcMain } from 'electron'
import { release } from 'node:os'
import { join } from 'node:path'
// The built directory structure
//
// ├─┬ dist-electron
@@ -14,10 +18,6 @@ process.env.PUBLIC = process.env.VITE_DEV_SERVER_URL
? join(process.env.DIST_ELECTRON, '../public')
: process.env.DIST
import { app, BrowserWindow, shell, ipcMain } from 'electron'
import { release } from 'os'
import { join } from 'path'
// Disable GPU Acceleration for Windows 7
if (release().startsWith('6.1')) app.disableHardwareAcceleration()
@@ -99,7 +99,7 @@ app.on('activate', () => {
})
// New window example arg: new windows url
ipcMain.handle('open-win', (event, arg) => {
ipcMain.handle('open-win', (_, arg) => {
const childWindow = new BrowserWindow({
webPreferences: {
preload,

View File

@@ -1,5 +1,5 @@
function domReady(condition: DocumentReadyState[] = ['complete', 'interactive']) {
return new Promise(resolve => {
return new Promise((resolve) => {
if (condition.includes(document.readyState)) {
resolve(true)
} else {
@@ -85,7 +85,7 @@ function useLoading() {
const { appendLoading, removeLoading } = useLoading()
domReady().then(appendLoading)
window.onmessage = ev => {
window.onmessage = (ev) => {
ev.data.payload === 'removeLoading' && removeLoading()
}