yangdx
commited on
Commit
·
a8128c3
1
Parent(s):
0d8fa96
Improve cleanup and state reset logic in GraphViewer and NavigationService.
Browse files- Add proper Sigma instance cleanup on unmount
- Ensure error handling for Sigma cleanup
lightrag/api/webui/assets/{index-CSrxfS-k.js → index-BiPN9eZH.js}
RENAMED
Binary files a/lightrag/api/webui/assets/index-CSrxfS-k.js and b/lightrag/api/webui/assets/index-BiPN9eZH.js differ
|
|
lightrag/api/webui/index.html
CHANGED
Binary files a/lightrag/api/webui/index.html and b/lightrag/api/webui/index.html differ
|
|
lightrag_webui/src/features/GraphViewer.tsx
CHANGED
@@ -151,9 +151,17 @@ const GraphViewer = () => {
|
|
151 |
// Clean up sigma instance when component unmounts
|
152 |
useEffect(() => {
|
153 |
return () => {
|
154 |
-
|
155 |
-
|
156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
};
|
158 |
}, []);
|
159 |
|
|
|
151 |
// Clean up sigma instance when component unmounts
|
152 |
useEffect(() => {
|
153 |
return () => {
|
154 |
+
const sigma = useGraphStore.getState().sigmaInstance;
|
155 |
+
if (sigma) {
|
156 |
+
try {
|
157 |
+
// 销毁sigma实例,这会自动清理WebGL上下文
|
158 |
+
sigma.kill();
|
159 |
+
useGraphStore.getState().setSigmaInstance(null);
|
160 |
+
console.log('Cleared sigma instance on unmount');
|
161 |
+
} catch (error) {
|
162 |
+
console.error('Error cleaning up sigma instance:', error);
|
163 |
+
}
|
164 |
+
}
|
165 |
};
|
166 |
}, []);
|
167 |
|
lightrag_webui/src/services/navigation.ts
CHANGED
@@ -19,21 +19,21 @@ class NavigationService {
|
|
19 |
*/
|
20 |
resetAllApplicationState() {
|
21 |
console.log('Resetting all application state...');
|
22 |
-
|
23 |
// Clear authentication state
|
24 |
localStorage.removeItem('LIGHTRAG-API-TOKEN');
|
25 |
sessionStorage.clear();
|
26 |
useAuthStore.getState().logout();
|
27 |
-
|
28 |
// Reset graph state
|
29 |
const graphStore = useGraphStore.getState();
|
30 |
graphStore.reset();
|
31 |
graphStore.setGraphDataFetchAttempted(false);
|
32 |
graphStore.setLabelsFetchAttempted(false);
|
33 |
-
|
34 |
// Reset backend state
|
35 |
useBackendState.getState().clear();
|
36 |
-
|
37 |
// Reset retrieval history while preserving other user preferences
|
38 |
useSettingsStore.getState().setRetrievalHistory([]);
|
39 |
}
|
@@ -45,7 +45,7 @@ class NavigationService {
|
|
45 |
navigateToLogin() {
|
46 |
// Reset state before navigation
|
47 |
this.resetAllApplicationState();
|
48 |
-
|
49 |
if (this.navigate) {
|
50 |
this.navigate('/login');
|
51 |
}
|
|
|
19 |
*/
|
20 |
resetAllApplicationState() {
|
21 |
console.log('Resetting all application state...');
|
22 |
+
|
23 |
// Clear authentication state
|
24 |
localStorage.removeItem('LIGHTRAG-API-TOKEN');
|
25 |
sessionStorage.clear();
|
26 |
useAuthStore.getState().logout();
|
27 |
+
|
28 |
// Reset graph state
|
29 |
const graphStore = useGraphStore.getState();
|
30 |
graphStore.reset();
|
31 |
graphStore.setGraphDataFetchAttempted(false);
|
32 |
graphStore.setLabelsFetchAttempted(false);
|
33 |
+
|
34 |
// Reset backend state
|
35 |
useBackendState.getState().clear();
|
36 |
+
|
37 |
// Reset retrieval history while preserving other user preferences
|
38 |
useSettingsStore.getState().setRetrievalHistory([]);
|
39 |
}
|
|
|
45 |
navigateToLogin() {
|
46 |
// Reset state before navigation
|
47 |
this.resetAllApplicationState();
|
48 |
+
|
49 |
if (this.navigate) {
|
50 |
this.navigate('/login');
|
51 |
}
|