|
|
@@ -1,40 +1,3 @@
|
|
|
-import React, { useEffect } from 'react'
|
|
|
-import { View } from '@tarojs/components'
|
|
|
-import Taro from '@tarojs/taro'
|
|
|
-import DashboardPage from '@d8d/rencai-dashboard-ui/pages/Dashboard/Dashboard'
|
|
|
-import { AuthProvider, useAuth } from '@d8d/rencai-auth-ui/hooks'
|
|
|
-
|
|
|
-// 内部组件:使用认证状态
|
|
|
-function IndexPageContent() {
|
|
|
- const { isLoggedIn, loading } = useAuth()
|
|
|
-
|
|
|
- useEffect(() => {
|
|
|
- // 如果未登录且不在加载中,跳转到登录页
|
|
|
- if (!loading && !isLoggedIn) {
|
|
|
- Taro.redirectTo({
|
|
|
- url: '/pages/login/index'
|
|
|
- })
|
|
|
- }
|
|
|
- }, [isLoggedIn, loading])
|
|
|
-
|
|
|
- // 加载中显示空白
|
|
|
- if (loading) {
|
|
|
- return <View className="min-h-screen bg-white" />
|
|
|
- }
|
|
|
-
|
|
|
- // 未登录不显示内容
|
|
|
- if (!isLoggedIn) {
|
|
|
- return <View className="min-h-screen bg-white" />
|
|
|
- }
|
|
|
-
|
|
|
- return <DashboardPage />
|
|
|
-}
|
|
|
-
|
|
|
-// 首页 - 用AuthProvider包装
|
|
|
-export default function Index() {
|
|
|
- return (
|
|
|
- <AuthProvider>
|
|
|
- <IndexPageContent />
|
|
|
- </AuthProvider>
|
|
|
- )
|
|
|
-}
|
|
|
+// 桥接文件:从 @d8d/rencai-dashboard-ui 包导Dashboard页面
|
|
|
+import Dashboard from '@d8d/rencai-dashboard-ui/pages/Dashboard/Dashboard'
|
|
|
+export default Dashboard
|