|
|
@@ -1,17 +1,133 @@
|
|
|
-import { hc } from 'hono/client'
|
|
|
+import { hc } from 'hono/client';
|
|
|
+import type {
|
|
|
+ AuthRoutes,
|
|
|
+ UserRoutes,
|
|
|
+ RoleRoutes,
|
|
|
+ FileRoutes,
|
|
|
+ CompanyRoutes,
|
|
|
+ JobRoutes,
|
|
|
+ ApplicationRoutes,
|
|
|
+ FavoriteRoutes,
|
|
|
+ ViewRoutes,
|
|
|
+ CompanyImageRoutes,
|
|
|
+ SilverTalentsRoutes,
|
|
|
+ ElderlyUniversityRoutes,
|
|
|
+ PolicyNewsRoutes,
|
|
|
+ UserPreferenceRoutes,
|
|
|
+ HomeRoutes,
|
|
|
+ SilverUsersKnowledgesRoutes,
|
|
|
+ SilverUsersKnowledgeCategoriesRoutes,
|
|
|
+ SilverUsersKnowledgeTagsRoutes,
|
|
|
+ SilverUsersKnowledgeStatsRoutes,
|
|
|
+ SilverUsersKnowledgeInteractionsRoutes,
|
|
|
+ SilverUsersKnowledgeRankingsRoutes,
|
|
|
+ SilverTalentsAdminRoutes,
|
|
|
+ MyCompanyRoutes
|
|
|
+} from '@/server/api';
|
|
|
import { axiosFetch } from './utils/axios'
|
|
|
-import { type SilverTalentsAdminRoutes } from '@/server/api'
|
|
|
|
|
|
-// 银龄库管理客户端
|
|
|
-export const silverTalentsAdminClient = hc<SilverTalentsAdminRoutes>('/api/v1', {
|
|
|
+// 客户端实例 - 严格按照RPC规范命名
|
|
|
+export const authClient = hc<AuthRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+}).api.v1.auth;
|
|
|
+
|
|
|
+export const userClient = hc<UserRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+}).api.v1.users;
|
|
|
+
|
|
|
+export const roleClient = hc<RoleRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+}).api.v1.roles;
|
|
|
+
|
|
|
+export const fileClient = hc<FileRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+}).api.v1.files;
|
|
|
+
|
|
|
+// 企业信息客户端 - 新增
|
|
|
+export const myCompanyClient = hc<MyCompanyRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+}).api.v1['companies'].my;
|
|
|
+
|
|
|
+// 银龄岗具体资源客户端(调整为标准格式)
|
|
|
+export const companyClient = hc<CompanyRoutes>('/', {
|
|
|
fetch: axiosFetch,
|
|
|
-}).api.v1.admin['silver-talents']
|
|
|
+}).api.v1['silver-jobs'].companies;
|
|
|
|
|
|
-// 类型定义
|
|
|
-export type SilverTalentAdminList = InferResponseType<typeof silverTalentsAdminClient.$get, 200>
|
|
|
-export type SilverTalentAdminDetail = InferResponseType<typeof silverTalentsAdminClient[':id'].$get, 200>
|
|
|
-export type SilverTalentAdminStats = InferResponseType<typeof silverTalentsAdminClient.stats.$get, 200>
|
|
|
-export type UpdateSilverTalentRequest = InferRequestType<typeof silverTalentsAdminClient[':id'].$put>['json']
|
|
|
-export type UpdateCertificationRequest = InferRequestType<typeof silverTalentsAdminClient[':id']['certification'].$patch>['json']
|
|
|
+export const jobClient = hc<JobRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+}).api.v1['silver-jobs'].jobs;
|
|
|
+
|
|
|
+export const applicationClient = hc<ApplicationRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+}).api.v1['silver-jobs'].applications;
|
|
|
+
|
|
|
+export const favoriteClient = hc<FavoriteRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+}).api.v1['silver-jobs'].favorites;
|
|
|
+
|
|
|
+export const viewClient = hc<ViewRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+}).api.v1['silver-jobs'].views;
|
|
|
|
|
|
-import type { InferResponseType, InferRequestType } from 'hono/client'
|
|
|
+export const companyImageClient = hc<CompanyImageRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+}).api.v1['silver-jobs']['company-images'];
|
|
|
+
|
|
|
+// 银龄用户资源客户端 - 重构为集中的对象,避免过深实例化
|
|
|
+export const silverUsersClient = {
|
|
|
+ knowledges: hc<SilverUsersKnowledgesRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+ }).api.v1['silver-users'].knowledges,
|
|
|
+
|
|
|
+ ['knowledge-categories']: hc<SilverUsersKnowledgeCategoriesRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+ }).api.v1['silver-users']['knowledge-categories'],
|
|
|
+
|
|
|
+ ['knowledge-tags']: hc<SilverUsersKnowledgeTagsRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+ }).api.v1['silver-users']['knowledge-tags'],
|
|
|
+
|
|
|
+ ['knowledge-stats']: hc<SilverUsersKnowledgeStatsRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+ }).api.v1['silver-users']['knowledge-stats'],
|
|
|
+
|
|
|
+ ['knowledge-interactions']: hc<SilverUsersKnowledgeInteractionsRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+ }).api.v1['silver-users']['knowledge-interactions'],
|
|
|
+
|
|
|
+ ['knowledge-rankings']: hc<SilverUsersKnowledgeRankingsRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+ }).api.v1['silver-users']['knowledge-rankings'],
|
|
|
+
|
|
|
+ profiles: hc<any>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+ }).api.v1['silver-users'].profiles
|
|
|
+};
|
|
|
+
|
|
|
+// 其他资源客户端
|
|
|
+export const elderlyUniversityClient = hc<ElderlyUniversityRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+}).api.v1['elderly-universities'];
|
|
|
+
|
|
|
+export const policyNewsClient = hc<PolicyNewsRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+}).api.v1['policy-news'];
|
|
|
+
|
|
|
+export const userPreferenceClient = hc<UserPreferenceRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+}).api.v1['user-preferences'];
|
|
|
+
|
|
|
+// 首页API客户端
|
|
|
+export const homeClient = hc<HomeRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+}).api.v1.home;
|
|
|
+
|
|
|
+export const silverTalentsClient = hc<SilverTalentsRoutes>('/', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+}).api.v1['silver-talents']
|
|
|
+
|
|
|
+
|
|
|
+// 银龄库管理客户端
|
|
|
+export const silverTalentsAdminClient = hc<SilverTalentsAdminRoutes>('/api/v1', {
|
|
|
+ fetch: axiosFetch,
|
|
|
+}).api.v1.admin['silver-talents']
|