|
@@ -8,162 +8,115 @@ import {IntellectualPropertyStats} from "@/components/IntellectualPropertyStats"
|
|
|
import ServerClient from "@/components/serverClient";
|
|
import ServerClient from "@/components/serverClient";
|
|
|
import {serverGet} from "@/utils/request";
|
|
import {serverGet} from "@/utils/request";
|
|
|
import AnimatedSection from "@/components/AnimatedSection";
|
|
import AnimatedSection from "@/components/AnimatedSection";
|
|
|
|
|
+import Honor from "@/components/about/Honor";
|
|
|
|
|
|
|
|
const features: Feature[] = [
|
|
const features: Feature[] = [
|
|
|
- {img: "/assets/home/8.png", title: "产品中心", subtitle: "PRODUCT_CENTER", href: "/products"},
|
|
|
|
|
- {img: "/assets/home/9.png", title: "解决方案", subtitle: "SOLUTION", href: "/solutions"},
|
|
|
|
|
- {img: "/assets/home/10.png", title: "新闻动态", subtitle: "NEWS", href: "/news"},
|
|
|
|
|
- {img: "/assets/home/11.png", title: "服务支持", subtitle: "SERVICE_SUPPORT", href: "/support"},
|
|
|
|
|
- {img: "/assets/home/12.png", title: "关于我们", subtitle: "ABOUT_US", href: "/about"},
|
|
|
|
|
|
|
+ {img: "/assets/home/8.png", title: "产品中心", subtitle: "PRODUCT_CENTER", href: "/products"},
|
|
|
|
|
+ {img: "/assets/home/9.png", title: "解决方案", subtitle: "SOLUTION", href: "/solutions"},
|
|
|
|
|
+ {img: "/assets/home/10.png", title: "新闻动态", subtitle: "NEWS", href: "/news"},
|
|
|
|
|
+ {img: "/assets/home/11.png", title: "服务支持", subtitle: "SERVICE_SUPPORT", href: "/support"},
|
|
|
|
|
+ {img: "/assets/home/12.png", title: "关于我们", subtitle: "ABOUT_US", href: "/about"},
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
-interface HardwareProduct {
|
|
|
|
|
- id: string;
|
|
|
|
|
- productCategoryName: string; // 产品大类名称(如:硬件产品/软件产品)
|
|
|
|
|
- productTypes: ProductType[]; // 产品类型列表(如:[感应设备, 检测设备, 数据采集])
|
|
|
|
|
- productTypeName: string;
|
|
|
|
|
- isCore: string;
|
|
|
|
|
- productId: string; // 实际数据中的“productId”(原接口写的“id”)
|
|
|
|
|
- productName: string;
|
|
|
|
|
- productCategory: string;
|
|
|
|
|
- productType: string;
|
|
|
|
|
- productUrl: string | null;
|
|
|
|
|
- productIntroduction: string;
|
|
|
|
|
- productModel: string;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
export default async function Home() {
|
|
export default async function Home() {
|
|
|
- const basicInfoRes = await serverGet<BasicInfo[]>("/webSite/getBasicInfo", {
|
|
|
|
|
- next: {
|
|
|
|
|
- revalidate: 1800
|
|
|
|
|
- },
|
|
|
|
|
- cache: "force-cache"
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- const res = await serverGet<ProductCategory[]>("/webSite/getProductCategoryAndType", null, {
|
|
|
|
|
- next: {
|
|
|
|
|
- revalidate: 180
|
|
|
|
|
- },
|
|
|
|
|
- cache: "force-cache"
|
|
|
|
|
- })
|
|
|
|
|
- if (res.code !== 200) {
|
|
|
|
|
- return <div>服务器错误</div>
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 优化后的筛选函数:硬件产品中 isCore=1 的数据,最多提取4条
|
|
|
|
|
- const filterHardwareCoreProducts = (
|
|
|
|
|
- data: ProductCategory[],
|
|
|
|
|
- maxCount: number = 4
|
|
|
|
|
- ): HardwareProduct[] => {
|
|
|
|
|
- // 边界处理:非数组返回空数组
|
|
|
|
|
- if (!Array.isArray(data)) return [];
|
|
|
|
|
-
|
|
|
|
|
- const coreProducts = [];
|
|
|
|
|
- // 第一层:遍历产品大类(软件产品/硬件产品)
|
|
|
|
|
- for (const category of data) {
|
|
|
|
|
- // 只处理硬件产品分类,且未收集满maxCount条时继续
|
|
|
|
|
- if (
|
|
|
|
|
- category.productCategoryName !== "硬件产品" ||
|
|
|
|
|
- !Array.isArray(category.productTypes) ||
|
|
|
|
|
- coreProducts.length >= maxCount
|
|
|
|
|
- ) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 第二层:遍历硬件产品下的类型(感应设备/检测设备/数据采集)
|
|
|
|
|
- for (const type of category.productTypes) {
|
|
|
|
|
- if (!Array.isArray(type.productCenters) || coreProducts.length >= maxCount) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 第三层:筛选当前类型下 isCore=1 的产品,且控制数量
|
|
|
|
|
- for (const item of type.productCenters) {
|
|
|
|
|
- if (item.isCore === "1" && coreProducts.length < maxCount) {
|
|
|
|
|
- coreProducts.push({
|
|
|
|
|
- ...item,
|
|
|
|
|
- id: item.productId, // 补全id(映射productId)
|
|
|
|
|
- productCategoryName: category.productCategoryName, // 补全产品大类名称
|
|
|
|
|
- productTypes: category.productTypes, // 补全产品类型列表
|
|
|
|
|
- productTypeName: type.productTypeName,
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- // 达到数量上限,立即终止当前层循环
|
|
|
|
|
- if (coreProducts.length >= maxCount) {
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return coreProducts;
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- const coreHardwareProducts = filterHardwareCoreProducts(res.data);
|
|
|
|
|
- console.log("硬件核心产品:", coreHardwareProducts);
|
|
|
|
|
-
|
|
|
|
|
- const basicInfo = basicInfoRes.data?.[0] || {
|
|
|
|
|
- address: "",
|
|
|
|
|
- companyProfile: "",
|
|
|
|
|
- companyProfileUrl: "",
|
|
|
|
|
- consultationHotline: "",
|
|
|
|
|
- email: "",
|
|
|
|
|
- hardwareIntroduction: "",
|
|
|
|
|
- id: "",
|
|
|
|
|
- qrCodeUrl: "",
|
|
|
|
|
- serviceHotline: "",
|
|
|
|
|
- softwareIntroduction: "",
|
|
|
|
|
- telephone: ""
|
|
|
|
|
- };
|
|
|
|
|
- return (
|
|
|
|
|
- <>
|
|
|
|
|
- <AnimatedSection effect="fade">
|
|
|
|
|
- <BannerCarousel/>
|
|
|
|
|
- </AnimatedSection>
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- <AnimatedSection effect="slide" direction="left">
|
|
|
|
|
- <div className="bg-[url('/assets/home/4.png')] w-full">
|
|
|
|
|
- <div className="custom-scrollbar overflow-x-auto">
|
|
|
|
|
- <div
|
|
|
|
|
- className="flex space-x-5 sm:space-x-6 md:space-x-8 min-w-max px-5 sm:px-6 md:px-10 mx-auto w-max">
|
|
|
|
|
- {features.map((f, idx) => (
|
|
|
|
|
- <FeatureCard key={idx} {...f} />
|
|
|
|
|
- ))}
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </AnimatedSection>
|
|
|
|
|
-
|
|
|
|
|
- {/*<AnimatedSection effect="fade">*/}
|
|
|
|
|
- {/* <div className='my-6 sm:my-10'>*/}
|
|
|
|
|
- {/* <MainTitle title="产品中心" titleLetter="PRODUCT_CENTER"/>*/}
|
|
|
|
|
- {/* </div>*/}
|
|
|
|
|
- {/*</AnimatedSection>*/}
|
|
|
|
|
-
|
|
|
|
|
- <AnimatedSection effect="fade">
|
|
|
|
|
- <div className='my-6 sm:my-10'>
|
|
|
|
|
- <MainTitle title="核心产品" titleLetter="CORE_PRODUCTS"/>
|
|
|
|
|
- </div>
|
|
|
|
|
- </AnimatedSection>
|
|
|
|
|
-
|
|
|
|
|
- {/*核心产品的产品介绍图*/}
|
|
|
|
|
- <AnimatedSection effect="slide" direction="right">
|
|
|
|
|
- <CoreProducts products={coreHardwareProducts}/>
|
|
|
|
|
- </AnimatedSection>
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- {/*软件产品模块*/}
|
|
|
|
|
- <AnimatedSection effect="slide" direction="left">
|
|
|
|
|
- <ProductionSoft softIntroduction={basicInfo.softwareIntroduction || ""}/>
|
|
|
|
|
- </AnimatedSection>
|
|
|
|
|
- {/* 知识产权统计模块 */}
|
|
|
|
|
- <AnimatedSection effect="scale">
|
|
|
|
|
- <IntellectualPropertyStats/>
|
|
|
|
|
- </AnimatedSection>
|
|
|
|
|
- {/* 服务器客户端模块 */}
|
|
|
|
|
- <AnimatedSection effect="scale">
|
|
|
|
|
- <ServerClient/>
|
|
|
|
|
- </AnimatedSection>
|
|
|
|
|
- </>
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ const basicInfoRes = await serverGet<BasicInfo[]>("/webSite/getBasicInfo", {
|
|
|
|
|
+ next: {
|
|
|
|
|
+ revalidate: 1800
|
|
|
|
|
+ },
|
|
|
|
|
+ cache: "force-cache"
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ const res = await serverGet<ProductCategory[]>("/webSite/getProductCategoryAndType", null, {
|
|
|
|
|
+ next: {
|
|
|
|
|
+ revalidate: 180
|
|
|
|
|
+ },
|
|
|
|
|
+ cache: "force-cache"
|
|
|
|
|
+ })
|
|
|
|
|
+ if (res.code !== 200) {
|
|
|
|
|
+ return <div>服务器错误</div>
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const honorRes = await serverGet<HonorInfo[]>("/webSite/getHonor", {
|
|
|
|
|
+ next: {
|
|
|
|
|
+ revalidate: 1800
|
|
|
|
|
+ },
|
|
|
|
|
+ cache: "force-cache"
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ const productList = res.data
|
|
|
|
|
+
|
|
|
|
|
+ const basicInfo = basicInfoRes.data?.[0] || {
|
|
|
|
|
+ address: "",
|
|
|
|
|
+ companyProfile: "",
|
|
|
|
|
+ companyProfileUrl: "",
|
|
|
|
|
+ consultationHotline: "",
|
|
|
|
|
+ email: "",
|
|
|
|
|
+ hardwareIntroduction: "",
|
|
|
|
|
+ id: "",
|
|
|
|
|
+ qrCodeUrl: "",
|
|
|
|
|
+ serviceHotline: "",
|
|
|
|
|
+ softwareIntroduction: "",
|
|
|
|
|
+ telephone: ""
|
|
|
|
|
+ };
|
|
|
|
|
+ return (
|
|
|
|
|
+ <>
|
|
|
|
|
+ <AnimatedSection effect="fade">
|
|
|
|
|
+ <BannerCarousel/>
|
|
|
|
|
+ </AnimatedSection>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <AnimatedSection effect="slide" direction="left">
|
|
|
|
|
+ <div className="bg-[url('/assets/home/4.png')] w-full">
|
|
|
|
|
+ <div className="custom-scrollbar overflow-x-auto">
|
|
|
|
|
+ <div
|
|
|
|
|
+ className="flex space-x-5 sm:space-x-6 md:space-x-8 min-w-max px-5 sm:px-6 md:px-10 mx-auto w-max">
|
|
|
|
|
+ {features.map((f, idx) => (
|
|
|
|
|
+ <FeatureCard key={idx} {...f} />
|
|
|
|
|
+ ))}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </AnimatedSection>
|
|
|
|
|
+
|
|
|
|
|
+ {/*<AnimatedSection effect="fade">*/}
|
|
|
|
|
+ {/* <div className='my-6 sm:my-10'>*/}
|
|
|
|
|
+ {/* <MainTitle title="产品中心" titleLetter="PRODUCT_CENTER"/>*/}
|
|
|
|
|
+ {/* </div>*/}
|
|
|
|
|
+ {/*</AnimatedSection>*/}
|
|
|
|
|
+
|
|
|
|
|
+ <AnimatedSection effect="fade">
|
|
|
|
|
+ <div className='my-6 sm:my-10'>
|
|
|
|
|
+ <MainTitle title="核心产品" titleLetter="CORE_PRODUCTS"/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </AnimatedSection>
|
|
|
|
|
+
|
|
|
|
|
+ {/*核心产品的产品介绍图*/}
|
|
|
|
|
+ <AnimatedSection effect="slide" direction="right">
|
|
|
|
|
+ <CoreProducts products={productList}/>
|
|
|
|
|
+ </AnimatedSection>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ {/*软件产品模块*/}
|
|
|
|
|
+ <AnimatedSection effect="slide" direction="left">
|
|
|
|
|
+ <ProductionSoft softIntroduction={basicInfo.softwareIntroduction || ""}/>
|
|
|
|
|
+ </AnimatedSection>
|
|
|
|
|
+ {/* 知识产权统计模块 */}
|
|
|
|
|
+ <AnimatedSection effect="scale">
|
|
|
|
|
+ <IntellectualPropertyStats/>
|
|
|
|
|
+ </AnimatedSection>
|
|
|
|
|
+ {/* 荣誉资质模块 */}
|
|
|
|
|
+ <AnimatedSection effect="scale">
|
|
|
|
|
+ <div className='my-6 sm:mt-10'>
|
|
|
|
|
+ <MainTitle title="荣誉资质" titleLetter="HONOR"/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className={"scroll-mt-10 max-w-4/5 mx-auto py-12 px-4"}>
|
|
|
|
|
+ <Honor honorList={honorRes.data}/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </AnimatedSection>
|
|
|
|
|
+ {/* 服务器客户端模块 */}
|
|
|
|
|
+ <AnimatedSection effect="scale">
|
|
|
|
|
+ <ServerClient/>
|
|
|
|
|
+ </AnimatedSection>
|
|
|
|
|
+ </>
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|