Просмотр исходного кода

♻️ refactor(components): change UserStatsCard export style from default to named

- 修改UserStatsCard组件导出方式为命名导出
- 更新HomePage中对UserStatsCard的导入方式

♻️ refactor(server): format home route handlers

- 移除路由处理函数后的分号,统一代码格式
- 调整openapi方法调用格式,移除多余空格
yourname 8 месяцев назад
Родитель
Сommit
a8a7017cce

+ 2 - 4
src/client/mobile/components/UserStatsCard.tsx

@@ -9,7 +9,7 @@ interface UserStatsCardProps {
   };
 }
 
-const UserStatsCard: React.FC<UserStatsCardProps> = ({ stats }) => {
+export const UserStatsCard: React.FC<UserStatsCardProps> = ({ stats }) => {
   const statsData = [
     {
       title: '积分余额',
@@ -60,6 +60,4 @@ const UserStatsCard: React.FC<UserStatsCardProps> = ({ stats }) => {
       </div>
     </div>
   );
-};
-
-export default UserStatsCard;
+};

+ 2 - 1
src/client/mobile/pages/HomePage.tsx

@@ -3,9 +3,10 @@ import { useNavigate } from 'react-router-dom';
 import { useHomeData } from '../hooks/useHomeData';
 import { useAuth } from '../hooks/AuthProvider';
 import { EnhancedCarousel } from '../components/EnhancedCarousel';
-import UserStatsCard from '../components/UserStatsCard';
+import { UserStatsCard } from '../components/UserStatsCard';
 import { SkeletonLoader, BannerSkeleton, ListItemSkeleton, UserStatsSkeleton } from '../components/SkeletonLoader';
 import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
+import NewHomePage from './NewHomePage';
 
 // 创建QueryClient实例
 const queryClient = new QueryClient({

+ 5 - 5
src/server/api/home/index.ts

@@ -94,10 +94,10 @@ const searchRoute = createRoute({
 });
 
 // 路由实现
-const app = new OpenAPIHono<AuthContext>();
+const app = new OpenAPIHono<AuthContext>()
 
 // 获取首页数据
-app.openapi(getHomeRoute, async (c) => {
+.openapi(getHomeRoute, async (c) => {
   try {
     const { limit = 10 } = c.req.valid('query');
     const user = c.get('user');
@@ -117,10 +117,10 @@ app.openapi(getHomeRoute, async (c) => {
     const { message = '获取首页数据失败' } = error as Error;
     return c.json({ code: 500, message }, 500);
   }
-});
+})
 
 // 搜索功能
-app.openapi(searchRoute, async (c) => {
+.openapi(searchRoute, async (c) => {
   try {
     const { keyword, type, limit } = c.req.valid('query');
     const searchService = new HomeService(AppDataSource);
@@ -131,6 +131,6 @@ app.openapi(searchRoute, async (c) => {
     const { message = '搜索失败' } = error as Error;
     return c.json({ code: 500, message }, 500);
   }
-});
+})
 
 export default app;