Browse Source

数据联调

zq940222 6 months ago
parent
commit
11d43f6d43
3 changed files with 7 additions and 11 deletions
  1. 5 5
      src/components/Features.tsx
  2. 2 2
      src/components/Services.tsx
  3. 0 4
      src/services/api.ts

+ 5 - 5
src/components/Features.tsx

@@ -14,7 +14,7 @@ import {extractSubstring} from "@/services/api.ts";
 import axios from "axios";
 
 interface FeatureProps {
-  title: string;
+  name: string;
   description: string;
   image: string;
 }
@@ -72,7 +72,7 @@ export const Features = () => {
             userWebsiteId: userWebsiteId
           }
         });
-        features = response2.data.data.map((item, index) => {
+        features = response2.data.data.map((item:FeatureProps, index:number) => {
           return {
             title: item.name,
             description: item.description.substring(0, 200) + '...',
@@ -119,10 +119,10 @@ export const Features = () => {
       </div>
 
       <div className="grid md:grid-cols-2 lg:grid-cols-3 gap-8">
-        {features.map(({ title, description, image }: FeatureProps) => (
-          <Card key={title}>
+        {features.map(({ name, description, image }: FeatureProps) => (
+          <Card key={name}>
             <CardHeader>
-              <CardTitle>{title}</CardTitle>
+              <CardTitle>{name}</CardTitle>
             </CardHeader>
 
             <CardContent>{description}</CardContent>

+ 2 - 2
src/components/Services.tsx

@@ -51,9 +51,9 @@ export const Services = () => {
             userWebsiteId: userWebsiteId
           }
         });
-        serviceList = response2.data.data.map((item, index) => {
+        serviceList = response2.data.data.map((item:ServiceProps, index:number) => {
           return {
-            title: item.name,
+            title: item.title,
             content: item.content.substring(0, 200) + '...',
             icon: iconList[index % iconList.length],
           }

+ 0 - 4
src/services/api.ts

@@ -9,8 +9,4 @@ export function extractSubstring(str: string) {
         }
     }
     return ''; // 如果没有找到匹配,返回空字符串
-}
-export function getImageUrl(index) {
-    // 使用 index 对 3 取余数,循环分配图片
-    return this.images[index % this.images.length];
 }