mirror of
https://github.com/woodchen-ink/nezha-dash-v1.git
synced 2025-07-18 09:31:55 +08:00
commit
f21a8cf844
10
package.json
10
package.json
@ -24,8 +24,8 @@
|
|||||||
"@radix-ui/react-separator": "^1.1.1",
|
"@radix-ui/react-separator": "^1.1.1",
|
||||||
"@radix-ui/react-slot": "^1.1.1",
|
"@radix-ui/react-slot": "^1.1.1",
|
||||||
"@radix-ui/react-switch": "^1.1.2",
|
"@radix-ui/react-switch": "^1.1.2",
|
||||||
"@tanstack/react-query": "^5.62.15",
|
"@tanstack/react-query": "^5.63.0",
|
||||||
"@tanstack/react-query-devtools": "^5.62.15",
|
"@tanstack/react-query-devtools": "^5.63.0",
|
||||||
"@tanstack/react-table": "^8.20.6",
|
"@tanstack/react-table": "^8.20.6",
|
||||||
"@trivago/prettier-plugin-sort-imports": "^5.2.1",
|
"@trivago/prettier-plugin-sort-imports": "^5.2.1",
|
||||||
"@types/d3-geo": "^3.1.0",
|
"@types/d3-geo": "^3.1.0",
|
||||||
@ -37,7 +37,7 @@
|
|||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"framer-motion": "^12.0.0-alpha.2",
|
"framer-motion": "^12.0.0-alpha.2",
|
||||||
"i18n-iso-countries": "^7.13.0",
|
"i18n-iso-countries": "^7.13.0",
|
||||||
"i18next": "^24.2.0",
|
"i18next": "^24.2.1",
|
||||||
"lucide-react": "^0.460.0",
|
"lucide-react": "^0.460.0",
|
||||||
"luxon": "^3.5.0",
|
"luxon": "^3.5.0",
|
||||||
"prettier-plugin-tailwindcss": "^0.6.9",
|
"prettier-plugin-tailwindcss": "^0.6.9",
|
||||||
@ -53,7 +53,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.17.0",
|
"@eslint/js": "^9.17.0",
|
||||||
"@types/node": "^22.10.5",
|
"@types/node": "^22.10.5",
|
||||||
"@types/react": "^19.0.2",
|
"@types/react": "^19.0.4",
|
||||||
"@types/react-dom": "^19.0.2",
|
"@types/react-dom": "^19.0.2",
|
||||||
"@vitejs/plugin-react-swc": "^3.7.2",
|
"@vitejs/plugin-react-swc": "^3.7.2",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
@ -64,7 +64,7 @@
|
|||||||
"postcss": "^8.4.49",
|
"postcss": "^8.4.49",
|
||||||
"tailwindcss": "^3.4.17",
|
"tailwindcss": "^3.4.17",
|
||||||
"typescript": "~5.6.3",
|
"typescript": "~5.6.3",
|
||||||
"typescript-eslint": "^8.19.0",
|
"typescript-eslint": "^8.19.1",
|
||||||
"vite": "^6.0.7"
|
"vite": "^6.0.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,8 +106,29 @@ export const WebSocketProvider: React.FC<WebSocketProviderProps> = ({ url, child
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
connect()
|
connect()
|
||||||
|
|
||||||
|
// 添加页面可见性变化监听
|
||||||
|
const handleVisibilityChange = () => {
|
||||||
|
if (document.hidden) {
|
||||||
|
// 页面隐藏时断开连接
|
||||||
|
cleanup()
|
||||||
|
} else {
|
||||||
|
// 页面可见时重新连接
|
||||||
|
connect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加页面卸载事件监听
|
||||||
|
const handleBeforeUnload = () => {
|
||||||
|
cleanup()
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("visibilitychange", handleVisibilityChange)
|
||||||
|
window.addEventListener("beforeunload", handleBeforeUnload)
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
cleanup()
|
cleanup()
|
||||||
|
document.removeEventListener("visibilitychange", handleVisibilityChange)
|
||||||
|
window.removeEventListener("beforeunload", handleBeforeUnload)
|
||||||
}
|
}
|
||||||
}, [url])
|
}, [url])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user