-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db2aaf2
commit c12e745
Showing
7 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { BrowserWindow, ipcMain } from 'electron' | ||
|
||
export async function windowAction(mainWin: Electron.BrowserWindow) { | ||
ipcMain.on('win-min', () => { | ||
const win = BrowserWindow.getFocusedWindow() | ||
win.minimize() | ||
}) | ||
|
||
ipcMain.on('win-recover', () => { | ||
const win = BrowserWindow.getFocusedWindow() | ||
if (win.isMaximized()) | ||
win.unmaximize() | ||
else | ||
win.maximize() | ||
}) | ||
|
||
ipcMain.on('win-close', () => { | ||
const win = BrowserWindow.getFocusedWindow() | ||
win.close() | ||
}) | ||
|
||
mainWin.on('maximize', () => { | ||
mainWin.webContents.send('maximize-change', { | ||
isMax: true, | ||
}) | ||
}) | ||
|
||
mainWin.on('unmaximize', () => { | ||
mainWin.webContents.send('maximize-change', { | ||
isMax: false, | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@import "@/style/var"; | ||
.app-bar { | ||
height: $barHeight; | ||
line-height: $barHeight; | ||
display: flex; | ||
flex-direction: row; | ||
padding: 0 0 0 20px; | ||
justify-content: space-between; | ||
font-size: var(--td-font-size-body-large); | ||
-webkit-app-region: drag; | ||
|
||
.bar-button-groups { | ||
-webkit-app-region: no-drag; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { useEffect, useState } from 'react' | ||
import { Button, Divider, Space } from 'tdesign-react' | ||
import { CloseIcon, RectangleIcon, RelativityIcon, RemoveIcon } from 'tdesign-icons-react' | ||
import { ipcRenderer } from 'electron' | ||
import './index.scss' | ||
|
||
const Bar = () => { | ||
const [isMax, setIsMax] = useState(false) | ||
|
||
const handleMini = () => { | ||
ipcRenderer.send('win-min') | ||
} | ||
|
||
const handleRecover = () => { | ||
ipcRenderer.send('win-recover') | ||
} | ||
|
||
const handleClose = () => { | ||
ipcRenderer.send('win-close') | ||
} | ||
|
||
useEffect(() => { | ||
ipcRenderer.on('maximize-change', (e: unknown, state: { isMax: boolean }) => { | ||
setIsMax(state.isMax) | ||
}) | ||
return () => { | ||
ipcRenderer.removeAllListeners('maximize-change') | ||
} | ||
}, []) | ||
return ( | ||
<div className="app-bar"> | ||
<div className="bar-button-groups">ChatGPT Tool</div> | ||
<div className="bar-button-groups"> | ||
<Space size="0" separator={<Divider layout="vertical" />}> | ||
<Button theme="primary" variant="text" onClick={handleMini}> | ||
<RemoveIcon /> | ||
</Button> | ||
<Button theme="warning" variant="text" onClick={handleRecover}> | ||
{ | ||
isMax ? <RelativityIcon /> : <RectangleIcon /> | ||
} | ||
</Button> | ||
<Button theme="danger" variant="text" onClick={handleClose}> | ||
<CloseIcon /> | ||
</Button> | ||
</Space> | ||
</div> | ||
</div> | ||
) | ||
} | ||
export default Bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$barHeight: var(--td-comp-size-xl); |