48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
/**
|
||
* 前台公开 API(无需 token)
|
||
*/
|
||
import { http, type Paginated } from './api';
|
||
import type {
|
||
Banner,
|
||
Manual,
|
||
ManualTreeNode,
|
||
News,
|
||
NewsCategory,
|
||
Product,
|
||
ProductCategory,
|
||
SiteConfig,
|
||
Team,
|
||
} from './types';
|
||
|
||
export const publicApi = {
|
||
getSiteConfig: () =>
|
||
http.get<unknown, SiteConfig>('/public/site-config'),
|
||
getBanners: () =>
|
||
http.get<unknown, Banner[]>('/public/banner'),
|
||
getProductCategories: () =>
|
||
http.get<unknown, ProductCategory[]>('/public/product-category'),
|
||
getProducts: (params: Record<string, unknown> = {}) =>
|
||
http.get<unknown, Paginated<Product>>('/public/product', { params }),
|
||
getProductDetail: (id: number) =>
|
||
http.get<unknown, Product>(`/public/product/${id}`),
|
||
getNewsCategories: () =>
|
||
http.get<unknown, NewsCategory[]>('/public/news-category'),
|
||
getNews: (params: Record<string, unknown> = {}) =>
|
||
http.get<unknown, Paginated<News>>('/public/news', { params }),
|
||
getNewsDetail: (id: number) =>
|
||
http.get<unknown, News>(`/public/news/${id}`),
|
||
getTeam: () =>
|
||
http.get<unknown, Team[]>('/public/team'),
|
||
submitMessage: (payload: {
|
||
name: string;
|
||
phone: string;
|
||
email?: string;
|
||
content: string;
|
||
}) => http.post<unknown, unknown>('/public/message', payload),
|
||
// ---------- 使用手册 ----------
|
||
getManualTree: () =>
|
||
http.get<unknown, ManualTreeNode[]>('/public/manual/tree'),
|
||
getManualDetail: (id: number) =>
|
||
http.get<unknown, Manual>(`/public/manual/${id}`),
|
||
};
|