Преглед на файлове

✨ feat(route): update member page route to /member

- change user profile page route from /users/:id to /member
- update navigation link in home page to use new route
- adjust routes configuration to map /member to MemberPage

♻️ refactor(auth): export User type from AuthProvider

- export User type to allow reuse across components
- update MemberPage to import User type from AuthProvider instead of entity

💄 style(login): update eye icon for password visibility

- replace EyeOffIcon with EyeSlashIcon for better visual representation
- maintain same functionality while improving icon consistency
yourname преди 4 месеца
родител
ревизия
dcc320d2c7

+ 1 - 1
src/client/home/hooks/AuthProvider.tsx

@@ -12,7 +12,7 @@ import type {
 import { authClient } from '@/client/api';
 import type { InferResponseType, InferRequestType } from 'hono/client';
 
-type User = InferResponseType<typeof authClient.me.$get, 200>;
+export type User = InferResponseType<typeof authClient.me.$get, 200>;
 
 
 // 创建认证上下文

+ 1 - 1
src/client/home/pages/HomePage.tsx

@@ -14,7 +14,7 @@ const HomePage: React.FC = () => {
           <h1 className="text-xl font-bold">网站首页</h1>
           {user ? (
             <div className="flex items-center space-x-4">
-              <div className="flex items-center cursor-pointer" onClick={() => navigate(`/users/${user?.id}`)}>
+              <div className="flex items-center cursor-pointer" onClick={() => navigate(`/member`)}>
                 <div className="w-8 h-8 rounded-full bg-white text-blue-600 flex items-center justify-center mr-2">
                   <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
                     <path fillRule="evenodd" d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clipRule="evenodd" />

+ 2 - 2
src/client/home/pages/LoginPage.tsx

@@ -1,6 +1,6 @@
 import React, { useState } from 'react';
 import { useForm } from 'react-hook-form';
-import { EyeIcon, EyeOffIcon, UserIcon, LockClosedIcon } from '@heroicons/react/24/outline';
+import { EyeIcon, EyeSlashIcon, UserIcon, LockClosedIcon } from '@heroicons/react/24/outline';
 import { useNavigate } from 'react-router-dom';
 import { useAuth } from '@/client/home/hooks/AuthProvider';
 
@@ -82,7 +82,7 @@ const LoginPage: React.FC = () => {
                   onClick={() => setShowPassword(!showPassword)}
                 >
                   {showPassword ? (
-                    <EyeOffIcon className="h-5 w-5 text-gray-400" />
+                    <EyeSlashIcon className="h-5 w-5 text-gray-400" />
                   ) : (
                     <EyeIcon className="h-5 w-5 text-gray-400" />
                   )}

+ 2 - 3
src/client/home/pages/MemberPage.tsx

@@ -4,11 +4,10 @@ import React, { useEffect, useState } from 'react';
 import { UserIcon, PencilIcon } from '@heroicons/react/24/outline';
 import { useParams, useNavigate } from 'react-router-dom';
 import { userClient } from '@/client/api';
-import { useAuth } from '@/client/home/hooks/AuthProvider';
-import type { UserEntity } from '@/server/modules/users/user.entity';
+import { useAuth, User } from '@/client/home/hooks/AuthProvider';
 
 const MemberPage: React.FC = () => {
-  const [user, setUser] = useState<UserEntity | null>(null);
+  const [user, setUser] = useState<User | null>(null);
   const [loading, setLoading] = useState(true);
   const { id: userId } = useParams<{ id: string }>();
   const id = Number(userId);

+ 6 - 6
src/client/home/routes.tsx

@@ -6,9 +6,13 @@ import { NotFoundPage } from './components/NotFoundPage';
 import HomePage from './pages/HomePage';
 import { MainLayout } from './layouts/MainLayout';
 import LoginPage from './pages/LoginPage';
-import UserProfilePage from './pages/MemberPage';
+import MemberPage from './pages/MemberPage';
 
 export const router = createBrowserRouter([
+  {
+    path: '/',
+    element: <HomePage />
+  },
   {
     path: '/login',
     element: <LoginPage />
@@ -23,11 +27,7 @@ export const router = createBrowserRouter([
     children: [
       {
         path: '',
-        element: <HomePage />
-      },
-      {
-        path: 'users/:id',
-        element: <UserProfilePage />
+        element: <MemberPage />
       },
       {
         path: '*',