feat(dashboard, risk): add SWR query hook and lazy load charts
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import dynamic from "next/dynamic";
|
||||
import Link from "next/link";
|
||||
import type { ReactNode } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -23,10 +24,6 @@ import { getAdminRequestLocale } from "@/lib/admin-locale";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { DashboardKpiCard } from "@/modules/dashboard/dashboard-visuals";
|
||||
import { DASHBOARD_CHART_COLORS } from "@/modules/dashboard/dashboard-chart-config";
|
||||
import {
|
||||
DailyTrendChart,
|
||||
PlayBreakdownChart,
|
||||
} from "@/modules/dashboard/dashboard-trend-charts";
|
||||
import {
|
||||
DASHBOARD_ANALYTICS_PERIODS,
|
||||
DASHBOARD_RANKING_METRICS,
|
||||
@@ -34,6 +31,16 @@ import {
|
||||
type DashboardAnalyticsState,
|
||||
} from "@/modules/dashboard/use-dashboard-analytics";
|
||||
|
||||
// recharts 图表组件懒加载
|
||||
const DailyTrendChart = dynamic(
|
||||
() => import("@/modules/dashboard/dashboard-trend-charts").then((m) => ({ default: m.DailyTrendChart })),
|
||||
{ ssr: false },
|
||||
);
|
||||
const PlayBreakdownChart = dynamic(
|
||||
() => import("@/modules/dashboard/dashboard-trend-charts").then((m) => ({ default: m.PlayBreakdownChart })),
|
||||
{ ssr: false },
|
||||
);
|
||||
|
||||
function computeDeltaPercent(series: number[]): string | null {
|
||||
if (series.length < 2) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user