Skip to content

Commit ba3cb9c

Browse files
committedMar 3, 2025
migrate to v2
1 parent 83f89f8 commit ba3cb9c

17 files changed

+4677
-2729
lines changed
 

‎.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules
22
dist
33
out
44
.gitignore
5+
*.d.ts

‎.eslintrc.cjs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module.exports = {
2-
extends: [
3-
'eslint:recommended',
4-
'plugin:react/recommended',
5-
'plugin:react/jsx-runtime',
6-
'@electron-toolkit/eslint-config-ts/recommended',
7-
'@electron-toolkit/eslint-config-prettier'
8-
]
9-
}
2+
extends: [
3+
'eslint:recommended',
4+
'plugin:react/recommended',
5+
'plugin:react/jsx-runtime',
6+
'@electron-toolkit/eslint-config-ts/recommended',
7+
'@electron-toolkit/eslint-config-prettier',
8+
],
9+
};

‎.prettierrc.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"printWidth": 100,
3+
"tabWidth": 4,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"trailingComma": "all",
8+
"bracketSpacing": true,
9+
"arrowParens": "always",
10+
"quoteProps": "preserve"
11+
}

‎.prettierrc.yaml

-4
This file was deleted.

‎electron.vite.config.ts

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { resolve } from 'path'
2-
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
3-
import react from '@vitejs/plugin-react'
1+
import { resolve } from 'path';
2+
import { defineConfig, externalizeDepsPlugin } from 'electron-vite';
3+
import react from '@vitejs/plugin-react';
44

55
export default defineConfig({
6-
main: {
7-
plugins: [externalizeDepsPlugin()]
8-
},
9-
preload: {
10-
plugins: [externalizeDepsPlugin()]
11-
},
12-
renderer: {
13-
resolve: {
14-
alias: {
15-
'@renderer': resolve('src/renderer/src')
16-
}
6+
main: {
7+
plugins: [externalizeDepsPlugin()],
178
},
18-
plugins: [react()]
19-
}
20-
})
9+
preload: {
10+
plugins: [externalizeDepsPlugin()],
11+
},
12+
renderer: {
13+
resolve: {
14+
alias: {
15+
'@renderer': resolve('src/renderer/src'),
16+
},
17+
},
18+
plugins: [react()],
19+
},
20+
});

‎package.json

+26-26
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zenith-boilerplate",
3-
"version": "1.0.0",
3+
"version": "2.0.0",
44
"description": "An Electron application with React and TypeScript & TailwindCSS and NextUI",
55
"main": "./out/main/index.js",
66
"author": "Arounte",
@@ -20,32 +20,32 @@
2020
"build:linux": "electron-vite build && electron-builder --linux --config"
2121
},
2222
"dependencies": {
23-
"@electron-toolkit/preload": "^2.0.0",
24-
"@electron-toolkit/utils": "^2.0.0",
25-
"@nextui-org/react": "^2.2.9",
26-
"electron-updater": "^6.1.1",
27-
"framer-motion": "^10.17.9"
23+
"@electron-toolkit/preload": "^3.0.1",
24+
"@electron-toolkit/utils": "^4.0.0",
25+
"@heroui/react": "2.7.4",
26+
"electron-updater": "^6.3.9",
27+
"motion": "^12.4.9",
28+
"autoprefixer": "^10.4.20",
29+
"electron": "^34.3.0",
30+
"electron-builder": "^25.1.8",
31+
"@vitejs/plugin-react": "^4.3.4",
32+
"electron-vite": "^3.0.0",
33+
"vite": "^6.2.0",
34+
"react": "^19.0.0",
35+
"react-dom": "^19.0.0",
36+
"tailwindcss": "^3",
37+
"postcss": "^8.5.3"
2838
},
2939
"devDependencies": {
30-
"@electron-toolkit/eslint-config-prettier": "^1.0.1",
31-
"@electron-toolkit/eslint-config-ts": "^1.0.0",
40+
"@electron-toolkit/eslint-config-prettier": "^1",
41+
"@electron-toolkit/eslint-config-ts": "^1",
3242
"@electron-toolkit/tsconfig": "^1.0.1",
33-
"@types/node": "^18.17.5",
34-
"@types/react": "^18.2.20",
35-
"@types/react-dom": "^18.2.7",
36-
"@vitejs/plugin-react": "^4.0.4",
37-
"autoprefixer": "^10.4.16",
38-
"electron": "^28.1.1",
39-
"electron-builder": "^24.6.3",
40-
"electron-vite": "^1.0.27",
41-
"eslint": "^8.47.0",
42-
"eslint-plugin-react": "^7.33.2",
43-
"postcss": "^8.4.33",
44-
"prettier": "^3.0.2",
45-
"react": "^18.2.0",
46-
"react-dom": "^18.2.0",
47-
"tailwindcss": "^3.4.0",
48-
"typescript": "^5.1.6",
49-
"vite": "^4.4.9"
43+
"@types/node": "^22.13.8",
44+
"@types/react": "^19.0.10",
45+
"@types/react-dom": "^19.0.4",
46+
"eslint": "^8",
47+
"eslint-plugin-react": "^7.37.4",
48+
"prettier": "^3.5.3",
49+
"typescript": "^5.8.2"
5050
}
51-
}
51+
}

‎postcss.config.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
2-
plugins: {
3-
tailwindcss: {},
4-
autoprefixer: {},
5-
},
6-
}
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
};

‎src/main/index.ts

+49-49
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
1-
import { app, shell, BrowserWindow } from 'electron'
2-
import { join } from 'path'
3-
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
4-
import icon from '../../resources/icon.png?asset'
1+
import { app, shell, BrowserWindow } from 'electron';
2+
import { join } from 'path';
3+
import { electronApp, optimizer, is } from '@electron-toolkit/utils';
4+
import icon from '../../resources/icon.png?asset';
55

66
function createWindow(): void {
7-
// Create the browser window.
8-
const mainWindow = new BrowserWindow({
9-
width: 900,
10-
height: 670,
11-
show: false,
12-
autoHideMenuBar: true,
13-
...(process.platform === 'linux' ? { icon } : {}),
14-
webPreferences: {
15-
preload: join(__dirname, '../preload/index.js'),
16-
sandbox: false
17-
}
18-
})
7+
// Create the browser window.
8+
const mainWindow = new BrowserWindow({
9+
width: 900,
10+
height: 670,
11+
show: false,
12+
autoHideMenuBar: true,
13+
...(process.platform === 'linux' ? { icon } : {}),
14+
webPreferences: {
15+
preload: join(__dirname, '../preload/index.js'),
16+
sandbox: false,
17+
},
18+
});
1919

20-
mainWindow.on('ready-to-show', () => {
21-
mainWindow.show()
22-
})
20+
mainWindow.on('ready-to-show', () => {
21+
mainWindow.show();
22+
});
2323

24-
mainWindow.webContents.setWindowOpenHandler((details) => {
25-
shell.openExternal(details.url)
26-
return { action: 'deny' }
27-
})
24+
mainWindow.webContents.setWindowOpenHandler((details) => {
25+
shell.openExternal(details.url);
26+
return { action: 'deny' };
27+
});
2828

29-
// HMR for renderer base on electron-vite cli.
30-
// Load the remote URL for development or the local html file for production.
31-
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
32-
mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL'])
33-
} else {
34-
mainWindow.loadFile(join(__dirname, '../renderer/index.html'))
35-
}
29+
// HMR for renderer base on electron-vite cli.
30+
// Load the remote URL for development or the local html file for production.
31+
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
32+
mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL']);
33+
} else {
34+
mainWindow.loadFile(join(__dirname, '../renderer/index.html'));
35+
}
3636
}
3737

3838
// This method will be called when Electron has finished
3939
// initialization and is ready to create browser windows.
4040
// Some APIs can only be used after this event occurs.
4141
app.whenReady().then(() => {
42-
// Set app user model id for windows
43-
electronApp.setAppUserModelId('com.electron')
42+
// Set app user model id for windows
43+
electronApp.setAppUserModelId('com.electron');
4444

45-
// Default open or close DevTools by F12 in development
46-
// and ignore CommandOrControl + R in production.
47-
// see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils
48-
app.on('browser-window-created', (_, window) => {
49-
optimizer.watchWindowShortcuts(window)
50-
})
45+
// Default open or close DevTools by F12 in development
46+
// and ignore CommandOrControl + R in production.
47+
// see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils
48+
app.on('browser-window-created', (_, window) => {
49+
optimizer.watchWindowShortcuts(window);
50+
});
5151

52-
createWindow()
52+
createWindow();
5353

54-
app.on('activate', function () {
55-
// On macOS it's common to re-create a window in the app when the
56-
// dock icon is clicked and there are no other windows open.
57-
if (BrowserWindow.getAllWindows().length === 0) createWindow()
58-
})
59-
})
54+
app.on('activate', function () {
55+
// On macOS it's common to re-create a window in the app when the
56+
// dock icon is clicked and there are no other windows open.
57+
if (BrowserWindow.getAllWindows().length === 0) createWindow();
58+
});
59+
});
6060

6161
// Quit when all windows are closed, except on macOS. There, it's common
6262
// for applications and their menu bar to stay active until the user quits
6363
// explicitly with Cmd + Q.
6464
app.on('window-all-closed', () => {
65-
if (process.platform !== 'darwin') {
66-
app.quit()
67-
}
68-
})
65+
if (process.platform !== 'darwin') {
66+
app.quit();
67+
}
68+
});
6969

7070
// In this file you can include the rest of your app"s specific main process
7171
// code. You can also put them in separate files and require them here.

‎src/preload/index.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import { contextBridge } from 'electron'
2-
import { electronAPI } from '@electron-toolkit/preload'
1+
import { contextBridge } from 'electron';
2+
import { electronAPI } from '@electron-toolkit/preload';
33

44
// Custom APIs for renderer
5-
const api = {}
5+
const api = {};
66

77
// Use `contextBridge` APIs to expose Electron APIs to
88
// renderer only if context isolation is enabled, otherwise
99
// just add to the DOM global.
1010
if (process.contextIsolated) {
11-
try {
12-
contextBridge.exposeInMainWorld('electron', electronAPI)
13-
contextBridge.exposeInMainWorld('api', api)
14-
} catch (error) {
15-
console.error(error)
16-
}
11+
try {
12+
contextBridge.exposeInMainWorld('electron', electronAPI);
13+
contextBridge.exposeInMainWorld('api', api);
14+
} catch (error) {
15+
console.error(error);
16+
}
1717
} else {
18-
// @ts-ignore (define in dts)
19-
window.electron = electronAPI
20-
// @ts-ignore (define in dts)
21-
window.api = api
18+
// @ts-ignore (define in dts)
19+
window.electron = electronAPI;
20+
// @ts-ignore (define in dts)
21+
window.api = api;
2222
}

‎src/renderer/index.html

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<!doctype html>
22
<html>
3-
<head>
4-
<meta charset="UTF-8" />
5-
<title>Electron</title>
6-
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
7-
<meta
8-
http-equiv="Content-Security-Policy"
9-
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'"
10-
/>
11-
</head>
123

13-
<body>
14-
<div id="root"></div>
15-
<script type="module" src="/src/main.tsx"></script>
16-
</body>
17-
</html>
4+
<head>
5+
<meta charset="UTF-8" />
6+
<title>Electron</title>
7+
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
8+
<meta http-equiv="Content-Security-Policy"
9+
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'" />
10+
</head>
11+
12+
<body>
13+
<div id="root"></div>
14+
<script type="module" src="/src/main.tsx"></script>
15+
</body>
16+
17+
</html>

‎src/renderer/src/App.tsx

+20-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
import { Chip } from '@nextui-org/react'
1+
import { Chip } from '@heroui/react';
2+
import { FC } from 'react';
3+
import Versions from '@renderer/components/Versions';
24

3-
function App(): JSX.Element {
4-
return (
5-
<div className="p-4">
6-
<h1 className="text-3xl font-extrabold text-blue-500">Zenith Boilerplate</h1>
7-
<a href="https://github.com/arounte">
8-
<h2 className="text-lg font-light text-blue-400 hover:text-pink-500">GitHub: @Arounte</h2>
9-
</a>
10-
<Chip color="primary" variant="shadow" className="my-2">NextUI works 🍻</Chip>
11-
</div>
12-
)
13-
}
5+
const App: FC = () => {
6+
return (
7+
<div className="p-4 flex flex-col gap-4">
8+
<h1 className="text-3xl font-extrabold text-blue-500">Zenith Boilerplate</h1>
9+
<a href="https://github.com/arounte" target="_blank" rel="noreferrer">
10+
<h2 className="text-lg font-light text-blue-400 hover:text-pink-500">
11+
GitHub: @Arounte
12+
</h2>
13+
</a>
14+
<Chip color="primary" variant="shadow" className="my-2">
15+
HeroUI works 🍻
16+
</Chip>
17+
<Versions />
18+
</div>
19+
);
20+
};
1421

15-
export default App
22+
export default App;
+13-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { useState } from 'react'
1+
import { FC, useRef } from 'react';
22

3-
function Versions(): JSX.Element {
4-
const [versions] = useState(window.electron.process.versions)
3+
const Versions: FC = () => {
4+
const { current: versions } = useRef(window.electron.process.versions);
55

6-
return (
7-
<ul className="versions">
8-
<li className="electron-version">Electron v{versions.electron}</li>
9-
<li className="chrome-version">Chromium v{versions.chrome}</li>
10-
<li className="node-version">Node v{versions.node}</li>
11-
<li className="v8-version">V8 v{versions.v8}</li>
12-
</ul>
13-
)
14-
}
6+
return (
7+
<ul className="text-blue-500">
8+
<li>Electron v{versions.electron}</li>
9+
<li>Chromium v{versions.chrome}</li>
10+
<li>Node v{versions.node}</li>
11+
<li>V8 v{versions.v8}</li>
12+
</ul>
13+
);
14+
};
1515

16-
export default Versions
16+
export default Versions;

‎src/renderer/src/main.tsx

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import React from 'react'
2-
import ReactDOM from 'react-dom/client'
3-
import './assets/index.css'
4-
import App from './App'
5-
import { NextUIProvider } from '@nextui-org/react'
1+
import React from 'react';
2+
import ReactDOM from 'react-dom/client';
3+
import './assets/index.css';
4+
import App from './App';
5+
import { HeroUIProvider } from '@heroui/react';
66

77
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
8-
<React.StrictMode>
9-
<NextUIProvider>
10-
<App />
11-
</NextUIProvider>
12-
</React.StrictMode>
13-
)
8+
<React.StrictMode>
9+
<HeroUIProvider>
10+
<App />
11+
</HeroUIProvider>
12+
</React.StrictMode>,
13+
);

‎tailwind.config.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { nextui } from '@nextui-org/react'
1+
import { heroui } from '@heroui/react';
22

33
/** @type {import('tailwindcss').Config} */
44
export default {
5-
content: [
6-
'./index.html',
7-
'./src/**/*.{js,ts,jsx,tsx}',
8-
'./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}'
9-
],
10-
theme: {
11-
extend: {}
12-
},
13-
darkMode: 'class',
14-
plugins: [nextui()]
15-
}
5+
content: [
6+
'./index.html',
7+
'./src/**/*.{js,ts,jsx,tsx}',
8+
'./node_modules/@heroui/theme/dist/**/*.{js,ts,jsx,tsx}',
9+
],
10+
theme: {
11+
extend: {},
12+
},
13+
darkMode: 'class',
14+
plugins: [heroui()],
15+
};

‎tsconfig.node.json

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
{
22
"extends": "@electron-toolkit/tsconfig/tsconfig.node.json",
3-
"include": ["electron.vite.config.*", "src/main/*", "src/preload/*"],
3+
"include": [
4+
"electron.vite.config.*",
5+
"src/main/*",
6+
"src/preload/*"
7+
],
48
"compilerOptions": {
59
"composite": true,
6-
"types": ["electron-vite/node"]
10+
"types": [
11+
"electron-vite/node"
12+
],
13+
"esModuleInterop": true,
14+
"target": "ES2021",
15+
"module": "ES2022",
16+
"moduleResolution": "node",
17+
"strict": true,
18+
"skipLibCheck": true,
719
}
820
}

‎tsconfig.web.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
"@renderer/*": [
1515
"src/renderer/src/*"
1616
]
17-
}
17+
},
18+
"esModuleInterop": true,
19+
"target": "ES2021",
20+
"module": "ES2022",
21+
"moduleResolution": "bundler",
22+
"strict": true,
23+
"skipLibCheck": true
1824
}
1925
}

‎yarn.lock

+4,456-2,541
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.