Pārlūkot izejas kodu

perf: 优化代码

kuns 2 mēneši atpakaļ
vecāks
revīzija
34950bc71c

+ 11 - 14
app/(auth)/(tabs)/(account)/accountMainPage.tsx

@@ -1,14 +1,11 @@
-import { Button, ScrollView, StyleSheet } from 'react-native';
-import { View, Text } from 'react-native';
-import { useAuth } from '../../../../context/AuthProvider';
-import { useEffect } from 'react';
-import { SafeAreaView } from 'react-native-safe-area-context';
-import AccountMainPageComponent from '../../../../component/accountPages/accountMainPageComponent';
-
-export default function Account() {
-    return (
-        <View className="flex-1">
-            <AccountMainPageComponent />
-        </View>
-    );
-}
+import { Button, ScrollView, StyleSheet } from 'react-native';
+import { View, Text } from 'react-native';
+import AccountMainPageComponent from '../../../../component/accountPages/accountMainPageComponent';
+
+export default function Account() {
+    return (
+        <View className="flex-1">
+            <AccountMainPageComponent />
+        </View>
+    );
+}

+ 1 - 1
component/accountPages/userTermsPageComponent.tsx

@@ -22,7 +22,7 @@ const TermsSection: React.FC<TermsSectionProps> = ({ title, clauses }) => (
     ))}
   </View>
 );
-const UserTermsPageComponent: React.FC<{ onAgree: () => void }> = ({ onAgree }) => {
+const UserTermsPageComponent: React.FC = () => {
   const sections = [
     {
       clauses: [

+ 2 - 0
component/global/bookingTabViewComponent.tsx

@@ -32,6 +32,7 @@ const fetchReservationsAndStations = async () => {
 
         const reservations = reservationResponse.status === 'fulfilled' ? reservationResponse.value : [];
         const stations = allStationsResponse.status === 'fulfilled' ? allStationsResponse.value : [];
+        console.log('received data', reservationResponse);
 
         return {
             reservations: Array.isArray(reservations) ? reservations : [],
@@ -83,6 +84,7 @@ const processReservations = (reservations: any [], allStations: string [], isFut
             } else if (snapshot?.connector) {
                 stationInfo = findStationByConnectorId(validStations, snapshot.connector);
             }
+
             // 确保时间字段存在
             const bookTime = reservation.book_time ? new Date(reservation.book_time) : new Date();
             const actualEndTime = reservation.actual_end_time ? new Date(reservation.actual_end_time) : new Date();

+ 0 - 1
component/global/chargingRecord.tsx

@@ -63,7 +63,6 @@ const TabViewComponent: React.FC<TabViewComponentProps> = ({
         getCurrentLocation();
     }, []);
 
-    // 修复 FirstRoute 组件
     const FirstRoute = ({ tabItems, isLoading, currentLocation }: { 
             tabItems: TabItem[]; 
             isLoading?: boolean; 

+ 0 - 200
component/global/testingCar.tsx

@@ -1,200 +0,0 @@
-// interface CarBrand {
-//     name: string;
-//     logo?: any; // This would be the require() statement for the logo image
-// }
-
-// interface AlphabetSection {
-//     letter: string;
-//     brands: CarBrand[];
-// }
-// const carBrands: AlphabetSection[] = [
-//     {
-//         letter: 'A',
-//         brands: [
-//             { name: 'Audi', logo: require('../../assets/audi.png') },
-//             { name: 'Acura', logo: require('../../assets/acura.png') }
-//         ]
-//     },
-//     {
-//         letter: 'B',
-//         brands: [
-//             { name: 'BMW', logo: require('../../assets/bmw1.png') },
-//             { name: 'BYD', logo: require('../../assets/byd.png') }
-//         ]
-//     },
-//     {
-//         letter: 'C',
-//         brands: [
-//             { name: 'Chevrolet', logo: require('../../assets/chevrolet1.png') },
-//             { name: 'Cadillac', logo: require('../../assets/cadillac1.png') }
-//         ]
-//     },
-//     {
-//         letter: 'F',
-//         brands: [
-//             { name: 'Ford', logo: require('../../assets/ford.png') },
-//             { name: 'Fiat', logo: require('../../assets/fiat.png') }
-//         ]
-//     },
-//     {
-//         letter: 'G',
-//         brands: [{ name: 'Genesis', logo: require('../../assets/genesis.png') }]
-//     },
-//     {
-//         letter: 'H',
-//         brands: [
-//             { name: 'Honda', logo: require('../../assets/honda.png') },
-//             { name: 'Hyundai', logo: require('../../assets/hyundai.png') }
-//         ]
-//     },
-//     {
-//         letter: 'J',
-//         brands: [{ name: 'Jaguar', logo: require('../../assets/jaguar.png') }]
-//     },
-//     {
-//         letter: 'K',
-//         brands: [{ name: 'Kia', logo: require('../../assets/kia.png') }]
-//     },
-
-//     {
-//         letter: 'M',
-//         brands: [
-//             { name: 'Mercedes-Benz', logo: require('../../assets/benz.png') },
-//             { name: 'Mini', logo: require('../../assets/mini.png') },
-//             { name: 'Mazda', logo: require('../../assets/mazda.png') }
-//         ]
-//     },
-//     {
-//         letter: 'N',
-//         brands: [{ name: 'Nissan', logo: require('../../assets/nissan.png') }]
-//     },
-//     {
-//         letter: 'P',
-//         brands: [{ name: 'Porsche', logo: require('../../assets/porsche.png') }]
-//     },
-
-//     {
-//         letter: 'S',
-//         brands: [{ name: 'Subaru', logo: require('../../assets/subaru.png') }]
-//     },
-//     {
-//         letter: 'T',
-//         brands: [
-//             { name: 'Tesla', logo: require('../../assets/tesla.png') },
-//             { name: 'Toyota', logo: require('../../assets/toyota.png') }
-//         ]
-//     },
-//     {
-//         letter: 'V',
-//         brands: [
-//             { name: 'Volkswagen', logo: require('../../assets/volkswagen.png') },
-//             { name: 'Volvo', logo: require('../../assets/volvo.png') }
-//         ]
-//     }
-// ];
-
-// import React, { useEffect } from 'react';
-// import { View, Text, Image, Pressable, StyleSheet, SafeAreaView, ScrollView } from 'react-native';
-// import useVehicleStore from '../../providers/vehicle_store';
-// import { FlashList } from '@shopify/flash-list';
-// import { router } from 'expo-router';
-// import { PreviousPageBlackSvg } from './SVG';
-
-// const CarBrandSelector = () => {
-//     const { vehicleBrand, vehicleModel, licensePlate, setVehicleBrand, setVehicleModel, setLicensePlate } =
-//         useVehicleStore();
-
-//     useEffect(() => {
-//         console.log('vehicleBrand in zustand', vehicleBrand);
-//     }, [vehicleBrand]);
-//     const renderBrandItem = ({ item: brand }: { item: CarBrand }) => (
-//         <Pressable
-//             style={styles.brandItem}
-//             onPress={() => {
-//                 setVehicleBrand(brand.name);
-//                 console.log(brand.name);
-//             }}
-//         >
-//             <Image source={brand.logo} style={styles.logo} resizeMode="contain" />
-//             <Text style={styles.brandName}>{brand.name}</Text>
-//         </Pressable>
-//     );
-
-//     const renderAlphabetSection = ({ item: section }: { item: AlphabetSection }) => (
-//         <View>
-//             <View style={styles.letterHeader} className="h-9">
-//                 <Text style={styles.letterText}>{section.letter}</Text>
-//             </View>
-//             <View style={styles.brandRow}>{section.brands.map((brand) => renderBrandItem({ item: brand }))}</View>
-//         </View>
-//     );
-
-//     return (
-//         <SafeAreaView className="flex-1 bg-white" edges={['top', 'right', 'left']}>
-//             <ScrollView showsVerticalScrollIndicator={false} className="flex-1 mx-[5%]">
-//                 <View style={{ marginTop: 25 }}>
-//                     <Pressable
-//                         className="self-start"
-//                         onPress={() => {
-//                             if (router.canGoBack()) {
-//                                 router.back();
-//                             } else {
-//                                 router.replace('/accountMainPage');
-//                             }
-//                         }}
-//                     >
-//                         <PreviousPageBlackSvg />
-//                     </Pressable>
-//                     <Text
-//                         style={{
-//                             fontSize: 30,
-//                             marginTop: 25,
-//                             marginBottom: 10
-//                         }}
-//                     >
-//                         選擇品牌
-//                     </Text>
-//                 </View>
-//                 <View className="flex-1">
-//                     <FlashList
-//                         data={carBrands}
-//                         renderItem={renderAlphabetSection}
-//                         keyExtractor={(item) => item.letter}
-//                     />
-//                 </View>
-//             </ScrollView>
-//         </SafeAreaView>
-//     );
-// };
-
-// const styles = StyleSheet.create({
-//     letterHeader: {
-//         backgroundColor: '#E3F2F8',
-//         padding: 10,
-//         marginVertical: 10
-//     },
-//     letterText: {
-//         color: '#02677D',
-//         fontSize: 14,
-//         fontWeight: 'bold'
-//     },
-//     brandRow: {
-//         flexDirection: 'row',
-//         flexWrap: 'wrap'
-//     },
-//     brandItem: {
-//         width: '33.33%',
-//         alignItems: 'center',
-//         padding: 10
-//     },
-//     logo: {
-//         width: 80,
-//         height: 80
-//     },
-//     brandName: {
-//         marginTop: 5,
-//         textAlign: 'center'
-//     }
-// });
-
-// export default CarBrandSelector;

+ 1 - 1
service/chargeStationService.tsx

@@ -467,7 +467,6 @@ class ChargeStationService {
                 }
             );
             if (response.status === 200 || response.status === 201) {
-                console.log('received data from fetchOngoingChargingData at chargingStationService', response.data);
                 return response.data;
             } else {
                 console.log('invalid response');
@@ -485,6 +484,7 @@ class ChargeStationService {
                 }
             });
             if (response.status === 200 || response.status === 201) {
+
                 return response.data;
             } else {
                 console.log('invalid response');