page.tsx 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import Image from "next/image"
  2. import MainTitle from "@/components/MainTitle"
  3. import ProductMenu from "@/components/products/ProductMenuClient"
  4. import {serverGet} from "@/utils/request";
  5. import AnimatedSection from "@/components/AnimatedSection";
  6. import React, {Suspense} from "react";
  7. export default async function ProductShowcase() {
  8. const res = await serverGet<ProductCategory[]>("/webSite/getProductCategoryAndType", null, {
  9. next: {
  10. revalidate: 180
  11. },
  12. cache: "force-cache"
  13. })
  14. if (res.code !== 200) {
  15. return <div>服务器错误</div>
  16. }
  17. const hardwareProductList: { key: string; label: string }[] = []
  18. for (let i = 0; i < res.data.length; i++) {
  19. const a = res.data[i].productTypes.map((item) => ({
  20. key: item.productTypeName,
  21. label: item.productTypeName,
  22. // children: item.productCenters.map((center) => ({
  23. // key: center.productCenterName,
  24. // label: center.productCenterName,
  25. // }))
  26. }))
  27. hardwareProductList.push(...a);
  28. hardwareProductList.reverse();
  29. // if (res.data[i].productCategoryName === "硬件产品") {
  30. // hardwareProductList = res.data[i].productTypes.map((item) => ({
  31. // key: item.productTypeName,
  32. // label: item.productTypeName,
  33. // // children: item.productCenters.map((center) => ({
  34. // // key: center.productCenterName,
  35. // // label: center.productCenterName,
  36. // // }))
  37. // }))
  38. // }else if(res.data[i].productCategoryName === "软件产品"){
  39. // softwareProductList = res.data[i].productTypes.map((item) => ({
  40. // key: item.productTypeName,
  41. // label: item.productTypeName,
  42. // // children: item.productCenters.map((center) => ({
  43. // // key: center.productCenterName,
  44. // // label: center.productCenterName,
  45. // // }))
  46. // }))
  47. // }
  48. }
  49. const products = res.data.flatMap((item) => item.productTypes.flatMap((type) => type.productCenters))
  50. return (
  51. <>
  52. <AnimatedSection effect="slide" direction="left">
  53. <div>
  54. <div className="w-full h-full flex items-center justify-center text-white text-4xl font-bold">
  55. <Image src={"/assets/productions/1.png"} alt={"产品中心"} width={1920} height={1080}/>
  56. </div>
  57. </div>
  58. </AnimatedSection>
  59. <div className="py-6 sm:py-10">
  60. <MainTitle title={"产品中心"}/>
  61. </div>
  62. <AnimatedSection effect="slide" direction="right">
  63. <Suspense fallback={<div>加载中...</div>}>
  64. <ProductMenu menuItems={hardwareProductList} products={products}/>
  65. </Suspense>
  66. </AnimatedSection>
  67. {/*<AnimatedSection effect="slide" direction="right">*/}
  68. {/* <Suspense fallback={<div>加载中...</div>}>*/}
  69. {/* <ProductMenu menuItems={softwareProductList} products={products}/>*/}
  70. {/* </Suspense>*/}
  71. {/*</AnimatedSection>*/}
  72. {/*<AnimatedSection effect="slide" direction="right">*/}
  73. {/* <ProductionNew/>*/}
  74. {/*</AnimatedSection>*/}
  75. </>
  76. )
  77. }