官网开发中 0803

This commit is contained in:
eafonyang
2026-08-03 19:09:03 +08:00
parent eeccdb079c
commit f37b6451ef
36 changed files with 1906 additions and 78 deletions
+48 -2
View File
@@ -1,4 +1,18 @@
import type { GlobalConfig, NavConfig, SectionBlock, I18nEntry, ProductsData } from '~/types/site';
import type {
GlobalConfig,
NavConfig,
SectionBlock,
I18nEntry,
ProductsData,
NewsArticle,
NewsDetail,
NewsListConfig,
ProductListConfig,
AboutConfig,
SupportConfig,
ContactConfig,
PageSeo
} from '~/types/site';
/**
* 官网前台公开接口服务层
@@ -35,5 +49,37 @@ export function useSiteApi() {
return get<ProductsData>('/site/products');
}
return { getGlobal, getNav, getSections, getI18n, getProducts };
/** 新闻列表(仅已发布) */
function getNews(skip = 0, limit = 9) {
return get<{ items: NewsArticle[]; total: number; skip: number; limit: number }>('/site/news', { skip, limit });
}
/** 新闻详情(按 slug,含推荐) */
function getNewsDetail(slug: string) {
return get<NewsDetail>(`/site/news/${encodeURIComponent(slug)}`);
}
/** 页面配置:product-list / news-list / about / support */
function getPageConfig<T>(type: 'product-list' | 'news-list' | 'about' | 'support') {
return get<T>('/site/page', { type });
}
/** 页面 SEO 配置 */
function getPageSeo(pageType: string, entityId?: number) {
const params: Record<string, unknown> = { page_type: pageType };
if (entityId) params.entity_id = entityId;
return get<PageSeo | null>('/site/page-seo', params);
}
/** 联系表单配置 + 字段 */
function getContact() {
return get<ContactConfig>('/site/contact');
}
/** 提交联系表单 */
function submitContact(formData: Record<string, string>) {
return useRequest().post<null>('/site/contact/submit', { form_data: formData });
}
return { getGlobal, getNav, getSections, getI18n, getProducts, getNews, getNewsDetail, getPageConfig, getPageSeo, getContact, submitContact };
}