|
8 | 8 | <script src="https://unpkg.com/react@18/umd/react.production.min.js"></script> |
9 | 9 | <script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script> |
10 | 10 | <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> |
11 | | - <script src="https://cdn.tailwindcss.com"></script> |
| 11 | + <script src="https://unpkg.com/@tailwindcss/browser@4"></script> |
12 | 12 | <!-- <script src="./data.js"></script> --> |
13 | | - <script> |
14 | | - tailwind.config = { |
15 | | - theme: { |
16 | | - extend: { |
17 | | - fontFamily: { |
18 | | - sans: ['"Segoe UI"', "Tahoma", "Geneva", "Verdana", "sans-serif"], |
19 | | - }, |
20 | | - backdropBlur: { |
21 | | - xs: "2px", |
22 | | - }, |
23 | | - colors: { |
24 | | - primary: { |
25 | | - 50: "#faf5ff", |
26 | | - 500: "#8b5cf6", |
27 | | - 600: "#7c3aed", |
28 | | - 700: "#6d28d9", |
29 | | - }, |
30 | | - }, |
31 | | - }, |
32 | | - }, |
33 | | - }; |
34 | | - </script> |
| 13 | + <style type="text/tailwindcss"> |
| 14 | + @theme { |
| 15 | + --color-primary-50: #faf5ff; |
| 16 | + --color-primary-500: #8b5cf6; |
| 17 | + --color-primary-600: #7c3aed; |
| 18 | + --color-primary-700: #6d28d9; |
| 19 | + } |
| 20 | + </style> |
35 | 21 | </head> |
36 | 22 | <body> |
37 | 23 | <div id="root"></div> |
|
288 | 274 | }, |
289 | 275 | }, |
290 | 276 | layout: { |
291 | | - type: "force", |
| 277 | + type: hyperData.nodes.length > 100 ? "force-atlas2" : "force", |
292 | 278 | clustering: visualizationMode === "graph" ? false : true, |
293 | 279 | preventOverlap: true, |
294 | 280 | nodeClusterBy: |
|
303 | 289 | useEffect(() => { |
304 | 290 | if (!graphDataFormatted || !containerRef.current) return; |
305 | 291 |
|
306 | | - // 销毁之前的图形实例 |
307 | | - if (graphRef.current) { |
308 | | - console.log(graphRef.current); |
| 292 | + // 销毁之前的图形实例并清空画布 |
| 293 | + if (graphRef.current && !graphRef.current.destroyed) { |
309 | 294 | graphRef.current.clear(); |
310 | | - graphRef.current.options.plugins = []; |
311 | | - graphRef.current.destroy(); |
312 | | - // graphRef.current.stopLayout && graphRef.current.stopLayout(); // 停止布局 |
313 | | - // graphRef.current.destroy && graphRef.current.destroy(); |
314 | | - // graphRef.current = null; |
| 295 | + if (containerRef.current) { |
| 296 | + containerRef.current.innerHTML = ""; |
| 297 | + } |
315 | 298 | } |
316 | 299 |
|
317 | 300 | const graph = new Graph({ |
|
361 | 344 |
|
362 | 345 | return () => { |
363 | 346 | window.removeEventListener("resize", handleResize); |
364 | | - if (graphRef.current) { |
365 | | - // graphRef.current.clear(); |
366 | | - // graphRef.current.stopLayout && graphRef.current.stopLayout(); // 停止布局 |
367 | | - graphRef.current.destroy && graphRef.current.destroy(); |
368 | | - graphRef.current = null; |
| 347 | + if (graphRef.current && !graphRef.current.destroyed) { |
| 348 | + graphRef.current.clear(); |
| 349 | + } |
| 350 | + if (containerRef.current) { |
| 351 | + containerRef.current.innerHTML = ""; |
369 | 352 | } |
370 | 353 | }; |
371 | 354 | }, [graphDataFormatted, visualizationMode]); |
372 | 355 |
|
373 | 356 | return ( |
374 | 357 | <div className="flex h-screen bg-gradient-to-br from-gray-50 to-gray-100"> |
375 | | - <div className="w-80 bg-white/95 backdrop-blur-sm border-r border-gray-200/50 p-6 overflow-y-auto shadow-xl"> |
| 358 | + <div className="w-80 h-screen overflow-hidden bg-white/95 backdrop-blur-sm border-r border-gray-200/50 p-6 shadow-xl"> |
376 | 359 | <h2 className="text-2xl font-bold text-gray-800 mb-6 flex items-center"> |
377 | 360 | Hypergraph-DB |
378 | 361 | </h2> |
@@ -473,7 +456,7 @@ <h2 className="text-2xl font-bold text-gray-800 mb-6 flex items-center"> |
473 | 456 | )} |
474 | 457 | </div> |
475 | 458 |
|
476 | | - <div className=" overflow-y-auto border border-gray-200 rounded-xl bg-white shadow-inner"> |
| 459 | + <div className="overflow-y-scroll hide-scrollbar h-[50vh] relative border border-gray-200 rounded-xl bg-white shadow-inner"> |
477 | 460 | {filteredVertices.length === 0 ? ( |
478 | 461 | <div className="p-4 text-center text-gray-500"> |
479 | 462 | {searchTerm |
@@ -534,7 +517,7 @@ <h2 className="text-2xl font-bold text-gray-800 mb-6 flex items-center"> |
534 | 517 | </div> |
535 | 518 |
|
536 | 519 | <div className="flex-1 flex flex-col bg-white/10 backdrop-blur-sm"> |
537 | | - <div className="bg-white/95 p-6 border-b border-gray-200/50 flex justify-between items-center shadow-sm"> |
| 520 | + <div className="bg-white/95 p-4 border-b border-gray-200/50 flex justify-between items-center shadow-sm"> |
538 | 521 | <div className="flex items-center gap-4"> |
539 | 522 | <h3 className="text-xl font-semibold text-gray-800 m-0"> |
540 | 523 | {visualizationMode === "hyper" ? "Hypergraph" : "Graph"}{" "} |
@@ -610,7 +593,7 @@ <h3 className="text-xl font-semibold text-gray-800 m-0"> |
610 | 593 | {!loading && ( |
611 | 594 | <div |
612 | 595 | ref={containerRef} |
613 | | - className="w-full min-h-[95vh] rounded-xl" |
| 596 | + className="w-full h-[calc(100vh-100px)] rounded-xl" |
614 | 597 | /> |
615 | 598 | )} |
616 | 599 | </div> |
|
0 commit comments