|
@@ -1,14 +1,46 @@
|
|
|
import { createContext, useContext, PropsWithChildren } from 'react'
|
|
import { createContext, useContext, PropsWithChildren } from 'react'
|
|
|
import Taro from '@tarojs/taro'
|
|
import Taro from '@tarojs/taro'
|
|
|
-import { InferResponseType, InferRequestType } from 'hono'
|
|
|
|
|
import { QueryClient, useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
|
import { QueryClient, useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
|
|
import { enterpriseAuthClient } from '../api'
|
|
import { enterpriseAuthClient } from '../api'
|
|
|
|
|
|
|
|
-// 用户类型定义 - 使用企业用户认证
|
|
|
|
|
-export type User = InferResponseType<typeof enterpriseAuthClient.me.$get, 200>
|
|
|
|
|
-type LoginRequest = InferRequestType<typeof enterpriseAuthClient.login.$post>['json']
|
|
|
|
|
|
|
+// 登录请求类型
|
|
|
|
|
+interface LoginRequest {
|
|
|
|
|
+ phone: string
|
|
|
|
|
+ password: string
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 用户类型定义 - 企业用户
|
|
|
|
|
+export interface User {
|
|
|
|
|
+ id: number
|
|
|
|
|
+ username: string
|
|
|
|
|
+ phone: string | null
|
|
|
|
|
+ email: string | null
|
|
|
|
|
+ nickname: string | null
|
|
|
|
|
+ name: string | null
|
|
|
|
|
+ avatarFileId: number | null
|
|
|
|
|
+ avatarFile?: {
|
|
|
|
|
+ id: number
|
|
|
|
|
+ name: string
|
|
|
|
|
+ fullUrl: string
|
|
|
|
|
+ type: string | null
|
|
|
|
|
+ size: number | null
|
|
|
|
|
+ } | null
|
|
|
|
|
+ companyId: number | null
|
|
|
|
|
+ company?: {
|
|
|
|
|
+ id: number
|
|
|
|
|
+ companyName: string
|
|
|
|
|
+ contactPerson: string | null
|
|
|
|
|
+ contactPhone: string | null
|
|
|
|
|
+ } | null
|
|
|
|
|
+ createdAt: string
|
|
|
|
|
+ updatedAt: string
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 企业用户注册可能由管理员创建,前端不提供注册接口
|
|
// 企业用户注册可能由管理员创建,前端不提供注册接口
|
|
|
-type RegisterRequest = { username: string; password: string }
|
|
|
|
|
|
|
+interface RegisterRequest {
|
|
|
|
|
+ username: string
|
|
|
|
|
+ password: string
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
export interface AuthContextType {
|
|
export interface AuthContextType {
|
|
|
user: User | null
|
|
user: User | null
|