1.安装vite
pnpm create vite
2.安装electron
用npm下载不过来QAQ
下载失败的话就重新下一遍
cnpm i -D electron
3.安装concurrently
用来执行多个程序
pnpm i concurrently
4.配置package.json
{"name": "demo","private": true,"version": "0.0.0","type": "module","main": "electron/main.cjs","scripts": {"dev": "concurrently \"vite\" \"electron .\"","build": "vue-tsc && vite build","preview": "vite preview"},"dependencies": {"concurrently": "^8.2.2","vue": "^3.4.21"},"devDependencies": {"@vitejs/plugin-vue": "^5.0.4","electron": "^30.0.6","typescript": "^5.2.2","vite": "^5.2.0","vue-tsc": "^2.0.6"}
}
5.运行
pnpm run dev
6.配置请求安全
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'"/>