v2.1.0: use vite-electron-plugin instead vite-plugin-electron

This commit is contained in:
草鞋没号
2022-10-03 09:16:14 +08:00
parent a15028ad68
commit db2e830dfd
9 changed files with 57 additions and 69 deletions

View File

@@ -1,22 +1,9 @@
/// <reference types="vite-plugin-electron/electron-env" />
/// <reference types="vite-electron-plugin/electron-env" />
declare namespace NodeJS {
interface ProcessEnv {
/**
* The built directory structure
*
* ```tree
* ├─┬ dist
* │ ├─┬ electron
* │ │ ├─┬ main
* │ │ │ └── index.js
* │ │ └─┬ preload
* │ │ └── index.js
* │ ├── index.html
* │ ├── ...other-static-files-from-public
* │
* ```
*/
VSCODE_DEBUG?: 'true'
DIST_ELECTRON: string
DIST: string
/** /dist/ or /public/ */
PUBLIC: string

View File

@@ -1,16 +1,16 @@
// The built directory structure
//
// ├─┬ dist-electron
// │ ├─┬ main
// │ │ └── index.js > Electron-Main
// │ └─┬ preload
// │ └── index.js > Preload-Scripts
// ├─┬ dist
// │ ├─┬ electron
// │ │ ├─┬ main
// │ │ │ └── index.js
// │ │ └─┬ preload
// │ │ └── index.js
// │ ├── index.html
// │ ├── ...other-static-files-from-public
// │
process.env.DIST = join(__dirname, '../..')
process.env.PUBLIC = app.isPackaged ? process.env.DIST : join(process.env.DIST, '../public')
// │ └── index.html > Electron-Renderer
//
process.env.DIST_ELECTRON = join(__dirname, '..')
process.env.DIST = join(process.env.DIST_ELECTRON, '../dist')
process.env.PUBLIC = app.isPackaged ? process.env.DIST : join(process.env.DIST_ELECTRON, '../public')
import { app, BrowserWindow, shell, ipcMain } from 'electron'
import { release } from 'os'
@@ -35,7 +35,7 @@ if (!app.requestSingleInstanceLock()) {
let win: BrowserWindow | null = null
// Here, you can also use other preload
const preload = join(__dirname, '../preload/index.js')
const url = process.env.VITE_DEV_SERVER_URL as string
const url = process.env.VITE_DEV_SERVER_URL
const indexHtml = join(process.env.DIST, 'index.html')
async function createWindow() {