|
|
@@ -1,47 +1,40 @@
|
|
|
-import { hc } from 'hono/client';
|
|
|
-import type { AuthRoutes, UserRoutes, RoleRoutes, FileRoutes, MembershipPlanRoutes, PaymentRoutes } from '@/server/api';
|
|
|
+import { hc } from 'hono/client'
|
|
|
+import type {
|
|
|
+ AuthRoutes, UserRoutes, RoleRoutes,
|
|
|
+ FileRoutes, MembershipPlanRoutes, PaymentRoutes
|
|
|
+} from '@/server/api';
|
|
|
import { axiosFetch } from './utils/axios-fetch';
|
|
|
|
|
|
-// 管理后台客户端
|
|
|
-export const authClient = hc<AuthRoutes>('/api/v1', {
|
|
|
+export const authClient = hc<AuthRoutes>('/', {
|
|
|
fetch: axiosFetch,
|
|
|
}).api.v1.auth;
|
|
|
|
|
|
-export const userClient = hc<UserRoutes>('/api/v1', {
|
|
|
+export const userClient = hc<UserRoutes>('/', {
|
|
|
fetch: axiosFetch,
|
|
|
}).api.v1.users;
|
|
|
|
|
|
-export const roleClient = hc<RoleRoutes>('/api/v1', {
|
|
|
+export const roleClient = hc<RoleRoutes>('/', {
|
|
|
fetch: axiosFetch,
|
|
|
}).api.v1.roles;
|
|
|
|
|
|
-export const fileClient = hc<FileRoutes>('/api/v1', {
|
|
|
+export const fileClient = hc<FileRoutes>('/', {
|
|
|
fetch: axiosFetch,
|
|
|
}).api.v1.files;
|
|
|
|
|
|
-export const membershipPlanClient = hc<MembershipPlanRoutes>('/api/v1', {
|
|
|
+export const membershipPlanClient = hc<MembershipPlanRoutes>('/', {
|
|
|
fetch: axiosFetch,
|
|
|
}).api.v1['membership-plans'];
|
|
|
|
|
|
-export const paymentClient = hc<PaymentRoutes>('/api/v1', {
|
|
|
+export const paymentClient = hc<PaymentRoutes>('/', {
|
|
|
fetch: axiosFetch,
|
|
|
}).api.v1.payments;
|
|
|
|
|
|
// 模板管理客户端(需要认证)
|
|
|
-export const templateClient = hc<any>('/api/v1', {
|
|
|
+export const templateClient = hc<any>('/', {
|
|
|
fetch: axiosFetch,
|
|
|
}).api.v1.templates;
|
|
|
|
|
|
// 公共模板客户端(无需认证)
|
|
|
-export const publicTemplateClient = hc<any>('/api/v1/public', {
|
|
|
+export const publicTemplateClient = hc<any>('/', {
|
|
|
fetch: axiosFetch,
|
|
|
-}).templates;
|
|
|
-
|
|
|
-// 类型定义
|
|
|
-import type { InferRequestType, InferResponseType } from 'hono/client';
|
|
|
-
|
|
|
-// 模板相关类型
|
|
|
-export type TemplateResponse = InferResponseType<typeof publicTemplateClient.$get, 200>['data'][0];
|
|
|
-export type TemplateListResponse = InferResponseType<typeof publicTemplateClient.$get, 200>;
|
|
|
-export type TemplatePreviewResponse = InferResponseType<typeof publicTemplateClient[':id']['preview']['$get'], 200>;
|
|
|
-export type TemplateDownloadResponse = InferResponseType<typeof publicTemplateClient[':id']['download']['$post'], 200>;
|
|
|
+}).templates;
|