mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 22:32:27 +08:00
refactor: Move DiagramProvider to RootLayout for improved context management
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
import { Geist, Geist_Mono } from "next/font/google";
|
import { Geist, Geist_Mono } from "next/font/google";
|
||||||
import { Analytics } from "@vercel/analytics/react";
|
import { Analytics } from "@vercel/analytics/react";
|
||||||
|
import { DiagramProvider } from "@/contexts/diagram-context";
|
||||||
|
|
||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
|
|
||||||
const geistSans = Geist({
|
const geistSans = Geist({
|
||||||
@@ -28,7 +30,8 @@ export default function RootLayout({
|
|||||||
<body
|
<body
|
||||||
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
||||||
>
|
>
|
||||||
{children}
|
<DiagramProvider>{children}</DiagramProvider>
|
||||||
|
|
||||||
<Analytics />
|
<Analytics />
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
36
app/page.tsx
36
app/page.tsx
@@ -2,30 +2,28 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { DrawIoEmbed } from "react-drawio";
|
import { DrawIoEmbed } from "react-drawio";
|
||||||
import ChatPanel from "@/components/chat-panel";
|
import ChatPanel from "@/components/chat-panel";
|
||||||
import { DiagramProvider, useDiagram } from "@/contexts/diagram-context";
|
import { useDiagram } from "@/contexts/diagram-context";
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const { drawioRef, handleDiagramExport } = useDiagram();
|
const { drawioRef, handleDiagramExport } = useDiagram();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DiagramProvider>
|
<div className="flex h-screen bg-gray-100">
|
||||||
<div className="flex h-screen bg-gray-100">
|
<div className="w-2/3 p-1 h-full relative">
|
||||||
<div className="w-2/3 p-1 h-full relative">
|
<DrawIoEmbed
|
||||||
<DrawIoEmbed
|
ref={drawioRef}
|
||||||
ref={drawioRef}
|
onExport={handleDiagramExport}
|
||||||
onExport={handleDiagramExport}
|
urlParameters={{
|
||||||
urlParameters={{
|
spin: true,
|
||||||
spin: true,
|
libraries: false,
|
||||||
libraries: false,
|
saveAndExit: false,
|
||||||
saveAndExit: false,
|
noExitBtn: true,
|
||||||
noExitBtn: true,
|
}}
|
||||||
}}
|
/>
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="w-1/3 h-full p-1">
|
|
||||||
<ChatPanel />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</DiagramProvider>
|
<div className="w-1/3 h-full p-1">
|
||||||
|
<ChatPanel />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user