-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 92cdc53
Showing
29 changed files
with
3,211 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
.DS_Store | ||
dist | ||
dist-ssr | ||
coverage | ||
*.local | ||
|
||
/cypress/videos/ | ||
/cypress/screenshots/ | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
*.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["Vue.volar"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# electron-app | ||
|
||
This template should help get you started developing with Vue 3 in Vite. | ||
|
||
## Recommended IDE Setup | ||
|
||
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur). | ||
|
||
## Type Support for `.vue` Imports in TS | ||
|
||
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types. | ||
|
||
## Customize configuration | ||
|
||
See [Vite Configuration Reference](https://vitejs.dev/config/). | ||
|
||
## Project Setup | ||
|
||
```sh | ||
npm install | ||
``` | ||
|
||
### Compile and Hot-Reload for Development | ||
|
||
```sh | ||
npm run dev | ||
``` | ||
|
||
### Type-Check, Compile and Minify for Production | ||
|
||
```sh | ||
npm run build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference types="vite/client" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<link rel="icon" href="/favicon.ico"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Vite App</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "electron-app", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "run-p type-check \"build-only {@}\" --", | ||
"preview": "vite preview", | ||
"build-only": "vite build", | ||
"type-check": "vue-tsc --build --force" | ||
}, | ||
"dependencies": { | ||
"vue": "^3.4.21" | ||
}, | ||
"devDependencies": { | ||
"@tsconfig/node20": "^20.1.2", | ||
"@types/node": "^20.11.25", | ||
"@vitejs/plugin-vue": "^5.0.4", | ||
"@vue/tsconfig": "^0.5.1", | ||
"electron": "^29.1.4", | ||
"electron-build": "^0.0.3", | ||
"npm-run-all2": "^6.1.2", | ||
"typescript": "~5.4.0", | ||
"vite": "^5.1.5", | ||
"vue-tsc": "^2.0.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// 生产环境插件 | ||
import type { Plugin } from 'vite'; | ||
|
||
// vite 插件要求导出一个对象 有一个name属性 | ||
|
||
export const ElectronPlugins = (): Plugin => { | ||
return { | ||
name: 'electron-dev', | ||
// 配置vite钩子 | ||
configureServer(server) { | ||
server?.httpServer?.on('listening', () => { | ||
const addressInfo = server.httpServer?.address() | ||
console.log(addressInfo) | ||
}) | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// 开发环境插件 | ||
import type { Plugin } from 'vite'; | ||
import type { AddressInfo } from 'net'; | ||
import { spawn } from 'child_process'; | ||
import fs from 'node:fs'; | ||
|
||
// vite 插件要求导出一个对象 有一个name属性 | ||
const buildBackground = () => { | ||
require('esbuild').buildSync({ | ||
entryPoints: ['src/background.ts'], | ||
bundle: true, | ||
outfile: 'dist/background.js', | ||
platform: 'node', | ||
target: 'node16', | ||
external: ['electron'] | ||
}); | ||
}; | ||
export const ElectronPlugins = (): Plugin => { | ||
return { | ||
name: 'electron-dev', | ||
// 配置vite钩子 | ||
configureServer(server) { | ||
buildBackground(); | ||
server?.httpServer?.on('listening', () => { | ||
//读取vite服务信息 | ||
const addressInfo = server.httpServer?.address() as AddressInfo; | ||
//拼接ip electron启动服务使用 | ||
const IP = `http://localhost:${addressInfo.port}`; | ||
//第一个参数是electron入口文件 | ||
//require('electron')返回一个路径 | ||
//electron 需要把ts编译成js | ||
//进程传参法发送给electron | ||
//electron 0 'dist/background.js' 1 IP 2 参数顺序 | ||
let ElectronProcess = spawn(require('electron'), [ | ||
'dist/background.js', | ||
IP | ||
]); | ||
fs.watchFile('src/background.ts', () => { | ||
ElectronProcess.kill(); | ||
buildBackground(); | ||
ElectronProcess = spawn(require('electron'), [ | ||
'dist/background.js', | ||
IP | ||
]); | ||
}); | ||
ElectronProcess.stderr.on('data', data => { | ||
console.log('日志', data.toString()); | ||
}); | ||
console.log(IP); | ||
}); | ||
} | ||
}; | ||
}; |
Oops, something went wrong.