1- import { useState } from 'react'
2- import UpdateElectron from '@/components/update'
3- import logoVite from './assets/logo-vite.svg'
4- import logoElectron from './assets/logo-electron.svg'
5- import './App.css'
6- import { Button } from 'antd'
1+ import React , { useEffect , useState } from 'react' ;
2+ import {
3+ MenuFoldOutlined ,
4+ MenuUnfoldOutlined ,
5+ UploadOutlined ,
6+ UserOutlined ,
7+ VideoCameraOutlined ,
8+ } from '@ant-design/icons' ;
9+ import { Button , Layout , Menu , theme } from 'antd' ;
10+ import { invokeIpcMethod } from './utils/ipcUtils' ;
711
12+ const { Header, Sider, Content } = Layout ;
813
9- function App ( ) {
10- const [ count , setCount ] = useState ( 0 )
14+ const App : React . FC = ( ) => {
15+ const [ collapsed , setCollapsed ] = useState ( false ) ;
16+ const {
17+ token : { colorBgContainer, borderRadiusLG } ,
18+ } = theme . useToken ( ) ;
1119
12- const communication = ( ) => {
13- window . ipcRenderer . send ( "message-from-renderer" , { type : "test" , params : {
14- id : "1" ,
15- name : "zc" ,
16- age : 18
17- } } )
18- }
20+ useEffect ( ( ) => {
21+ const getAreaList = async ( ) => {
22+ const mysql = await invokeIpcMethod ( "mysqlQuery" , "SELECT * from tz_basket tb " )
23+ console . log ( mysql ) ;
24+ }
25+ getAreaList ( ) ;
26+ } , [ ] )
1927
2028 return (
21- < div className = 'App' >
22- < Button onClick = { ( ) => communication ( ) } > 开始通讯</ Button >
23- < div className = 'logo-box' >
24- < a href = 'https://github.com/electron-vite/electron-vite-react' target = '_blank' >
25- < img src = { logoVite } className = 'logo vite' alt = 'Electron + Vite logo' />
26- < img src = { logoElectron } className = 'logo electron' alt = 'Electron + Vite logo' />
27- </ a >
28- </ div >
29- < h1 > Electron + Vite + React</ h1 >
30- < div className = 'card' >
31- < button onClick = { ( ) => setCount ( ( count ) => count + 1 ) } >
32- count is { count }
33- </ button >
34- < p >
35- Edit < code > src/App.tsx</ code > and save to test HMR
36- </ p >
37- </ div >
38- < p className = 'read-the-docs' >
39- Click on the Electron + Vite logo to learn more
40- </ p >
41- < div className = 'flex-center' >
42- Place static files into the< code > /public</ code > folder < img style = { { width : '5em' } } src = './node.svg' alt = 'Node logo' />
43- </ div >
29+ < Layout >
30+ < Button onClick = { async ( ) => {
31+ const mysql = await invokeIpcMethod ( 'SELECT * from tz_area ta ' )
32+ console . log ( mysql ) ;
4433
45- < UpdateElectron />
46- </ div >
47- )
48- }
34+ } } > mysql</ Button >
35+ < Sider trigger = { null } collapsible collapsed = { collapsed } >
36+ < div className = "demo-logo-vertical" />
37+ < Menu
38+ theme = "dark"
39+ mode = "inline"
40+ defaultSelectedKeys = { [ '1' ] }
41+ items = { [
42+ {
43+ key : '1' ,
44+ icon : < UserOutlined /> ,
45+ label : 'nav 1' ,
46+ } ,
47+ {
48+ key : '2' ,
49+ icon : < VideoCameraOutlined /> ,
50+ label : 'nav 2' ,
51+ } ,
52+ {
53+ key : '3' ,
54+ icon : < UploadOutlined /> ,
55+ label : 'nav 3' ,
56+ } ,
57+ ] }
58+ />
59+ </ Sider >
60+ < Layout >
61+ < Header style = { { padding : 0 , background : colorBgContainer } } >
62+ < Button
63+ type = "text"
64+ icon = { collapsed ? < MenuUnfoldOutlined /> : < MenuFoldOutlined /> }
65+ onClick = { ( ) => setCollapsed ( ! collapsed ) }
66+ style = { {
67+ fontSize : '16px' ,
68+ width : 64 ,
69+ height : 64 ,
70+ } }
71+ />
72+ </ Header >
73+ < Content
74+ style = { {
75+ margin : '24px 16px' ,
76+ padding : 24 ,
77+ minHeight : 280 ,
78+ background : colorBgContainer ,
79+ borderRadius : borderRadiusLG ,
80+ } }
81+ >
82+ Content
83+ </ Content >
84+ </ Layout >
85+ </ Layout >
86+ ) ;
87+ } ;
4988
50- export default App
89+ export default App ;
0 commit comments