Merge pull request #93 from xhayper/patch-1
feat: improvement to template
This commit is contained in:
		
						commit
						9f414cef12
					
				| 
						 | 
				
			
			@ -12,7 +12,7 @@ import { join } from 'node:path'
 | 
			
		|||
// ├─┬ dist
 | 
			
		||||
// │ └── index.html    > Electron-Renderer
 | 
			
		||||
//
 | 
			
		||||
process.env.DIST_ELECTRON = join(__dirname, '..')
 | 
			
		||||
process.env.DIST_ELECTRON = join(__dirname, '../')
 | 
			
		||||
process.env.DIST = join(process.env.DIST_ELECTRON, '../dist')
 | 
			
		||||
process.env.PUBLIC = process.env.VITE_DEV_SERVER_URL
 | 
			
		||||
  ? join(process.env.DIST_ELECTRON, '../public')
 | 
			
		||||
| 
						 | 
				
			
			@ -38,7 +38,7 @@ 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
 | 
			
		||||
const indexHtml = join('dist/', 'index.html')
 | 
			
		||||
const indexHtml = join(process.env.DIST, 'index.html')
 | 
			
		||||
 | 
			
		||||
async function createWindow() {
 | 
			
		||||
  win = new BrowserWindow({
 | 
			
		||||
| 
						 | 
				
			
			@ -54,11 +54,10 @@ async function createWindow() {
 | 
			
		|||
    },
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
      // Open devTool if the app is not packaged
 | 
			
		||||
      win.webContents.openDevTools()
 | 
			
		||||
 | 
			
		||||
  if (process.env.VITE_DEV_SERVER_URL) { // electron-vite-vue#298
 | 
			
		||||
    win.loadURL(url)
 | 
			
		||||
    // Open devTool if the app is not packaged
 | 
			
		||||
    win.webContents.openDevTools()
 | 
			
		||||
  } else {
 | 
			
		||||
    win.loadFile(indexHtml)
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
{
 | 
			
		||||
  "name": "electron-vite-react",
 | 
			
		||||
  "version": "2.1.0",
 | 
			
		||||
  "main": "dist-electron/electron/main/index.js",
 | 
			
		||||
  "main": "dist-electron/main/index.js",
 | 
			
		||||
  "description": "Electron Vite React boilerplate.",
 | 
			
		||||
  "author": "草鞋没号 <308487730@qq.com>",
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
| 
						 | 
				
			
			@ -18,7 +18,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@types/react": "^18.0.26",
 | 
			
		||||
    "@types/react-dom": "^18.0.9",
 | 
			
		||||
    "@types/react-dom": "^18.0.10",
 | 
			
		||||
    "@vitejs/plugin-react": "^3.0.0",
 | 
			
		||||
    "electron": "^22.0.0",
 | 
			
		||||
    "electron-builder": "^23.6.0",
 | 
			
		||||
| 
						 | 
				
			
			@ -27,7 +27,7 @@
 | 
			
		|||
    "sass": "^1.57.1",
 | 
			
		||||
    "typescript": "^4.9.4",
 | 
			
		||||
    "vite": "^4.0.3",
 | 
			
		||||
    "vite-electron-plugin": "^0.6.0",
 | 
			
		||||
    "vite-electron-plugin": "^0.6.3",
 | 
			
		||||
    "vite-plugin-electron-renderer": "^0.11.3"
 | 
			
		||||
  },
 | 
			
		||||
  "engines": {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,8 +23,7 @@ export default defineConfig({
 | 
			
		|||
    react(),
 | 
			
		||||
    electron({
 | 
			
		||||
      include: [
 | 
			
		||||
        'electron',
 | 
			
		||||
        'preload',
 | 
			
		||||
        'electron'
 | 
			
		||||
      ],
 | 
			
		||||
      transformOptions: {
 | 
			
		||||
        sourcemap: isDevelopment
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue