@tomjs/create-app 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
- package/template-electron-react/README.md +19 -11
- package/template-electron-react/electron/env.d.ts +1 -0
- package/template-electron-react/electron/main/index.ts +36 -27
- package/template-electron-react/electron/preload/index.ts +1 -0
- package/template-electron-react/package.json +7 -11
- package/template-electron-react/scripts/builder.ts +1 -1
- package/template-electron-react/scripts/release.ts +1 -1
- package/template-electron-react/src/App.tsx +4 -2
- package/template-electron-react/vite.config.ts +9 -81
- package/template-electron-vue/README.md +19 -11
- package/template-electron-vue/electron/env.d.ts +1 -0
- package/template-electron-vue/electron/main/index.ts +36 -27
- package/template-electron-vue/electron/preload/index.ts +1 -0
- package/template-electron-vue/package.json +9 -13
- package/template-electron-vue/scripts/builder.ts +1 -1
- package/template-electron-vue/scripts/release.ts +1 -1
- package/template-electron-vue/src/App.vue +16 -4
- package/template-electron-vue/src/components/HelloWorld.vue +6 -0
- package/template-electron-vue/src/style.css +3 -3
- package/template-electron-vue/vite.config.ts +9 -80
- package/template-node/package.json +3 -3
- package/template-node/src/index.ts +1 -1
- package/template-react/package.json +3 -3
- package/template-vue/package.json +5 -5
- package/template-electron-react/.vscode/.debug.env +0 -1
- package/template-electron-react/.vscode/.debug.script.mjs +0 -23
- package/template-electron-react/.vscode/extensions.json +0 -6
- package/template-electron-react/.vscode/launch.json +0 -53
- package/template-electron-react/.vscode/settings.json +0 -13
- package/template-electron-react/.vscode/tasks.json +0 -31
- package/template-electron-react/electron/electron-env.d.ts +0 -11
- package/template-electron-vue/.vscode/.debug.env +0 -1
- package/template-electron-vue/.vscode/.debug.script.mjs +0 -23
- package/template-electron-vue/.vscode/extensions.json +0 -6
- package/template-electron-vue/.vscode/launch.json +0 -53
- package/template-electron-vue/.vscode/settings.json +0 -13
- package/template-electron-vue/.vscode/tasks.json +0 -31
- package/template-electron-vue/electron/electron-env.d.ts +0 -11
package/dist/index.mjs
CHANGED
|
@@ -4,5 +4,5 @@ import a,{renameSync as Ce}from"fs";import Oe from"os";import i from"path";impor
|
|
|
4
4
|
Scaffolding project in ${s}...`);let T=g||P?.name||n||"",G=t=>i.join(Fe(import.meta.url),"../..",`template-${t}`),we=G(T),U=T.includes("node");[we,G("config")].forEach(t=>{let o=a.readdirSync(t);for(let r of o){let l=r.startsWith("_")?r.replace("_","."):r;if(U&&!f.includes("examples")&&r.includes("stylelint"))continue;let m=i.join(s,l);z(i.join(t,r),m)}});let d=D||h(),Se=`template-${T}`,j={name:"UserName",email:"name@github.com"};function ee(){let t=d.startsWith("@")?d.split("/")[0].substring(1):Ge(j.name);return`${xe||`https://github.com/${t}`}/${d.substring(d.indexOf("/")+1)}.git`}ke(),U&&(je(),Ee(),be());let te=se(process.env.npm_config_user_agent),_=te?te.name:"npm";b.which("git")&&(b.exec(`cd ${s} && git init`),f.includes("publish")&&b.exec(`cd ${s} && git remote add origin ${ee()}`));let I=i.relative(Q,s);switch(console.log(`
|
|
5
5
|
Done. Now run:
|
|
6
6
|
`),s!==Q&&console.log(` cd ${I.includes(" ")?`"${I}"`:I}`),_){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${_} install`),console.log(` ${_} run dev`);break}function je(){["LICENSE","README.md","README.zh_CN.md"].forEach(t=>{let o=i.join(s,t);if(!f.includes("publish")&&a.existsSync(o)){a.rmSync(o),t==="README.md"&&a.writeFileSync(o,`# ${d}
|
|
7
|
-
`,{encoding:"utf-8"});return}if(!a.existsSync(o))return;let r=a.readFileSync(o,"utf-8").replace(new RegExp(Se,"g"),d).replace(new RegExp("{{user.name}}","g"),j.name).replace(new RegExp("{{user.email}}","g"),j.email);if(t.startsWith("README")){let l=d.replace("@","%40"),m=d.replace("@","%40").replace(new RegExp("/","g"),"%2F");r=r.replace("{{badges}}",[``,``,``].join(" "))}a.writeFileSync(o,r)})}function k(t,...o){["dependencies","devDependencies"].forEach(r=>{Object.keys(t[r]||{}).forEach(l=>{o.find(m=>l.includes(m))&&delete t[r][l]})})}function ke(){let t=v(i.join(s,"package.json"));t.name=d,f.includes("publish")?(b.which("git")&&(j.name=ye("user.name")||Oe.userInfo().username,j.email=ye("user.email")||"",t.author=Object.assign(t.author,j)),t.repository.url=`git+${ee()}`):(delete t.author,delete t.publishConfig,delete t.repository,delete t.scripts.prepublishOnly,delete t.devDependencies.np),f.includes("electron")||(k(t,"electron"),t.scripts["lint:eslint"]=t.scripts["lint:eslint"].replace(",electron","")),
|
|
7
|
+
`,{encoding:"utf-8"});return}if(!a.existsSync(o))return;let r=a.readFileSync(o,"utf-8").replace(new RegExp(Se,"g"),d).replace(new RegExp("{{user.name}}","g"),j.name).replace(new RegExp("{{user.email}}","g"),j.email);if(t.startsWith("README")){let l=d.replace("@","%40"),m=d.replace("@","%40").replace(new RegExp("/","g"),"%2F");r=r.replace("{{badges}}",[``,``,``].join(" "))}a.writeFileSync(o,r)})}function k(t,...o){["dependencies","devDependencies"].forEach(r=>{Object.keys(t[r]||{}).forEach(l=>{o.find(m=>l.includes(m))&&delete t[r][l]})})}function ke(){let t=v(i.join(s,"package.json"));t.name=d,f.includes("publish")?(b.which("git")&&(j.name=ye("user.name")||Oe.userInfo().username,j.email=ye("user.email")||"",t.author=Object.assign(t.author,j)),t.repository.url=`git+${ee()}`):(delete t.author,delete t.publishConfig,delete t.repository,delete t.scripts.prepublishOnly,delete t.devDependencies.np),U&&(f.includes("electron")||(k(t,"electron"),t.scripts["lint:eslint"]=t.scripts["lint:eslint"].replace(",electron","")),f.includes("vite")&&k(t,"vite")),x(i.join(s,"package.json"),t)}function W(t,o){let r=t.lastIndexOf("."),l=t.substring(0,r)+"."+o+t.substring(r),m=i.join(s,t),y=i.join(s,l);f.includes(o)?($(m),a.existsSync(y)&&Ce(y,m)):$(y)}function Ee(){if(W("tsconfig.json","test"),W("jest.config.cjs","electron"),f.includes("test"))return;a.readdirSync(s).filter(r=>r.startsWith("jest.config")||["test"].includes(r)).forEach(r=>{$(i.join(s,r))});let t=i.join(s,"package.json"),o=v(t);delete o.scripts.test,o.scripts["lint:eslint"]=o.scripts["lint:eslint"].replace(",test",""),k(o,"jest"),x(t,o)}function be(){if(W(".lintstagedrc.cjs","examples"),!f.includes("examples")){let r=v(i.join(s,"package.json"));r.scripts.lint=r.scripts.lint.replace(" lint:stylelint",""),r.scripts["lint:eslint"]=r.scripts["lint:eslint"].replace(",examples",""),delete r.scripts["lint:stylelint"],k(r,"stylelint"),x(i.join(s,"package.json"),r);return}let t=i.join(s,"examples");a.mkdirSync(t);let o=f.includes("electron");["vue","react"].forEach(r=>{let l=G(o?`electron-${r}`:r),m=i.join(t,r);if(!a.existsSync(l)){console.log(`${Z(l)} template is not exist`);return}a.cpSync(l,m,{recursive:!0});let y=v(i.join(m,"package.json"));Object.keys(y.scripts).forEach(E=>{(E.startsWith("lint")||["prepare"].includes(E))&&delete y.scripts[E]}),k(y,"eslint","prettier","stylelint","commitlint","husky","lint-staged","tsconfig","lint-staged","npm-run-all"),x(i.join(m,"package.json"),y),["_lintstagedrc.cjs"].forEach(E=>{let ne=i.join(m,E);a.existsSync(ne)&&a.rmSync(ne,{recursive:!0})})}),a.writeFileSync(i.join(s,"pnpm-workspace.yaml"),`packages:
|
|
8
8
|
- 'examples/*'`,{encoding:"utf-8"})}}q().then(async()=>Ie().catch(e=>{e.message&&console.error(e)})).catch(e=>{e.message&&console.error(e)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomjs/create-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "create tomjs web app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tomjs",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"@tomjs/commitlint": "^2.0.5",
|
|
55
55
|
"@tomjs/eslint": "^1.1.1",
|
|
56
56
|
"@tomjs/prettier": "^1.0.6",
|
|
57
|
-
"@tomjs/stylelint": "^1.1.
|
|
58
|
-
"@tomjs/tsconfig": "^1.0.
|
|
57
|
+
"@tomjs/stylelint": "^1.1.1",
|
|
58
|
+
"@tomjs/tsconfig": "^1.0.9",
|
|
59
59
|
"@types/lodash-es": "^4.17.12",
|
|
60
60
|
"@types/minimist": "^1.2.5",
|
|
61
61
|
"@types/node": "^18.19.3",
|
|
@@ -4,23 +4,31 @@ vite + electron + react
|
|
|
4
4
|
|
|
5
5
|
## Description
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- Recommended `electron` front-end code directory structure
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
|--electron
|
|
11
|
+
| |--main
|
|
12
|
+
| | |--index.ts
|
|
13
|
+
| |--preload
|
|
14
|
+
| | |--index.ts
|
|
15
|
+
|--src
|
|
16
|
+
| |--App.tsx
|
|
17
|
+
| |--main.tsx
|
|
14
18
|
```
|
|
15
19
|
|
|
16
|
-
- output
|
|
20
|
+
- Use the default dist output directory of the plugin
|
|
17
21
|
|
|
18
22
|
```
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
|--dist
|
|
24
|
+
| |--main
|
|
25
|
+
| | |--index.js
|
|
26
|
+
| | |--index.js.map
|
|
27
|
+
| |--preload
|
|
28
|
+
| | |--index.js
|
|
29
|
+
| | |--index.js.map
|
|
30
|
+
| |--renderer
|
|
31
|
+
| | |--index.html
|
|
24
32
|
```
|
|
25
33
|
|
|
26
34
|
## Reference project
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="@tomjs/vite-plugin-electron/env" />
|
|
@@ -3,20 +3,8 @@ import { dirname, join } from 'node:path';
|
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { app, BrowserWindow, ipcMain, shell } from 'electron';
|
|
5
5
|
|
|
6
|
-
// The built directory structure
|
|
7
|
-
//
|
|
8
|
-
// ├─┬ dist
|
|
9
|
-
// │ ├── main.js > Electron-Main
|
|
10
|
-
// │ ├── preload.js > Preload-Scripts
|
|
11
|
-
// │ ├─┬ render > Electron-Renderer
|
|
12
|
-
// │ │ └── index.html
|
|
13
|
-
//
|
|
14
6
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
15
|
-
process.env.
|
|
16
|
-
process.env.DIST = join(process.env.DIST_ELECTRON, 'render');
|
|
17
|
-
process.env.VITE_PUBLIC = process.env.VITE_DEV_SERVER_URL
|
|
18
|
-
? join(process.env.DIST_ELECTRON, '../public')
|
|
19
|
-
: process.env.DIST;
|
|
7
|
+
const isDev = process.env.NODE_ENV === 'development';
|
|
20
8
|
|
|
21
9
|
// Disable GPU Acceleration for Windows 7
|
|
22
10
|
if (release().startsWith('6.1')) app.disableHardwareAcceleration();
|
|
@@ -32,19 +20,22 @@ if (!app.requestSingleInstanceLock()) {
|
|
|
32
20
|
// Remove electron security warnings
|
|
33
21
|
// This warning only shows in development mode
|
|
34
22
|
// Read more on https://www.electronjs.org/docs/latest/tutorial/security
|
|
35
|
-
|
|
23
|
+
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
|
|
36
24
|
|
|
37
25
|
let win: BrowserWindow | null = null;
|
|
38
|
-
//
|
|
39
|
-
const preload = join(__dirname, '
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
26
|
+
// package.json "type":"module", must use mjs extension
|
|
27
|
+
const preload = join(__dirname, '../preload/index.mjs');
|
|
28
|
+
const serverUrl = process.env.APP_DEV_SERVER_URL as string;
|
|
29
|
+
const rendererDist = join(__dirname, '../renderer');
|
|
30
|
+
const indexHtml = join(rendererDist, 'index.html');
|
|
31
|
+
const publicPath = serverUrl ? join(__dirname, '../../public') : rendererDist;
|
|
32
|
+
|
|
33
|
+
function createWindow() {
|
|
44
34
|
win = new BrowserWindow({
|
|
45
35
|
title: 'Main window',
|
|
46
36
|
width: 800,
|
|
47
37
|
height: 700,
|
|
38
|
+
icon: join(publicPath, 'img/icon.png'),
|
|
48
39
|
webPreferences: {
|
|
49
40
|
preload,
|
|
50
41
|
// Warning: Enable nodeIntegration and disable contextIsolation is not secure in production
|
|
@@ -55,11 +46,10 @@ async function createWindow() {
|
|
|
55
46
|
},
|
|
56
47
|
});
|
|
57
48
|
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
win.loadURL(url);
|
|
49
|
+
if (isDev) {
|
|
50
|
+
win.loadURL(serverUrl);
|
|
61
51
|
// Open devTool if the app is not packaged
|
|
62
|
-
|
|
52
|
+
win.webContents.openDevTools();
|
|
63
53
|
} else {
|
|
64
54
|
win.loadFile(indexHtml);
|
|
65
55
|
}
|
|
@@ -77,7 +67,26 @@ async function createWindow() {
|
|
|
77
67
|
// win.webContents.on('will-navigate', (event, url) => { }) #344
|
|
78
68
|
}
|
|
79
69
|
|
|
80
|
-
app.whenReady().then(
|
|
70
|
+
app.whenReady().then(async () => {
|
|
71
|
+
createWindow();
|
|
72
|
+
|
|
73
|
+
if (isDev) {
|
|
74
|
+
const { installExtension, REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS } = await import(
|
|
75
|
+
'@tomjs/electron-devtools-installer'
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
installExtension([REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS])
|
|
79
|
+
.then(exts => {
|
|
80
|
+
console.log(
|
|
81
|
+
'Added Extension: ',
|
|
82
|
+
exts.map(s => s.name),
|
|
83
|
+
);
|
|
84
|
+
})
|
|
85
|
+
.catch(() => {
|
|
86
|
+
console.log('Failed to install extensions');
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
81
90
|
|
|
82
91
|
app.on('window-all-closed', () => {
|
|
83
92
|
win = null;
|
|
@@ -111,8 +120,8 @@ ipcMain.handle('open-win', (_, arg) => {
|
|
|
111
120
|
},
|
|
112
121
|
});
|
|
113
122
|
|
|
114
|
-
if (
|
|
115
|
-
childWindow.loadURL(`${
|
|
123
|
+
if (serverUrl) {
|
|
124
|
+
childWindow.loadURL(`${serverUrl}#${arg}`);
|
|
116
125
|
} else {
|
|
117
126
|
childWindow.loadFile(indexHtml, { hash: arg });
|
|
118
127
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log('Electron Preload Process!');
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electron-app",
|
|
3
3
|
"version": "0.0.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "vite + electron + vue",
|
|
5
6
|
"engines": {
|
|
6
7
|
"node": ">=18"
|
|
7
8
|
},
|
|
8
|
-
"
|
|
9
|
-
"env": {
|
|
10
|
-
"VITE_DEV_SERVER_URL": "http://127.0.0.1:6888/"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"main": "dist/main.js",
|
|
9
|
+
"main": "dist/main/index.mjs",
|
|
14
10
|
"scripts": {
|
|
15
11
|
"dev": "vite",
|
|
16
12
|
"build": "npm run clean && vite build && npm run release",
|
|
@@ -29,10 +25,12 @@
|
|
|
29
25
|
"devDependencies": {
|
|
30
26
|
"@commitlint/cli": "^18.4.3",
|
|
31
27
|
"@tomjs/commitlint": "^2.0.5",
|
|
28
|
+
"@tomjs/electron-devtools-installer": "^2.0.3",
|
|
32
29
|
"@tomjs/eslint": "^1.1.1",
|
|
33
30
|
"@tomjs/prettier": "^1.0.6",
|
|
34
|
-
"@tomjs/stylelint": "^1.1.
|
|
35
|
-
"@tomjs/tsconfig": "^1.0.
|
|
31
|
+
"@tomjs/stylelint": "^1.1.1",
|
|
32
|
+
"@tomjs/tsconfig": "^1.0.9",
|
|
33
|
+
"@tomjs/vite-plugin-electron": "^1.1.2",
|
|
36
34
|
"@types/node": "^18.19.3",
|
|
37
35
|
"@types/react": "^18.2.42",
|
|
38
36
|
"@types/react-dom": "^18.2.17",
|
|
@@ -48,11 +46,9 @@
|
|
|
48
46
|
"rimraf": "^5.0.5",
|
|
49
47
|
"shelljs": "^0.8.5",
|
|
50
48
|
"stylelint": "^15.11.0",
|
|
51
|
-
"tree-kill": "^1.2.2",
|
|
52
49
|
"tsx": "^4.6.2",
|
|
53
50
|
"typescript": "~5.2.2",
|
|
54
|
-
"vite": "^5.0.
|
|
55
|
-
"vite-plugin-electron": "^0.15.4",
|
|
51
|
+
"vite": "^5.0.7",
|
|
56
52
|
"vite-plugin-electron-renderer": "^0.14.5"
|
|
57
53
|
}
|
|
58
54
|
}
|
|
@@ -11,7 +11,7 @@ export default {
|
|
|
11
11
|
output: `build/${pkg.version}`,
|
|
12
12
|
app: 'dist',
|
|
13
13
|
},
|
|
14
|
-
files: ['main.
|
|
14
|
+
files: ['main/index.mjs', 'preload/index.mjs', 'renderer'],
|
|
15
15
|
icon: 'public/img/icon.png',
|
|
16
16
|
artifactName: '${productName}-${version}-${os}-${arch}.${ext}',
|
|
17
17
|
electronLanguages: ['zh-CN', 'en-US'],
|
|
@@ -13,7 +13,7 @@ function genPkgJson() {
|
|
|
13
13
|
version: pkg.version,
|
|
14
14
|
author: os.userInfo().username,
|
|
15
15
|
description: pkg.description,
|
|
16
|
-
main: '
|
|
16
|
+
main: 'main/index.mjs',
|
|
17
17
|
dependencies: Object.entries(Object.assign({}, pkg.dependencies, pkg.devDependencies))
|
|
18
18
|
.filter(([name]) => ELECTRON_DEPENDENCIES.includes(name))
|
|
19
19
|
.reduce((object, entry) => ({ ...object, [entry[0]]: entry[1] }), {}),
|
|
@@ -9,7 +9,9 @@ import './App.css';
|
|
|
9
9
|
function App() {
|
|
10
10
|
const [count, setCount] = useState(0);
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const versions = ['chrome', 'node', 'electron']
|
|
13
|
+
.map(s => `${s}: ${process.versions[s]}`)
|
|
14
|
+
.concat(['platform: ' + os.platform() + ' ' + os.arch()]);
|
|
13
15
|
|
|
14
16
|
return (
|
|
15
17
|
<>
|
|
@@ -25,8 +27,8 @@ function App() {
|
|
|
25
27
|
</a>
|
|
26
28
|
</div>
|
|
27
29
|
<h1>Vite + Electron + React</h1>
|
|
28
|
-
<div>{info}</div>
|
|
29
30
|
<div className="card">
|
|
31
|
+
<div style={{ marginBottom: '1em' }}>{versions.join(', ')}</div>
|
|
30
32
|
<button onClick={() => setCount(count => count + 1)}>count is {count}</button>
|
|
31
33
|
<p>
|
|
32
34
|
Edit <code>src/App.tsx</code> and save to test HMR
|
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
import { rmSync } from 'node:fs';
|
|
2
1
|
import path from 'node:path';
|
|
3
2
|
import { defineConfig } from 'vite';
|
|
4
|
-
import electron from 'vite-plugin-electron';
|
|
5
|
-
import { notBundle } from 'vite-plugin-electron/plugin';
|
|
6
3
|
import renderer from 'vite-plugin-electron-renderer';
|
|
4
|
+
import electron from '@tomjs/vite-plugin-electron';
|
|
7
5
|
import react from '@vitejs/plugin-react-swc';
|
|
8
6
|
import pkg from './package.json';
|
|
9
7
|
|
|
10
8
|
// https://vitejs.dev/config/
|
|
11
|
-
export default defineConfig((
|
|
12
|
-
['main.js', 'main.js.map', 'preload.js'].forEach(s => {
|
|
13
|
-
rmSync(`dist/${s}`, { recursive: true, force: true });
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
const isServe = command === 'serve';
|
|
17
|
-
const isBuild = command === 'build';
|
|
18
|
-
const sourcemap = isServe || !!process.env.VSCODE_DEBUG;
|
|
19
|
-
|
|
9
|
+
export default defineConfig(() => {
|
|
20
10
|
process.env.APP_BUILD_TIME = Date.now() + '';
|
|
21
11
|
process.env.APP_VERSION = pkg.version;
|
|
22
12
|
|
|
@@ -28,84 +18,22 @@ export default defineConfig(({ command }) => {
|
|
|
28
18
|
},
|
|
29
19
|
},
|
|
30
20
|
build: {
|
|
31
|
-
outDir: 'dist/render',
|
|
32
21
|
emptyOutDir: true,
|
|
33
22
|
},
|
|
34
23
|
plugins: [
|
|
35
24
|
react(),
|
|
36
|
-
electron(
|
|
37
|
-
{
|
|
38
|
-
|
|
39
|
-
onstart({ startup }) {
|
|
40
|
-
if (process.env.VSCODE_DEBUG) {
|
|
41
|
-
console.log(/* For `.vscode/.debug.script.mjs` */ '[startup] Electron App');
|
|
42
|
-
} else {
|
|
43
|
-
startup();
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
vite: {
|
|
47
|
-
build: {
|
|
48
|
-
sourcemap,
|
|
49
|
-
minify: isBuild,
|
|
50
|
-
outDir: 'dist',
|
|
51
|
-
emptyOutDir: false,
|
|
52
|
-
lib: {
|
|
53
|
-
entry: 'electron/main/index.ts',
|
|
54
|
-
formats: ['cjs'],
|
|
55
|
-
fileName: () => 'main.js',
|
|
56
|
-
},
|
|
57
|
-
rollupOptions: {
|
|
58
|
-
// Some third-party Node.js libraries may not be built correctly by Vite, especially `C/C++` addons,
|
|
59
|
-
// we can use `external` to exclude them to ensure they work correctly.
|
|
60
|
-
// Others need to put them in `dependencies` to ensure they are collected into `app.asar` after the app is built.
|
|
61
|
-
// Of course, this is not absolute, just this way is relatively simple. :)
|
|
62
|
-
external: Object.keys('dependencies' in pkg ? pkg.dependencies : {}),
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
plugins: [
|
|
66
|
-
// This is just an option to improve build performance, it's non-deterministic!
|
|
67
|
-
// e.g. `import log from 'electron-log'` -> `const log = require('electron-log')`
|
|
68
|
-
isServe && notBundle(),
|
|
69
|
-
],
|
|
70
|
-
},
|
|
25
|
+
electron({
|
|
26
|
+
main: {
|
|
27
|
+
entry: 'electron/main/index.ts',
|
|
71
28
|
},
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
// Notify the Renderer process to reload the page when the Preload scripts build is complete,
|
|
75
|
-
// instead of restarting the entire Electron App.
|
|
76
|
-
reload();
|
|
77
|
-
},
|
|
78
|
-
vite: {
|
|
79
|
-
build: {
|
|
80
|
-
sourcemap: sourcemap ? 'inline' : undefined, // #332
|
|
81
|
-
minify: isBuild,
|
|
82
|
-
outDir: 'dist',
|
|
83
|
-
emptyOutDir: false,
|
|
84
|
-
lib: {
|
|
85
|
-
entry: 'electron/preload/index.ts',
|
|
86
|
-
formats: ['cjs'],
|
|
87
|
-
fileName: () => 'preload.js',
|
|
88
|
-
},
|
|
89
|
-
rollupOptions: {
|
|
90
|
-
external: Object.keys('dependencies' in pkg ? pkg.dependencies : {}),
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
plugins: [isServe && notBundle()],
|
|
94
|
-
},
|
|
29
|
+
preload: {
|
|
30
|
+
entry: 'electron/preload/index.ts',
|
|
95
31
|
},
|
|
96
|
-
|
|
32
|
+
}),
|
|
97
33
|
// Use Node.js API in the Renderer process
|
|
98
34
|
renderer(),
|
|
99
35
|
],
|
|
100
|
-
server:
|
|
101
|
-
? (() => {
|
|
102
|
-
const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL);
|
|
103
|
-
return {
|
|
104
|
-
host: url.hostname,
|
|
105
|
-
port: +url.port,
|
|
106
|
-
};
|
|
107
|
-
})()
|
|
108
|
-
: {},
|
|
36
|
+
server: {},
|
|
109
37
|
clearScreen: false,
|
|
110
38
|
};
|
|
111
39
|
});
|
|
@@ -4,23 +4,31 @@ vite + electron + vue
|
|
|
4
4
|
|
|
5
5
|
## Description
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- Recommended `electron` front-end code directory structure
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
|--electron
|
|
11
|
+
| |--main
|
|
12
|
+
| | |--index.ts
|
|
13
|
+
| |--preload
|
|
14
|
+
| | |--index.ts
|
|
15
|
+
|--src
|
|
16
|
+
| |--App.vue
|
|
17
|
+
| |--main.ts
|
|
14
18
|
```
|
|
15
19
|
|
|
16
|
-
- output
|
|
20
|
+
- Use the default dist output directory of the plugin
|
|
17
21
|
|
|
18
22
|
```
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
|--dist
|
|
24
|
+
| |--main
|
|
25
|
+
| | |--index.js
|
|
26
|
+
| | |--index.js.map
|
|
27
|
+
| |--preload
|
|
28
|
+
| | |--index.js
|
|
29
|
+
| | |--index.js.map
|
|
30
|
+
| |--renderer
|
|
31
|
+
| | |--index.html
|
|
24
32
|
```
|
|
25
33
|
|
|
26
34
|
## Reference project
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="@tomjs/vite-plugin-electron/env" />
|
|
@@ -3,20 +3,8 @@ import { dirname, join } from 'node:path';
|
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { app, BrowserWindow, ipcMain, shell } from 'electron';
|
|
5
5
|
|
|
6
|
-
// The built directory structure
|
|
7
|
-
//
|
|
8
|
-
// ├─┬ dist
|
|
9
|
-
// │ ├── main.js > Electron-Main
|
|
10
|
-
// │ ├── preload.js > Preload-Scripts
|
|
11
|
-
// │ ├─┬ render > Electron-Renderer
|
|
12
|
-
// │ │ └── index.html
|
|
13
|
-
//
|
|
14
6
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
15
|
-
process.env.
|
|
16
|
-
process.env.DIST = join(process.env.DIST_ELECTRON, 'render');
|
|
17
|
-
process.env.VITE_PUBLIC = process.env.VITE_DEV_SERVER_URL
|
|
18
|
-
? join(process.env.DIST_ELECTRON, '../public')
|
|
19
|
-
: process.env.DIST;
|
|
7
|
+
const isDev = process.env.NODE_ENV === 'development';
|
|
20
8
|
|
|
21
9
|
// Disable GPU Acceleration for Windows 7
|
|
22
10
|
if (release().startsWith('6.1')) app.disableHardwareAcceleration();
|
|
@@ -32,19 +20,22 @@ if (!app.requestSingleInstanceLock()) {
|
|
|
32
20
|
// Remove electron security warnings
|
|
33
21
|
// This warning only shows in development mode
|
|
34
22
|
// Read more on https://www.electronjs.org/docs/latest/tutorial/security
|
|
35
|
-
|
|
23
|
+
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
|
|
36
24
|
|
|
37
25
|
let win: BrowserWindow | null = null;
|
|
38
|
-
//
|
|
39
|
-
const preload = join(__dirname, '
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
26
|
+
// package.json "type":"module", must use mjs extension
|
|
27
|
+
const preload = join(__dirname, '../preload/index.mjs');
|
|
28
|
+
const serverUrl = process.env.APP_DEV_SERVER_URL as string;
|
|
29
|
+
const rendererDist = join(__dirname, '../renderer');
|
|
30
|
+
const indexHtml = join(rendererDist, 'index.html');
|
|
31
|
+
const publicPath = serverUrl ? join(__dirname, '../../public') : rendererDist;
|
|
32
|
+
|
|
33
|
+
function createWindow() {
|
|
44
34
|
win = new BrowserWindow({
|
|
45
35
|
title: 'Main window',
|
|
46
36
|
width: 800,
|
|
47
37
|
height: 700,
|
|
38
|
+
icon: join(publicPath, 'img/icon.png'),
|
|
48
39
|
webPreferences: {
|
|
49
40
|
preload,
|
|
50
41
|
// Warning: Enable nodeIntegration and disable contextIsolation is not secure in production
|
|
@@ -55,11 +46,10 @@ async function createWindow() {
|
|
|
55
46
|
},
|
|
56
47
|
});
|
|
57
48
|
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
win.loadURL(url);
|
|
49
|
+
if (isDev) {
|
|
50
|
+
win.loadURL(serverUrl);
|
|
61
51
|
// Open devTool if the app is not packaged
|
|
62
|
-
|
|
52
|
+
win.webContents.openDevTools();
|
|
63
53
|
} else {
|
|
64
54
|
win.loadFile(indexHtml);
|
|
65
55
|
}
|
|
@@ -77,7 +67,26 @@ async function createWindow() {
|
|
|
77
67
|
// win.webContents.on('will-navigate', (event, url) => { }) #344
|
|
78
68
|
}
|
|
79
69
|
|
|
80
|
-
app.whenReady().then(
|
|
70
|
+
app.whenReady().then(async () => {
|
|
71
|
+
createWindow();
|
|
72
|
+
|
|
73
|
+
if (isDev) {
|
|
74
|
+
const { installExtension, REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS } = await import(
|
|
75
|
+
'@tomjs/electron-devtools-installer'
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
installExtension([REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS])
|
|
79
|
+
.then(exts => {
|
|
80
|
+
console.log(
|
|
81
|
+
'Added Extension: ',
|
|
82
|
+
exts.map(s => s.name),
|
|
83
|
+
);
|
|
84
|
+
})
|
|
85
|
+
.catch(() => {
|
|
86
|
+
console.log('Failed to install extensions');
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
81
90
|
|
|
82
91
|
app.on('window-all-closed', () => {
|
|
83
92
|
win = null;
|
|
@@ -111,8 +120,8 @@ ipcMain.handle('open-win', (_, arg) => {
|
|
|
111
120
|
},
|
|
112
121
|
});
|
|
113
122
|
|
|
114
|
-
if (
|
|
115
|
-
childWindow.loadURL(`${
|
|
123
|
+
if (serverUrl) {
|
|
124
|
+
childWindow.loadURL(`${serverUrl}#${arg}`);
|
|
116
125
|
} else {
|
|
117
126
|
childWindow.loadFile(indexHtml, { hash: arg });
|
|
118
127
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log('Electron Preload Process!');
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electron-app",
|
|
3
3
|
"version": "0.0.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "vite + electron + vue",
|
|
5
6
|
"engines": {
|
|
6
7
|
"node": ">=18"
|
|
7
8
|
},
|
|
8
|
-
"
|
|
9
|
-
"env": {
|
|
10
|
-
"VITE_DEV_SERVER_URL": "http://127.0.0.1:6888/"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"main": "dist/main.js",
|
|
9
|
+
"main": "dist/main/index.mjs",
|
|
14
10
|
"scripts": {
|
|
15
11
|
"dev": "vite",
|
|
16
12
|
"build": "npm run clean && vue-tsc --noEmit && vite build && npm run release",
|
|
@@ -22,18 +18,20 @@
|
|
|
22
18
|
"prepare": "husky install"
|
|
23
19
|
},
|
|
24
20
|
"dependencies": {
|
|
25
|
-
"vue": "^3.3.
|
|
21
|
+
"vue": "^3.3.11"
|
|
26
22
|
},
|
|
27
23
|
"devDependencies": {
|
|
28
24
|
"@commitlint/cli": "^18.4.3",
|
|
29
25
|
"@tomjs/commitlint": "^2.0.5",
|
|
26
|
+
"@tomjs/electron-devtools-installer": "^2.0.3",
|
|
30
27
|
"@tomjs/eslint": "^1.1.1",
|
|
31
28
|
"@tomjs/prettier": "^1.0.6",
|
|
32
|
-
"@tomjs/stylelint": "^1.1.
|
|
33
|
-
"@tomjs/tsconfig": "^1.0.
|
|
29
|
+
"@tomjs/stylelint": "^1.1.1",
|
|
30
|
+
"@tomjs/tsconfig": "^1.0.9",
|
|
31
|
+
"@tomjs/vite-plugin-electron": "^1.1.2",
|
|
34
32
|
"@types/node": "^18.19.3",
|
|
35
33
|
"@types/shelljs": "^0.8.15",
|
|
36
|
-
"@vitejs/plugin-vue": "^4.5.
|
|
34
|
+
"@vitejs/plugin-vue": "^4.5.2",
|
|
37
35
|
"electron": "^28.0.0",
|
|
38
36
|
"electron-builder": "^24.9.1",
|
|
39
37
|
"eslint": "^8.55.0",
|
|
@@ -44,11 +42,9 @@
|
|
|
44
42
|
"rimraf": "^5.0.5",
|
|
45
43
|
"shelljs": "^0.8.5",
|
|
46
44
|
"stylelint": "^15.11.0",
|
|
47
|
-
"tree-kill": "^1.2.2",
|
|
48
45
|
"tsx": "^4.6.2",
|
|
49
46
|
"typescript": "~5.2.2",
|
|
50
|
-
"vite": "^5.0.
|
|
51
|
-
"vite-plugin-electron": "^0.15.4",
|
|
47
|
+
"vite": "^5.0.7",
|
|
52
48
|
"vite-plugin-electron-renderer": "^0.14.5",
|
|
53
49
|
"vue-tsc": "^1.8.25"
|
|
54
50
|
}
|
|
@@ -11,7 +11,7 @@ export default {
|
|
|
11
11
|
output: `build/${pkg.version}`,
|
|
12
12
|
app: 'dist',
|
|
13
13
|
},
|
|
14
|
-
files: ['main.
|
|
14
|
+
files: ['main/index.mjs', 'preload/index.mjs', 'renderer'],
|
|
15
15
|
icon: 'public/img/icon.png',
|
|
16
16
|
artifactName: '${productName}-${version}-${os}-${arch}.${ext}',
|
|
17
17
|
electronLanguages: ['zh-CN', 'en-US'],
|
|
@@ -13,7 +13,7 @@ function genPkgJson() {
|
|
|
13
13
|
version: pkg.version,
|
|
14
14
|
author: os.userInfo().username,
|
|
15
15
|
description: pkg.description,
|
|
16
|
-
main: '
|
|
16
|
+
main: 'main/index.mjs',
|
|
17
17
|
dependencies: Object.entries(Object.assign({}, pkg.dependencies, pkg.devDependencies))
|
|
18
18
|
.filter(([name]) => ELECTRON_DEPENDENCIES.includes(name))
|
|
19
19
|
.reduce((object, entry) => ({ ...object, [entry[0]]: entry[1] }), {}),
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import os from 'node:os';
|
|
3
2
|
import HelloWorld from './components/HelloWorld.vue';
|
|
4
|
-
|
|
5
|
-
const info = os.platform() + ' ' + os.arch();
|
|
6
3
|
</script>
|
|
7
4
|
|
|
8
5
|
<template>
|
|
@@ -17,7 +14,6 @@ const info = os.platform() + ' ' + os.arch();
|
|
|
17
14
|
<img src="./assets/vue.svg" class="logo vue" alt="Vue logo" />
|
|
18
15
|
</a>
|
|
19
16
|
</div>
|
|
20
|
-
<div>{{ info }}</div>
|
|
21
17
|
<HelloWorld msg="Vite + Electron + Vue" />
|
|
22
18
|
</template>
|
|
23
19
|
|
|
@@ -40,4 +36,20 @@ const info = os.platform() + ' ' + os.arch();
|
|
|
40
36
|
.logo.vue:hover {
|
|
41
37
|
filter: drop-shadow(0 0 2em #42b883aa);
|
|
42
38
|
}
|
|
39
|
+
|
|
40
|
+
@keyframes logo-spin {
|
|
41
|
+
from {
|
|
42
|
+
transform: rotate(0deg);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
to {
|
|
46
|
+
transform: rotate(360deg);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
51
|
+
a:nth-of-type(2) .logo {
|
|
52
|
+
animation: logo-spin infinite 20s linear;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
43
55
|
</style>
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import os from 'node:os';
|
|
2
3
|
import { ref } from 'vue';
|
|
3
4
|
|
|
4
5
|
defineProps<{ msg: string }>();
|
|
5
6
|
|
|
6
7
|
const count = ref(0);
|
|
8
|
+
|
|
9
|
+
const versions = ['chrome', 'node', 'electron']
|
|
10
|
+
.map(s => `${s}: ${process.versions[s]}`)
|
|
11
|
+
.concat(['platform: ' + os.platform() + ' ' + os.arch()]);
|
|
7
12
|
</script>
|
|
8
13
|
|
|
9
14
|
<template>
|
|
10
15
|
<h1>{{ msg }}</h1>
|
|
11
16
|
|
|
12
17
|
<div class="card">
|
|
18
|
+
<div style="margin-bottom: 1em">{{ versions.join(', ') }}</div>
|
|
13
19
|
<button type="button" @click="count++">count is {{ count }}</button>
|
|
14
20
|
<p>
|
|
15
21
|
Edit
|
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
import { rmSync } from 'node:fs';
|
|
2
1
|
import path from 'node:path';
|
|
3
2
|
import { defineConfig } from 'vite';
|
|
4
|
-
import electron from 'vite-plugin-electron';
|
|
5
|
-
import { notBundle } from 'vite-plugin-electron/plugin';
|
|
6
3
|
import renderer from 'vite-plugin-electron-renderer';
|
|
4
|
+
import electron from '@tomjs/vite-plugin-electron';
|
|
7
5
|
import vue from '@vitejs/plugin-vue';
|
|
8
6
|
import pkg from './package.json';
|
|
9
7
|
|
|
10
8
|
// https://vitejs.dev/config/
|
|
11
|
-
export default defineConfig((
|
|
12
|
-
['main.js', 'main.js.map', 'preload.js'].forEach(s => {
|
|
13
|
-
rmSync(`dist/${s}`, { recursive: true, force: true });
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
const isServe = command === 'serve';
|
|
17
|
-
const isBuild = command === 'build';
|
|
18
|
-
const sourcemap = isServe || !!process.env.VSCODE_DEBUG;
|
|
19
|
-
|
|
9
|
+
export default defineConfig(() => {
|
|
20
10
|
process.env.APP_BUILD_TIME = Date.now() + '';
|
|
21
11
|
process.env.APP_VERSION = pkg.version;
|
|
22
12
|
|
|
@@ -33,79 +23,18 @@ export default defineConfig(({ command }) => {
|
|
|
33
23
|
},
|
|
34
24
|
plugins: [
|
|
35
25
|
vue(),
|
|
36
|
-
electron(
|
|
37
|
-
{
|
|
38
|
-
|
|
39
|
-
onstart({ startup }) {
|
|
40
|
-
if (process.env.VSCODE_DEBUG) {
|
|
41
|
-
console.log(/* For `.vscode/.debug.script.mjs` */ '[startup] Electron App');
|
|
42
|
-
} else {
|
|
43
|
-
startup();
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
vite: {
|
|
47
|
-
build: {
|
|
48
|
-
sourcemap,
|
|
49
|
-
minify: isBuild,
|
|
50
|
-
outDir: 'dist',
|
|
51
|
-
emptyOutDir: false,
|
|
52
|
-
lib: {
|
|
53
|
-
entry: 'electron/main/index.ts',
|
|
54
|
-
formats: ['cjs'],
|
|
55
|
-
fileName: () => 'main.js',
|
|
56
|
-
},
|
|
57
|
-
rollupOptions: {
|
|
58
|
-
// Some third-party Node.js libraries may not be built correctly by Vite, especially `C/C++` addons,
|
|
59
|
-
// we can use `external` to exclude them to ensure they work correctly.
|
|
60
|
-
// Others need to put them in `dependencies` to ensure they are collected into `app.asar` after the app is built.
|
|
61
|
-
// Of course, this is not absolute, just this way is relatively simple. :)
|
|
62
|
-
external: Object.keys('dependencies' in pkg ? pkg.dependencies : {}),
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
plugins: [
|
|
66
|
-
// This is just an option to improve build performance, it's non-deterministic!
|
|
67
|
-
// e.g. `import log from 'electron-log'` -> `const log = require('electron-log')`
|
|
68
|
-
isServe && notBundle(),
|
|
69
|
-
],
|
|
70
|
-
},
|
|
26
|
+
electron({
|
|
27
|
+
main: {
|
|
28
|
+
entry: 'electron/main/index.ts',
|
|
71
29
|
},
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
// Notify the Renderer process to reload the page when the Preload scripts build is complete,
|
|
75
|
-
// instead of restarting the entire Electron App.
|
|
76
|
-
reload();
|
|
77
|
-
},
|
|
78
|
-
vite: {
|
|
79
|
-
build: {
|
|
80
|
-
sourcemap: sourcemap ? 'inline' : undefined, // #332
|
|
81
|
-
minify: isBuild,
|
|
82
|
-
outDir: 'dist',
|
|
83
|
-
emptyOutDir: false,
|
|
84
|
-
lib: {
|
|
85
|
-
entry: 'electron/preload/index.ts',
|
|
86
|
-
formats: ['cjs'],
|
|
87
|
-
fileName: () => 'preload.js',
|
|
88
|
-
},
|
|
89
|
-
rollupOptions: {
|
|
90
|
-
external: Object.keys('dependencies' in pkg ? pkg.dependencies : {}),
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
plugins: [isServe && notBundle()],
|
|
94
|
-
},
|
|
30
|
+
preload: {
|
|
31
|
+
entry: 'electron/preload/index.ts',
|
|
95
32
|
},
|
|
96
|
-
|
|
33
|
+
}),
|
|
97
34
|
// Use Node.js API in the Renderer process
|
|
98
35
|
renderer(),
|
|
99
36
|
],
|
|
100
|
-
server:
|
|
101
|
-
? (() => {
|
|
102
|
-
const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL);
|
|
103
|
-
return {
|
|
104
|
-
host: url.hostname,
|
|
105
|
-
port: +url.port,
|
|
106
|
-
};
|
|
107
|
-
})()
|
|
108
|
-
: {},
|
|
37
|
+
server: {},
|
|
109
38
|
clearScreen: false,
|
|
110
39
|
};
|
|
111
40
|
});
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"@tomjs/commitlint": "^2.0.5",
|
|
58
58
|
"@tomjs/eslint": "^1.1.1",
|
|
59
59
|
"@tomjs/prettier": "^1.0.6",
|
|
60
|
-
"@tomjs/stylelint": "^1.1.
|
|
61
|
-
"@tomjs/tsconfig": "^1.0.
|
|
60
|
+
"@tomjs/stylelint": "^1.1.1",
|
|
61
|
+
"@tomjs/tsconfig": "^1.0.9",
|
|
62
62
|
"@types/jest": "^29.5.11",
|
|
63
63
|
"@types/node": "^18.19.3",
|
|
64
64
|
"electron": "^28.0.0",
|
|
@@ -75,6 +75,6 @@
|
|
|
75
75
|
"tsup": "^8.0.1",
|
|
76
76
|
"tsx": "^4.6.2",
|
|
77
77
|
"typescript": "~5.2.2",
|
|
78
|
-
"vite": "^5.0.
|
|
78
|
+
"vite": "^5.0.7"
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@tomjs/commitlint": "^2.0.5",
|
|
26
26
|
"@tomjs/eslint": "^1.1.1",
|
|
27
27
|
"@tomjs/prettier": "^1.0.6",
|
|
28
|
-
"@tomjs/stylelint": "^1.1.
|
|
29
|
-
"@tomjs/tsconfig": "^1.0.
|
|
28
|
+
"@tomjs/stylelint": "^1.1.1",
|
|
29
|
+
"@tomjs/tsconfig": "^1.0.9",
|
|
30
30
|
"@types/node": "^18.19.3",
|
|
31
31
|
"@types/react": "^18.2.42",
|
|
32
32
|
"@types/react-dom": "^18.2.17",
|
|
@@ -38,6 +38,6 @@
|
|
|
38
38
|
"prettier": "^3.1.0",
|
|
39
39
|
"stylelint": "^15.11.0",
|
|
40
40
|
"typescript": "~5.2.2",
|
|
41
|
-
"vite": "^5.0.
|
|
41
|
+
"vite": "^5.0.7"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
"prepare": "husky install"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"vue": "^3.3.
|
|
20
|
+
"vue": "^3.3.11"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@commitlint/cli": "^18.4.3",
|
|
24
24
|
"@tomjs/commitlint": "^2.0.5",
|
|
25
25
|
"@tomjs/eslint": "^1.1.1",
|
|
26
26
|
"@tomjs/prettier": "^1.0.6",
|
|
27
|
-
"@tomjs/stylelint": "^1.1.
|
|
28
|
-
"@tomjs/tsconfig": "^1.0.
|
|
27
|
+
"@tomjs/stylelint": "^1.1.1",
|
|
28
|
+
"@tomjs/tsconfig": "^1.0.9",
|
|
29
29
|
"@types/node": "^18.19.3",
|
|
30
|
-
"@vitejs/plugin-vue": "^4.5.
|
|
30
|
+
"@vitejs/plugin-vue": "^4.5.2",
|
|
31
31
|
"eslint": "^8.55.0",
|
|
32
32
|
"husky": "^8.0.3",
|
|
33
33
|
"lint-staged": "^15.2.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"prettier": "^3.1.0",
|
|
36
36
|
"stylelint": "^15.11.0",
|
|
37
37
|
"typescript": "~5.2.2",
|
|
38
|
-
"vite": "^5.0.
|
|
38
|
+
"vite": "^5.0.7",
|
|
39
39
|
"vue-tsc": "^1.8.25"
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
VITE_DEV_SERVER_URL=http://127.0.0.1:6888/
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
import { fileURLToPath } from 'node:url'
|
|
4
|
-
import { createRequire } from 'node:module'
|
|
5
|
-
import { spawn } from 'node:child_process'
|
|
6
|
-
|
|
7
|
-
const pkg = createRequire(import.meta.url)('../package.json')
|
|
8
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
9
|
-
|
|
10
|
-
// write .debug.env
|
|
11
|
-
const envContent = Object.entries(pkg.debug.env).map(([key, val]) => `${key}=${val}`)
|
|
12
|
-
fs.writeFileSync(path.join(__dirname, '.debug.env'), envContent.join('\n'))
|
|
13
|
-
|
|
14
|
-
// bootstrap
|
|
15
|
-
spawn(
|
|
16
|
-
// TODO: terminate `npm run dev` when Debug exits.
|
|
17
|
-
process.platform === 'win32' ? 'npm.cmd' : 'npm',
|
|
18
|
-
['run', 'dev'],
|
|
19
|
-
{
|
|
20
|
-
stdio: 'inherit',
|
|
21
|
-
env: Object.assign(process.env, { VSCODE_DEBUG: 'true' }),
|
|
22
|
-
},
|
|
23
|
-
)
|
|
@@ -1,53 +0,0 @@
|
|
|
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
|
-
"--remote-debugging-port=9229",
|
|
33
|
-
"."
|
|
34
|
-
],
|
|
35
|
-
"envFile": "${workspaceFolder}/.vscode/.debug.env",
|
|
36
|
-
"console": "integratedTerminal"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"name": "Debug Renderer Process",
|
|
40
|
-
"port": 9229,
|
|
41
|
-
"request": "attach",
|
|
42
|
-
"type": "chrome",
|
|
43
|
-
"timeout": 60000,
|
|
44
|
-
"skipFiles": [
|
|
45
|
-
"<node_internals>/**",
|
|
46
|
-
"${workspaceRoot}/node_modules/**",
|
|
47
|
-
"${workspaceRoot}/dist-electron/**",
|
|
48
|
-
// Skip files in host(VITE_DEV_SERVER_URL)
|
|
49
|
-
"http://127.0.0.1:6888/**"
|
|
50
|
-
]
|
|
51
|
-
},
|
|
52
|
-
]
|
|
53
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
VITE_DEV_SERVER_URL=http://127.0.0.1:6888/
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
import { fileURLToPath } from 'node:url'
|
|
4
|
-
import { createRequire } from 'node:module'
|
|
5
|
-
import { spawn } from 'node:child_process'
|
|
6
|
-
|
|
7
|
-
const pkg = createRequire(import.meta.url)('../package.json')
|
|
8
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
9
|
-
|
|
10
|
-
// write .debug.env
|
|
11
|
-
const envContent = Object.entries(pkg.debug.env).map(([key, val]) => `${key}=${val}`)
|
|
12
|
-
fs.writeFileSync(path.join(__dirname, '.debug.env'), envContent.join('\n'))
|
|
13
|
-
|
|
14
|
-
// bootstrap
|
|
15
|
-
spawn(
|
|
16
|
-
// TODO: terminate `npm run dev` when Debug exits.
|
|
17
|
-
process.platform === 'win32' ? 'npm.cmd' : 'npm',
|
|
18
|
-
['run', 'dev'],
|
|
19
|
-
{
|
|
20
|
-
stdio: 'inherit',
|
|
21
|
-
env: Object.assign(process.env, { VSCODE_DEBUG: 'true' }),
|
|
22
|
-
},
|
|
23
|
-
)
|
|
@@ -1,53 +0,0 @@
|
|
|
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
|
-
"--remote-debugging-port=9229",
|
|
33
|
-
"."
|
|
34
|
-
],
|
|
35
|
-
"envFile": "${workspaceFolder}/.vscode/.debug.env",
|
|
36
|
-
"console": "integratedTerminal"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"name": "Debug Renderer Process",
|
|
40
|
-
"port": 9229,
|
|
41
|
-
"request": "attach",
|
|
42
|
-
"type": "chrome",
|
|
43
|
-
"timeout": 60000,
|
|
44
|
-
"skipFiles": [
|
|
45
|
-
"<node_internals>/**",
|
|
46
|
-
"${workspaceRoot}/node_modules/**",
|
|
47
|
-
"${workspaceRoot}/dist-electron/**",
|
|
48
|
-
// Skip files in host(VITE_DEV_SERVER_URL)
|
|
49
|
-
"http://127.0.0.1:6888/**"
|
|
50
|
-
]
|
|
51
|
-
},
|
|
52
|
-
]
|
|
53
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
}
|