fix: dynamic import for echarts, html2canvas, jspdf to prevent SSR errors
CI/CD / build-and-push (push) Successful in 1m31s
Details
CI/CD / build-and-push (push) Successful in 1m31s
Details
This commit is contained in:
parent
b7ecc51f13
commit
03629431fd
|
|
@ -8,8 +8,6 @@ import TimeSeriesChart from '@/components/charts/TimeSeriesChart';
|
|||
import NetworkChart from '@/components/charts/NetworkChart';
|
||||
import NodeTable from '@/components/report/NodeTable';
|
||||
import AlertSection from '@/components/report/AlertSection';
|
||||
import html2canvas from 'html2canvas';
|
||||
import jsPDF from 'jspdf';
|
||||
|
||||
export default function Home() {
|
||||
const [days, setDays] = useState(7);
|
||||
|
|
@ -18,6 +16,8 @@ export default function Home() {
|
|||
|
||||
const handleExportPdf = async () => {
|
||||
if (!reportRef.current) return;
|
||||
const html2canvas = (await import('html2canvas')).default;
|
||||
const { default: jsPDF } = await import('jspdf');
|
||||
const canvas = await html2canvas(reportRef.current, { scale: 2, useCORS: true });
|
||||
const imgData = canvas.toDataURL('image/png');
|
||||
const pdf = new jsPDF('p', 'mm', 'a4');
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
'use client';
|
||||
|
||||
import ReactECharts from 'echarts-for-react';
|
||||
import dynamic from 'next/dynamic';
|
||||
import type { NetworkMetrics } from '@/types/metrics';
|
||||
import { formatTimestamp, formatBytes } from '@/lib/formatters';
|
||||
|
||||
const ReactECharts = dynamic(() => import('echarts-for-react'), { ssr: false });
|
||||
|
||||
interface NetworkChartProps {
|
||||
data: NetworkMetrics;
|
||||
height?: number;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
'use client';
|
||||
|
||||
import ReactECharts from 'echarts-for-react';
|
||||
import dynamic from 'next/dynamic';
|
||||
import type { MetricInstance } from '@/types/metrics';
|
||||
import { formatTimestamp } from '@/lib/formatters';
|
||||
|
||||
const ReactECharts = dynamic(() => import('echarts-for-react'), { ssr: false });
|
||||
|
||||
interface TimeSeriesChartProps {
|
||||
title: string;
|
||||
instances: MetricInstance[];
|
||||
|
|
|
|||
Loading…
Reference in New Issue