Browse Source

fix: 解决Dashboard.tsx中TalentUserInfo类型推断为never的问题

- 添加本地TalentUserInfo接口定义(基于后端Schema)
- 使用类型转换绕过InferResponseType的推断问题
- 修复远程打卡功能验证阻塞

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
yourname 14 hours ago
parent
commit
7d57293d52

+ 33 - 1
mini-ui-packages/rencai-dashboard-ui/src/pages/Dashboard/Dashboard.tsx

@@ -15,6 +15,36 @@ import type { InferResponseType } from 'hono'
 // 类型定义
 type PersonalInfoResponse = InferResponseType<typeof talentDashboardClient.personal.info.$get, 200>
 
+/**
+ * 人才用户信息类型
+ * 基于 TalentMeResponseSchema 定义(从后端Schema推断)
+ */
+interface TalentUserInfo {
+  id: number
+  username: string
+  userType: string
+  personId: number | null
+  phone: string | null
+  nickname: string | null
+  name: string | null
+  avatarFileId: number | null
+  personInfo: {
+    id: number
+    name: string
+    gender: string
+    idCard: string
+    disabilityId: string
+    disabilityType: string
+    disabilityLevel: string
+    phone: string
+    province: string
+    city: string
+    district: string | null
+    detailedAddress: string | null
+    jobStatus: number
+  } | null
+}
+
 // 模拟打卡数据(P2延期功能)
 interface ClockInData {
   status: '已打卡' | '未打卡'
@@ -42,7 +72,9 @@ const formatCurrentDate = (): string => {
 }
 
 const Dashboard: React.FC = () => {
-  const { user, refreshUser } = useAuth()
+  const { user: userFromAuth, refreshUser } = useAuth()
+  // 类型转换:因为 InferResponseType 在某些情况下推断为 never
+  const user = userFromAuth as TalentUserInfo | null
   const [_personalInfo, _setPersonalInfo] = React.useState<PersonalInfoResponse | null>(null)
   const [_loading, _setLoading] = React.useState(true)