Skip to content

Commit 045706e

Browse files
committed
🎉 init:
1 parent 2c3e5f8 commit 045706e

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

.vscode/launch.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
// 使用 IntelliSense 了解相关属性。
3+
// 悬停以查看现有属性的描述。
4+
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Electron Main",
9+
"program": "${workspaceFolder}/main.js",
10+
"request": "launch",
11+
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
12+
"skipFiles": [
13+
"<node_internals>/**"
14+
],
15+
"type": "node"
16+
}
17+
18+
]
19+
}

electron/main/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ const preload = path.join(__dirname, '../preload/index.mjs')
4444
const indexHtml = path.join(RENDERER_DIST, 'index.html')
4545

4646
async function createWindow() {
47+
4748
win = new BrowserWindow({
48-
title: 'Main window',
49+
title: '立冬工具',
4950
icon: path.join(process.env.VITE_PUBLIC, 'favicon.ico'),
51+
backgroundColor: 'pink',//窗口背景颜色
5052
webPreferences: {
5153
preload,
5254
// Warning: Enable nodeIntegration and disable contextIsolation is not secure in production
@@ -79,6 +81,12 @@ async function createWindow() {
7981

8082
// Auto update
8183
update(win)
84+
85+
ipcMain.on('message-from-renderer', (event, arg) => {
86+
console.log(arg); // 将会打印 'Hello from the Renderer process!'
87+
event.reply('message-from-main', 'Hello back from the Main process!');
88+
});
89+
8290
}
8391

8492
app.whenReady().then(createWindow)

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"e2e": "playwright test"
2020
},
2121
"dependencies": {
22+
"antd": "^5.18.0",
2223
"electron-updater": "^6.1.8"
2324
},
2425
"devDependencies": {

src/App.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,23 @@ import UpdateElectron from '@/components/update'
33
import logoVite from './assets/logo-vite.svg'
44
import logoElectron from './assets/logo-electron.svg'
55
import './App.css'
6+
import { Button } from 'antd'
7+
68

79
function App() {
810
const [count, setCount] = useState(0)
11+
12+
const communication=()=>{
13+
window.ipcRenderer.send("message-from-renderer",{type:"test",params:{
14+
id:"1",
15+
name:"zc",
16+
age:18
17+
}})
18+
}
19+
920
return (
1021
<div className='App'>
22+
<Button onClick={()=>communication()}>开始通讯</Button>
1123
<div className='logo-box'>
1224
<a href='https://github.com/electron-vite/electron-vite-react' target='_blank'>
1325
<img src={logoVite} className='logo vite' alt='Electron + Vite logo' />

0 commit comments

Comments
 (0)