publishContent.router.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import Icon, { DesktopOutlined } from '@ant-design/icons'
  2. import { AdminRouterItem } from "../../router";
  3. import React, { Suspense } from 'react';
  4. import WeComIcon from "@src/assets/images/publishContent/wxCom.svg?react";
  5. import WeGZHIcon from "@src/assets/images/publishContent/wxGzh.svg?react";
  6. import LogoIcon from "@src/assets/images/login/logo.svg?react";
  7. import { Outlet } from "react-router-dom";
  8. // Lazy load components
  9. const WeCom = React.lazy(() => import('./weCom/index'));
  10. const WeGZH = React.lazy(() => import('./weGZH/index'));
  11. // Loading fallback component
  12. // eslint-disable-next-line react-refresh/only-export-components
  13. const LazyLoadingFallback = () => (
  14. <div className="flex items-center justify-center flex-col h-[50vh]">
  15. <Icon component={LogoIcon} className="text-[50px] opacity-50" />
  16. <div className="text-gray-500 text-xl">加载中</div>
  17. </div>
  18. );
  19. // Wrapper component with Suspense
  20. // eslint-disable-next-line react-refresh/only-export-components
  21. const LazyComponent = ({ Component }: { Component: React.ComponentType<any> }) => (
  22. <Suspense fallback={<LazyLoadingFallback />}>
  23. <Component />
  24. </Suspense>
  25. );
  26. const demoRoutes: AdminRouterItem[] = [
  27. {
  28. path: 'publishContent',
  29. element: <Outlet />,
  30. meta: {
  31. label: "发布内容管理",
  32. title: "发布内容管理",
  33. key: "/publishContent",
  34. icon: <DesktopOutlined />,
  35. },
  36. children: [
  37. {
  38. path: 'wegzh',
  39. element: <LazyComponent Component={WeGZH} />,
  40. meta: {
  41. label: "公众号",
  42. title: "公众号",
  43. key: "/publishContent/wegzh",
  44. icon: <Icon component={WeGZHIcon} className="!text-[20px]" />,
  45. }
  46. },
  47. {
  48. path: 'wecom',
  49. element: <LazyComponent Component={WeCom} />,
  50. meta: {
  51. label: "企微",
  52. title: "企微",
  53. key: "/publishContent/wecom",
  54. icon: <Icon component={WeComIcon} className="!text-[20px]"/>,
  55. }
  56. },
  57. ]
  58. }
  59. ]
  60. export default demoRoutes