Explorar o código

🐛 fix(homepage): 修复未登录用户黑屏问题

- 修改加载状态判断条件,移除对homeData的依赖
- 添加错误状态处理页面,显示加载失败提示和重新加载按钮
- 添加未登录状态处理页面,引导用户登录

💄 style(chat): 优化遮罩层样式写法

- 将bg-black和bg-opacity合并为更简洁的bg-black/50语法
yourname hai 7 meses
pai
achega
b4f8694722

+ 2 - 2
src/client/mobile/components/SmartAssistant/ChatWindow.tsx

@@ -52,8 +52,8 @@ export const ChatWindow: React.FC<ChatWindowProps> = ({
     <>
     <>
       {/* 遮罩层 */}
       {/* 遮罩层 */}
       <div
       <div
-        className={`fixed inset-0 bg-black transition-opacity duration-300 z-40 ${
-          isOpen ? 'bg-opacity-50' : 'bg-opacity-0 pointer-events-none'
+        className={`fixed inset-0 transition-opacity duration-300 z-40 ${
+          isOpen ? 'bg-black/50' : 'bg-black/0 pointer-events-none'
         }`}
         }`}
         onClick={onClose}
         onClick={onClose}
       />
       />

+ 45 - 2
src/client/mobile/pages/NewHomePage.tsx

@@ -226,8 +226,8 @@ const NewHomePage: React.FC = () => {
     isError: isIconsError
     isError: isIconsError
   } = useHomeIcons();
   } = useHomeIcons();
 
 
-  // 加载状态
-  if (isLoading || !homeData || isIconsLoading) {
+  // 加载状态 - 修复未登录用户黑屏问题
+  if (isLoading || isIconsLoading) {
     return (
     return (
       <div className="min-h-screen" style={{ backgroundColor: COLORS.ink.light }}>
       <div className="min-h-screen" style={{ backgroundColor: COLORS.ink.light }}>
         <HeaderSkeleton />
         <HeaderSkeleton />
@@ -239,6 +239,49 @@ const NewHomePage: React.FC = () => {
     );
     );
   }
   }
 
 
+  // 错误状态处理
+  if (isError || isIconsError) {
+    return (
+      <div className="min-h-screen bg-white flex items-center justify-center">
+        <div className="text-center p-8">
+          <h2 className="text-xl font-bold text-gray-800 mb-2">加载失败</h2>
+          <p className="text-gray-600 mb-4">请检查网络连接或重新登录</p>
+          <button
+            onClick={() => window.location.reload()}
+            className="px-4 py-2 bg-blue-600 text-white rounded-full"
+          >
+            重新加载
+          </button>
+        </div>
+      </div>
+    );
+  }
+
+  // 未登录状态处理
+  if (!user) {
+    return (
+      <div className="min-h-screen bg-white">
+        <header className="px-4 py-4 bg-white shadow-sm">
+          <div className="flex items-center justify-between mb-3">
+            <div className="flex items-center space-x-2">
+              <img src="/yizhihuilogo.png" alt="银龄智慧" className="h-8 w-auto" />
+              <h1 className="font-bold text-xl">银龄智慧</h1>
+            </div>
+          </div>
+          <div className="text-center py-8">
+            <h2 className="text-lg font-bold mb-4">请先登录</h2>
+            <button
+              onClick={() => navigate('/login')}
+              className="px-6 py-2 bg-blue-600 text-white rounded-full"
+            >
+              立即登录
+            </button>
+          </div>
+        </header>
+      </div>
+    );
+  }
+
   // 数据转换与排序
   // 数据转换与排序
   const recommendedJobs = transformJobs(homeData.recommendedJobs || [])
   const recommendedJobs = transformJobs(homeData.recommendedJobs || [])
     .sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())
     .sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())