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