feat(HomePage): 已登录用户访问首页展示个人中心内容
- HomePage: 添加条件渲染,已登录时展示 Center 组件 - 重构 Center 目录结构,合并 Center.tsx 到 index.tsx - 重命名 CenterDashboard 为 Center(lazy-components, homeRoutes) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -28,7 +28,7 @@ export const homeRoutes = [
|
|||||||
// 个人中心 - /home/center
|
// 个人中心 - /home/center
|
||||||
{
|
{
|
||||||
path: 'center',
|
path: 'center',
|
||||||
component: lazyComponents.CenterDashboard,
|
component: lazyComponents.Center,
|
||||||
protection: PROTECTION_MODES.MODAL,
|
protection: PROTECTION_MODES.MODAL,
|
||||||
meta: {
|
meta: {
|
||||||
title: '个人中心',
|
title: '个人中心',
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const lazyComponents = {
|
|||||||
// Home 模块
|
// Home 模块
|
||||||
// ⚡ 直接引用 HomePage,无需中间层(静态页面不需要骨架屏)
|
// ⚡ 直接引用 HomePage,无需中间层(静态页面不需要骨架屏)
|
||||||
HomePage: React.lazy(() => import('@views/Home/HomePage')),
|
HomePage: React.lazy(() => import('@views/Home/HomePage')),
|
||||||
CenterDashboard: React.lazy(() => import('@views/Center')),
|
Center: React.lazy(() => import('@views/Center')),
|
||||||
ProfilePage: React.lazy(() => import('@views/Profile/ProfilePage')),
|
ProfilePage: React.lazy(() => import('@views/Profile/ProfilePage')),
|
||||||
// 价值论坛 - 我的积分页面
|
// 价值论坛 - 我的积分页面
|
||||||
ForumMyPoints: React.lazy(() => import('@views/Profile')),
|
ForumMyPoints: React.lazy(() => import('@views/Profile')),
|
||||||
@@ -56,7 +56,7 @@ export const lazyComponents = {
|
|||||||
*/
|
*/
|
||||||
export const {
|
export const {
|
||||||
HomePage,
|
HomePage,
|
||||||
CenterDashboard,
|
Center,
|
||||||
ProfilePage,
|
ProfilePage,
|
||||||
ForumMyPoints,
|
ForumMyPoints,
|
||||||
SettingsPage,
|
SettingsPage,
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
// src/views/Center/index.js
|
|
||||||
// 入口文件,导出 Center 组件
|
|
||||||
|
|
||||||
export { default } from './Center';
|
|
||||||
@@ -13,12 +13,12 @@ import ForumCenter from '@views/Profile/components/ForumCenter';
|
|||||||
import { THEME } from '@views/Profile/components/MarketDashboard/constants';
|
import { THEME } from '@views/Profile/components/MarketDashboard/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CenterDashboard 组件
|
* Center 组件
|
||||||
* 个人中心仪表板主页面
|
* 个人中心仪表板主页面
|
||||||
*
|
*
|
||||||
* 注意:右侧 WatchSidebar 已移至全局 GlobalSidebar(在 MainLayout 中渲染)
|
* 注意:右侧 WatchSidebar 已移至全局 GlobalSidebar(在 MainLayout 中渲染)
|
||||||
*/
|
*/
|
||||||
const CenterDashboard: React.FC = () => {
|
const Center: React.FC = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box bg={THEME.bg.primary} minH="100vh" overflowX="hidden">
|
<Box bg={THEME.bg.primary} minH="100vh" overflowX="hidden">
|
||||||
@@ -42,4 +42,4 @@ const CenterDashboard: React.FC = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CenterDashboard;
|
export default Center;
|
||||||
@@ -16,6 +16,7 @@ import { FeaturedFeatureCard } from './components/FeaturedFeatureCard';
|
|||||||
import { FeatureCard } from './components/FeatureCard';
|
import { FeatureCard } from './components/FeatureCard';
|
||||||
import MiniProgramLauncher from '@/components/MiniProgramLauncher';
|
import MiniProgramLauncher from '@/components/MiniProgramLauncher';
|
||||||
import { isMobileDevice } from '@/components/MiniProgramLauncher/hooks/useWechatEnvironment';
|
import { isMobileDevice } from '@/components/MiniProgramLauncher/hooks/useWechatEnvironment';
|
||||||
|
import Center from '@views/Center';
|
||||||
import '@/styles/home-animations.css';
|
import '@/styles/home-animations.css';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,7 +24,7 @@ import '@/styles/home-animations.css';
|
|||||||
* 展示平台核心功能,引导用户探索各个功能模块
|
* 展示平台核心功能,引导用户探索各个功能模块
|
||||||
*/
|
*/
|
||||||
const HomePage: React.FC = () => {
|
const HomePage: React.FC = () => {
|
||||||
const { user, isAuthenticated } = useAuth();
|
const { user, isAuthenticated, isLoading } = useAuth();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { track } = usePostHogTrack();
|
const { track } = usePostHogTrack();
|
||||||
|
|
||||||
@@ -83,6 +84,17 @@ const HomePage: React.FC = () => {
|
|||||||
// 移动端判断(用于显示小程序入口)
|
// 移动端判断(用于显示小程序入口)
|
||||||
const isMobile = isMobileDevice();
|
const isMobile = isMobileDevice();
|
||||||
|
|
||||||
|
// 等待认证状态确认(避免闪烁)
|
||||||
|
if (isLoading) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 已登录直接渲染个人中心
|
||||||
|
if (isAuthenticated && user) {
|
||||||
|
return <Center />;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 未登录渲染首页内容
|
||||||
return (
|
return (
|
||||||
<Box minH="100%">
|
<Box minH="100%">
|
||||||
{/* Hero Section - 深色科技风格,自适应容器高度 */}
|
{/* Hero Section - 深色科技风格,自适应容器高度 */}
|
||||||
|
|||||||
Reference in New Issue
Block a user