Skip to content

Commit 9a4bec1

Browse files
committed
update
update
1 parent 61c1bf3 commit 9a4bec1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1434
-91
lines changed

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
dist-electron
14+
release
15+
*.local
16+
17+
# Editor directories and files
18+
.vscode/debug.script.mjs
19+
.idea
20+
.DS_Store
21+
*.suo
22+
*.ntvs*
23+
*.njsproj
24+
*.sln
25+
*.sw?
26+
27+
#lockfile
28+
package-lock.json
29+
pnpm-lock.yaml
30+
yarn.lock
31+
/test-results/
32+
/playwright-report/
33+
/playwright/.cache/

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shamefully-hoist=true

.vscode/extensions.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"mrmlnc.vscode-json5"
6+
]
7+
}

.vscode/launch.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"compounds": [
7+
{
8+
"name": "Debug App",
9+
"preLaunchTask": "Before Debug",
10+
"configurations": [
11+
"Debug Main Process",
12+
"Debug Renderer Process"
13+
],
14+
"presentation": {
15+
"hidden": false,
16+
"group": "",
17+
"order": 1
18+
},
19+
"stopAll": true
20+
}
21+
],
22+
"configurations": [
23+
{
24+
"name": "Debug Main Process",
25+
"type": "node",
26+
"request": "launch",
27+
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
28+
"windows": {
29+
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
30+
},
31+
"runtimeArgs": [
32+
"--no-sandbox",
33+
"--remote-debugging-port=9229",
34+
"."
35+
],
36+
"envFile": "${workspaceFolder}/.vscode/.debug.env",
37+
"console": "integratedTerminal"
38+
},
39+
{
40+
"name": "Debug Renderer Process",
41+
"port": 9229,
42+
"request": "attach",
43+
"type": "chrome",
44+
"timeout": 60000,
45+
"skipFiles": [
46+
"<node_internals>/**",
47+
"${workspaceRoot}/node_modules/**",
48+
"${workspaceRoot}/dist-electron/**",
49+
// Skip files in host(VITE_DEV_SERVER_URL)
50+
"http://127.0.0.1:7777/**"
51+
]
52+
},
53+
]
54+
}

.vscode/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib",
3+
"typescript.tsc.autoDetect": "off",
4+
"json.schemas": [
5+
{
6+
"fileMatch": [
7+
"/*electron-builder.json5",
8+
"/*electron-builder.json"
9+
],
10+
"url": "https://json.schemastore.org/electron-builder"
11+
}
12+
]
13+
}

.vscode/tasks.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "Before Debug",
8+
"type": "shell",
9+
"command": "node .vscode/.debug.script.mjs",
10+
"isBackground": true,
11+
"problemMatcher": {
12+
"owner": "typescript",
13+
"fileLocation": "relative",
14+
"pattern": {
15+
// TODO: correct "regexp"
16+
"regexp": "^([a-zA-Z]\\:\/?([\\w\\-]\/?)+\\.\\w+):(\\d+):(\\d+): (ERROR|WARNING)\\: (.*)$",
17+
"file": 1,
18+
"line": 3,
19+
"column": 4,
20+
"code": 5,
21+
"message": 6
22+
},
23+
"background": {
24+
"activeOnStart": true,
25+
"beginsPattern": "^.*VITE v.* ready in \\d* ms.*$",
26+
"endsPattern": "^.*\\[startup\\] Electron App.*$"
27+
}
28+
}
29+
}
30+
]
31+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 草鞋没号
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +0,0 @@
1-
# electron-vite-react
2-
3-
[![awesome-vite](https://awesome.re/mentioned-badge.svg)](https://github.com/vitejs/awesome-vite)
4-
![GitHub stars](https://img.shields.io/github/stars/caoxiemeihao/vite-react-electron?color=fa6470)
5-
![GitHub issues](https://img.shields.io/github/issues/caoxiemeihao/vite-react-electron?color=d8b22d)
6-
![GitHub license](https://img.shields.io/github/license/caoxiemeihao/vite-react-electron)
7-
[![Required Node.JS >= 14.18.0 || >=16.0.0](https://img.shields.io/static/v1?label=node&message=14.18.0%20||%20%3E=16.0.0&logo=node.js&color=3f893e)](https://nodejs.org/about/releases)
8-
9-
English | [简体中文](README.zh-CN.md)
10-
11-
## 👀 Overview
12-
13-
📦 Ready out of the box
14-
🎯 Based on the official [template-react-ts](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts), project structure will be familiar to you
15-
🌱 Easily extendable and customizable
16-
💪 Supports Node.js API in the renderer process
17-
🔩 Supports C/C++ native addons
18-
🐞 Debugger configuration included
19-
🖥 Easy to implement multiple windows
20-
21-
## 🛫 Quick Setup
22-
23-
```sh
24-
# clone the project
25-
git clone https://github.com/electron-vite/electron-vite-react.git
26-
27-
# enter the project directory
28-
cd electron-vite-react
29-
30-
# install dependency
31-
npm install
32-
33-
# develop
34-
npm run dev
35-
```
36-
37-
## 🐞 Debug
38-
39-
![electron-vite-react-debug.gif](/electron-vite-react-debug.gif)
40-
41-
## 📂 Directory structure
42-
43-
Familiar React application structure, just with `electron` folder on the top :wink:
44-
*Files in this folder will be separated from your React application and built into `dist-electron`*
45-
46-
```tree
47-
├── electron Electron-related code
48-
│ ├── main Main-process source code
49-
│ └── preload Preload-scripts source code
50-
51-
├── release Generated after production build, contains executables
52-
│ └── {version}
53-
│ ├── {os}-{os_arch} Contains unpacked application executable
54-
│ └── {app_name}_{version}.{ext} Installer for the application
55-
56-
├── public Static assets
57-
└── src Renderer source code, your React application
58-
```
59-
60-
<!--
61-
## 🚨 Be aware
62-
63-
This template integrates Node.js API to the renderer process by default. If you want to follow **Electron Security Concerns** you might want to disable this feature. You will have to expose needed API by yourself.
64-
65-
To get started, remove the option as shown below. This will [modify the Vite configuration and disable this feature](https://github.com/electron-vite/vite-plugin-electron-renderer#config-presets-opinionated).
66-
67-
```diff
68-
# vite.config.ts
69-
70-
export default {
71-
plugins: [
72-
...
73-
- // Use Node.js API in the Renderer-process
74-
- renderer({
75-
- nodeIntegration: true,
76-
- }),
77-
...
78-
],
79-
}
80-
```
81-
-->
82-
83-
## 🔧 Additional features
84-
85-
1. electron-updater 👉 [see docs](src/components/update/README.md)
86-
1. playwright
87-
88-
## ❔ FAQ
89-
90-
- [C/C++ addons, Node.js modules - Pre-Bundling](https://github.com/electron-vite/vite-plugin-electron-renderer#dependency-pre-bundling)
91-
- [dependencies vs devDependencies](https://github.com/electron-vite/vite-plugin-electron-renderer#dependencies-vs-devdependencies)

build/icon.icns

455 KB
Binary file not shown.

build/icon.ico

53.9 KB
Binary file not shown.

build/icon.png

67 KB
Loading

e2e/example.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { test, expect, _electron as electron } from "@playwright/test";
2+
3+
test("homepage has title and links to intro page", async () => {
4+
const app = await electron.launch({ args: [".", "--no-sandbox"] });
5+
const page = await app.firstWindow();
6+
expect(await page.title()).toBe("Electron + Vite + React");
7+
await page.screenshot({ path: "e2e/screenshots/example.png" });
8+
});

e2e/screenshots/example.png

102 KB
Loading

electron-builder.json5

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* @see https://www.electron.build/configuration/configuration
3+
*/
4+
{
5+
"appId": "YourAppID",
6+
"asar": true,
7+
"directories": {
8+
"output": "release/${version}"
9+
},
10+
"files": [
11+
"dist-electron",
12+
"dist"
13+
],
14+
"mac": {
15+
"artifactName": "${productName}_${version}.${ext}",
16+
"target": [
17+
"dmg",
18+
"zip"
19+
]
20+
},
21+
"win": {
22+
"target": [
23+
{
24+
"target": "nsis",
25+
"arch": [
26+
"x64"
27+
]
28+
}
29+
],
30+
"artifactName": "${productName}_${version}.${ext}"
31+
},
32+
"nsis": {
33+
"oneClick": false,
34+
"perMachine": false,
35+
"allowToChangeInstallationDirectory": true,
36+
"deleteAppDataOnUninstall": false
37+
},
38+
"publish": {
39+
"provider": "generic",
40+
"channel": "latest",
41+
"url": "https://github.com/electron-vite/electron-vite-react/releases/download/v0.9.9/"
42+
}
43+
}

electron-vite-react-debug.gif

9.64 MB
Loading

electron-vite-react.gif

3.41 MB
Loading

electron/electron-env.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference types="vite-electron-plugin/electron-env" />
2+
3+
declare namespace NodeJS {
4+
interface ProcessEnv {
5+
VSCODE_DEBUG?: 'true'
6+
DIST_ELECTRON: string
7+
DIST: string
8+
/** /dist/ or /public/ */
9+
VITE_PUBLIC: string
10+
}
11+
}

0 commit comments

Comments
 (0)