feat: 更新窗口关闭行为,支持托盘最小化并修复布局样式

This commit is contained in:
ILoveBingLu
2026-03-12 20:12:27 +08:00
parent 24c9bc3ebc
commit 9eae24e4e0
6 changed files with 97 additions and 7 deletions
+10 -3
View File
@@ -243,18 +243,25 @@ function createWindow() {
// 获取关闭行为配置
const closeToTray = configService?.get('closeToTray')
// 如果配置为关闭到托盘(默认为 true)
if (closeToTray !== false) {
event.preventDefault()
win.hide()
// 确保托盘已创建
if (!tray) {
createTray()
}
return
}
// 否则允许窗口关闭,应用退出
// 配置为直接退出时,需要显式退出应用。
// 否则主窗口关闭后托盘仍然存在,进程不会真正结束。
event.preventDefault()
app.isQuitting = true
app.quit()
})
// 开发环境加载 vite 服务器
+81
View File
@@ -34,6 +34,7 @@
"koffi": "^2.9.0",
"lucide-react": "^0.562.0",
"marked": "^17.0.1",
"motion": "^12.35.2",
"onnxruntime-node": "^1.23.2",
"openai": "^4.70.0",
"react": "^19.2.3",
@@ -6552,6 +6553,39 @@
"node": ">=0.8"
}
},
"node_modules/framer-motion": {
"version": "12.35.2",
"resolved": "https://registry.npmmirror.com/framer-motion/-/framer-motion-12.35.2.tgz",
"integrity": "sha512-dhfuEMaNo0hc+AEqyHiIfiJRNb9U9UQutE9FoKm5pjf7CMitp9xPEF1iWZihR1q86LBmo6EJ7S8cN8QXEy49AA==",
"license": "MIT",
"dependencies": {
"motion-dom": "^12.35.2",
"motion-utils": "^12.29.2",
"tslib": "^2.4.0"
},
"peerDependencies": {
"@emotion/is-prop-valid": "*",
"react": "^18.0.0 || ^19.0.0",
"react-dom": "^18.0.0 || ^19.0.0"
},
"peerDependenciesMeta": {
"@emotion/is-prop-valid": {
"optional": true
},
"react": {
"optional": true
},
"react-dom": {
"optional": true
}
}
},
"node_modules/framer-motion/node_modules/tslib": {
"version": "2.8.1",
"resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.8.1.tgz",
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"license": "0BSD"
},
"node_modules/fs-constants": {
"version": "1.0.0",
"resolved": "https://registry.npmmirror.com/fs-constants/-/fs-constants-1.0.0.tgz",
@@ -8015,6 +8049,53 @@
"integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==",
"license": "MIT"
},
"node_modules/motion": {
"version": "12.35.2",
"resolved": "https://registry.npmmirror.com/motion/-/motion-12.35.2.tgz",
"integrity": "sha512-8zCi1DkNyU6a/tgEHn/GnnXZDcaMpDHbDOGORY1Rg/6lcNMSOuvwDB3i4hMSOvxqMWArc/vrGaw/Xek1OP69/A==",
"license": "MIT",
"dependencies": {
"framer-motion": "^12.35.2",
"tslib": "^2.4.0"
},
"peerDependencies": {
"@emotion/is-prop-valid": "*",
"react": "^18.0.0 || ^19.0.0",
"react-dom": "^18.0.0 || ^19.0.0"
},
"peerDependenciesMeta": {
"@emotion/is-prop-valid": {
"optional": true
},
"react": {
"optional": true
},
"react-dom": {
"optional": true
}
}
},
"node_modules/motion-dom": {
"version": "12.35.2",
"resolved": "https://registry.npmmirror.com/motion-dom/-/motion-dom-12.35.2.tgz",
"integrity": "sha512-pWXFMTwvGDbx1Fe9YL5HZebv2NhvGBzRtiNUv58aoK7+XrsuaydQ0JGRKK2r+bTKlwgSWwWxHbP5249Qr/BNpg==",
"license": "MIT",
"dependencies": {
"motion-utils": "^12.29.2"
}
},
"node_modules/motion-utils": {
"version": "12.29.2",
"resolved": "https://registry.npmmirror.com/motion-utils/-/motion-utils-12.29.2.tgz",
"integrity": "sha512-G3kc34H2cX2gI63RqU+cZq+zWRRPSsNIOjpdl9TN4AQwC4sgwYPl/Q/Obf/d53nOm569T0fYK+tcoSV50BWx8A==",
"license": "MIT"
},
"node_modules/motion/node_modules/tslib": {
"version": "2.8.1",
"resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.8.1.tgz",
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"license": "0BSD"
},
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.3.tgz",
+1
View File
@@ -42,6 +42,7 @@
"koffi": "^2.9.0",
"lucide-react": "^0.562.0",
"marked": "^17.0.1",
"motion": "^12.35.2",
"onnxruntime-node": "^1.23.2",
"openai": "^4.70.0",
"react": "^19.2.3",
+1 -1
View File
@@ -460,7 +460,7 @@ function App() {
}
// 主窗口 - 完整布局
const disableContentOverflow = ['/data-management', '/settings', '/open-api'].includes(location.pathname)
const disableContentOverflow = ['/data-management', '/settings'].includes(location.pathname)
return (
<div className="app-container">
+3 -2
View File
@@ -552,8 +552,9 @@ function OpenApiPage() {
return (
<>
<Box sx={{ height: '100%', overflowY: 'auto', pb: 3 }}>
<Container maxWidth="lg" sx={{ px: { xs: 2, md: 3 }, py: 3 }}>
{/* 独立页面布局:抵消 App 主内容区的 padding,完整占据空间 */}
<Box sx={{ height: '100%', mx: -3, mt: -3, overflowY: 'auto', pb: 3 }}>
<Container maxWidth="lg" sx={{ px: { xs: 2, md: 4 }, py: { xs: 3, md: 4 } }}>
<Stack spacing={3}>
<Box>
<Stack
+1 -1
View File
@@ -4,7 +4,7 @@
display: flex;
flex-direction: column;
height: calc(100% + 24px);
margin: -24px 0 0;
margin: -24px -24px 0;
position: relative;
overflow: hidden;