setting.router.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import Icon, { SettingOutlined } from '@ant-design/icons'
  2. import { AdminRouterItem } from "../../router/index.tsx";
  3. import React, { Suspense } from 'react';
  4. import LogoIcon from "@src/assets/images/login/logo.svg?react";
  5. // Lazy load components
  6. const Setting = React.lazy(() => import('./setting.tsx'));
  7. // Loading fallback component
  8. // eslint-disable-next-line react-refresh/only-export-components
  9. const LazyLoadingFallback = () => (
  10. <div className="flex items-center justify-center flex-col h-[50vh]">
  11. <Icon component={LogoIcon} className="text-[50px] opacity-50" />
  12. <div className="text-gray-500 text-xl">加载中</div>
  13. </div>
  14. );
  15. // Wrapper component with Suspense
  16. // eslint-disable-next-line react-refresh/only-export-components
  17. const LazyComponent = ({ Component }: { Component: React.ComponentType<any> }) => (
  18. <Suspense fallback={<LazyLoadingFallback />}>
  19. <Component />
  20. </Suspense>
  21. );
  22. const demoRoutes: AdminRouterItem[] = [
  23. {
  24. path: 'setting',
  25. element: <LazyComponent Component={Setting} />,
  26. sortKey: 5,
  27. meta: {
  28. label: "设置",
  29. title: "设置",
  30. key: "/setting",
  31. icon: <SettingOutlined />,
  32. },
  33. }
  34. ]
  35. export default demoRoutes