前端-官网内容管理开发
This commit is contained in:
@@ -8,3 +8,15 @@ export * from './blacklist';
|
||||
export * from './ota-target-device';
|
||||
export * from './share-code-log';
|
||||
export * from './model';
|
||||
|
||||
// 官网 CMS
|
||||
export * from './www-global';
|
||||
export * from './www-nav';
|
||||
export * from './www-sections';
|
||||
export * from './www-pages';
|
||||
export * from './www-products';
|
||||
export * from './www-news';
|
||||
export * from './www-media';
|
||||
export * from './www-i18n';
|
||||
export * from './www-contact';
|
||||
export * from './www-seo';
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import { request } from '../request';
|
||||
import type { PageParams } from './brand';
|
||||
|
||||
// ===== 表单配置 =====
|
||||
export function fetchGetFormSettings() {
|
||||
return request<Api.Www.FormSettings>({ url: '/www/contact/settings', method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchUpdateFormSettings(data: Omit<Api.Www.FormSettings, 'id'>) {
|
||||
return request<Api.Www.FormSettings>({ url: '/www/contact/settings', method: 'put', data });
|
||||
}
|
||||
|
||||
// ===== 表单字段 =====
|
||||
export function fetchGetFormFields() {
|
||||
return request<{ items: Api.Www.FormField[]; total: number }>({ url: '/www/contact/fields', method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchCreateFormField(data: Partial<Api.Www.FormField>) {
|
||||
return request<Api.Www.FormField>({ url: '/www/contact/fields', method: 'post', data });
|
||||
}
|
||||
|
||||
export function fetchUpdateFormField(id: number, data: Partial<Api.Www.FormField>) {
|
||||
return request<Api.Www.FormField>({ url: `/www/contact/fields/${id}`, method: 'put', data });
|
||||
}
|
||||
|
||||
export function fetchDeleteFormField(id: number) {
|
||||
return request({ url: `/www/contact/fields/${id}`, method: 'delete' });
|
||||
}
|
||||
|
||||
export function fetchSortFormFields(data: Array<{ id: number; sort_order: number }>) {
|
||||
return request({ url: '/www/contact/fields/sort', method: 'patch', data });
|
||||
}
|
||||
|
||||
// ===== 提交记录 =====
|
||||
export function fetchGetFormSubmissions(params?: PageParams & { is_read?: 0 | 1; start_date?: string; end_date?: string }) {
|
||||
return request<Api.Common.PageResult<Api.Www.FormSubmission>>({ url: '/www/contact/submissions', method: 'get', params });
|
||||
}
|
||||
|
||||
export function fetchGetFormSubmission(id: number) {
|
||||
return request<Api.Www.FormSubmission>({ url: `/www/contact/submissions/${id}`, method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchMarkSubmissionRead(id: number) {
|
||||
return request({ url: `/www/contact/submissions/${id}/read`, method: 'patch' });
|
||||
}
|
||||
|
||||
export function fetchDeleteSubmission(id: number) {
|
||||
return request({ url: `/www/contact/submissions/${id}`, method: 'delete' });
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import { request } from '../request';
|
||||
import type { PageParams } from './brand';
|
||||
|
||||
// ===== 站点信息 =====
|
||||
export function fetchGetSiteSettings() {
|
||||
return request<Api.Www.SiteSettings>({ url: '/www/global/site', method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchUpdateSiteSettings(data: Omit<Api.Www.SiteSettings, 'id' | 'updated_at'>) {
|
||||
return request<Api.Www.SiteSettings>({ url: '/www/global/site', method: 'put', data });
|
||||
}
|
||||
|
||||
// ===== 页脚配置 =====
|
||||
export function fetchGetFooterSettings() {
|
||||
return request<Api.Www.FooterSettings>({ url: '/www/global/footer', method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchUpdateFooterSettings(data: Omit<Api.Www.FooterSettings, 'id'>) {
|
||||
return request<Api.Www.FooterSettings>({ url: '/www/global/footer', method: 'put', data });
|
||||
}
|
||||
|
||||
// ===== 社交链接 =====
|
||||
export function fetchGetSocialLinks() {
|
||||
return request<Api.Www.SocialLink[]>({ url: '/www/global/social', method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchUpdateSocialLinks(data: Array<Pick<Api.Www.SocialLink, 'platform' | 'url' | 'qrcode_url'>>) {
|
||||
return request<Api.Www.SocialLink[]>({ url: '/www/global/social', method: 'put', data });
|
||||
}
|
||||
|
||||
// ===== SEO 默认值 =====
|
||||
export function fetchGetSeoDefaults() {
|
||||
return request<Api.Www.SeoDefaults>({ url: '/www/global/seo', method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchUpdateSeoDefaults(data: Omit<Api.Www.SeoDefaults, 'id'>) {
|
||||
return request<Api.Www.SeoDefaults>({ url: '/www/global/seo', method: 'put', data });
|
||||
}
|
||||
|
||||
// 保留 PageParams 导出兼容
|
||||
export type { PageParams };
|
||||
@@ -0,0 +1,13 @@
|
||||
import { request } from '../request';
|
||||
|
||||
export function fetchGetI18nEntries(params?: { keyword?: string }) {
|
||||
return request<{ items: Api.Www.I18nEntry[]; total: number }>({ url: '/www/i18n', method: 'get', params });
|
||||
}
|
||||
|
||||
export function fetchUpdateI18nEntry(id: number, data: { value_zh: string; value_en: string }) {
|
||||
return request<Api.Www.I18nEntry>({ url: `/www/i18n/${id}`, method: 'put', data });
|
||||
}
|
||||
|
||||
export function fetchBatchUpdateI18nEntries(data: Array<{ id: number; value_zh: string; value_en: string }>) {
|
||||
return request({ url: '/www/i18n/batch', method: 'put', data });
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { request } from '../request';
|
||||
import type { PageParams } from './brand';
|
||||
|
||||
// ===== 素材库 =====
|
||||
export function fetchGetMedia(params?: PageParams & { category?: string; tag?: string; keyword?: string; file_type?: string }) {
|
||||
return request<Api.Common.PageResult<Api.Www.MediaItem>>({ url: '/www/media', method: 'get', params });
|
||||
}
|
||||
|
||||
export function fetchUploadMedia(file: File, onProgress?: (percent: number) => void) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
return request<Api.Www.MediaItem>({
|
||||
url: '/www/media/upload',
|
||||
method: 'post',
|
||||
data: formData,
|
||||
onUploadProgress: (e: { loaded: number; total?: number }) => {
|
||||
if (onProgress && e.total) {
|
||||
onProgress(Math.round((e.loaded / e.total) * 100));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function fetchGetMediaItem(id: number) {
|
||||
return request<Api.Www.MediaItem>({ url: `/www/media/${id}`, method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchUpdateMediaItem(id: number, data: { filename?: string; category?: string; tags?: string[] }) {
|
||||
return request<Api.Www.MediaItem>({ url: `/www/media/${id}`, method: 'put', data });
|
||||
}
|
||||
|
||||
export function fetchDeleteMediaItem(id: number) {
|
||||
return request({ url: `/www/media/${id}`, method: 'delete' });
|
||||
}
|
||||
|
||||
// ===== 素材标签 =====
|
||||
export function fetchGetMediaTags() {
|
||||
return request<Api.Www.MediaTag[]>({ url: '/www/media/tags', method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchCreateMediaTag(tagName: string) {
|
||||
return request<Api.Www.MediaTag>({ url: '/www/media/tags', method: 'post', data: { tag_name: tagName } });
|
||||
}
|
||||
|
||||
export function fetchUpdateMediaTag(id: number, tagName: string) {
|
||||
return request<Api.Www.MediaTag>({ url: `/www/media/tags/${id}`, method: 'put', data: { tag_name: tagName } });
|
||||
}
|
||||
|
||||
export function fetchDeleteMediaTag(id: number) {
|
||||
return request({ url: `/www/media/tags/${id}`, method: 'delete' });
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { request } from '../request';
|
||||
|
||||
// ===== 导航入口 =====
|
||||
export function fetchGetNavItems() {
|
||||
return request<{ items: Api.Www.NavItem[]; total: number }>({ url: '/www/nav/items', method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchCreateNavItem(data: Api.Www.NavItemPayload) {
|
||||
return request<Api.Www.NavItem>({ url: '/www/nav/items', method: 'post', data });
|
||||
}
|
||||
|
||||
export function fetchUpdateNavItem(id: number, data: Partial<Api.Www.NavItemPayload>) {
|
||||
return request<Api.Www.NavItem>({ url: `/www/nav/items/${id}`, method: 'put', data });
|
||||
}
|
||||
|
||||
export function fetchDeleteNavItem(id: number) {
|
||||
return request({ url: `/www/nav/items/${id}`, method: 'delete' });
|
||||
}
|
||||
|
||||
export function fetchSortNavItems(data: Array<{ id: number; sort_order: number }>) {
|
||||
return request({ url: '/www/nav/items/sort', method: 'patch', data });
|
||||
}
|
||||
|
||||
// ===== 导航外观 =====
|
||||
export function fetchGetNavAppearance() {
|
||||
return request<Api.Www.NavAppearance>({ url: '/www/nav/appearance', method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchUpdateNavAppearance(data: Omit<Api.Www.NavAppearance, 'id'>) {
|
||||
return request<Api.Www.NavAppearance>({ url: '/www/nav/appearance', method: 'put', data });
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { request } from '../request';
|
||||
import type { PageParams } from './brand';
|
||||
|
||||
// ===== 新闻文章 =====
|
||||
export function fetchGetNews(params?: PageParams & { status?: string; title?: string }) {
|
||||
return request<Api.Common.PageResult<Api.Www.NewsArticle>>({ url: '/www/news', method: 'get', params });
|
||||
}
|
||||
|
||||
export function fetchGetNewsArticle(id: number) {
|
||||
return request<Api.Www.NewsArticle>({ url: `/www/news/${id}`, method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchCreateNewsArticle(data: Api.Www.NewsArticlePayload) {
|
||||
return request<Api.Www.NewsArticle>({ url: '/www/news', method: 'post', data });
|
||||
}
|
||||
|
||||
export function fetchUpdateNewsArticle(id: number, data: Partial<Api.Www.NewsArticlePayload>) {
|
||||
return request<Api.Www.NewsArticle>({ url: `/www/news/${id}`, method: 'put', data });
|
||||
}
|
||||
|
||||
export function fetchDeleteNewsArticle(id: number) {
|
||||
return request({ url: `/www/news/${id}`, method: 'delete' });
|
||||
}
|
||||
|
||||
// ===== 文章推荐 =====
|
||||
export function fetchGetNewsRecommendations(id: number) {
|
||||
return request<Api.Www.NewsArticle[]>({ url: `/www/news/${id}/recommendations`, method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchUpdateNewsRecommendations(id: number, recommendedIds: number[]) {
|
||||
return request({ url: `/www/news/${id}/recommendations`, method: 'put', data: { recommended_ids: recommendedIds } });
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { request } from '../request';
|
||||
|
||||
// ===== 产品列表页配置 =====
|
||||
export function fetchGetProductListSettings() {
|
||||
return request<Api.Www.ProductListSettings>({ url: '/www/page/product-list', method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchUpdateProductListSettings(data: Omit<Api.Www.ProductListSettings, 'id'>) {
|
||||
return request<Api.Www.ProductListSettings>({ url: '/www/page/product-list', method: 'put', data });
|
||||
}
|
||||
|
||||
// ===== 新闻列表页配置 =====
|
||||
export function fetchGetNewsListSettings() {
|
||||
return request<Api.Www.NewsListSettings>({ url: '/www/page/news-list', method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchUpdateNewsListSettings(data: Omit<Api.Www.NewsListSettings, 'id'>) {
|
||||
return request<Api.Www.NewsListSettings>({ url: '/www/page/news-list', method: 'put', data });
|
||||
}
|
||||
|
||||
// ===== 关于我们配置 =====
|
||||
export function fetchGetAboutSettings() {
|
||||
return request<Api.Www.AboutSettings>({ url: '/www/page/about', method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchUpdateAboutSettings(data: Record<string, unknown>) {
|
||||
return request<Api.Www.AboutSettings>({ url: '/www/page/about', method: 'put', data });
|
||||
}
|
||||
|
||||
// ===== 技术支持配置 =====
|
||||
export function fetchGetSupportSettings() {
|
||||
return request<Api.Www.SupportSettings>({ url: '/www/page/support', method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchUpdateSupportSettings(data: Record<string, unknown>) {
|
||||
return request<Api.Www.SupportSettings>({ url: '/www/page/support', method: 'put', data });
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { request } from '../request';
|
||||
import type { PageParams } from './brand';
|
||||
|
||||
// ===== 产品系列 =====
|
||||
export function fetchGetProductSeries() {
|
||||
return request<{ items: Api.Www.ProductSeries[]; total: number }>({
|
||||
url: '/www/product/series',
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
export function fetchCreateProductSeries(data: Api.Www.ProductSeriesPayload) {
|
||||
return request<Api.Www.ProductSeries>({ url: '/www/product/series', method: 'post', data });
|
||||
}
|
||||
|
||||
export function fetchGetProductSeriesById(id: number) {
|
||||
return request<Api.Www.ProductSeries>({ url: `/www/product/series/${id}`, method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchUpdateProductSeries(id: number, data: Partial<Api.Www.ProductSeriesPayload>) {
|
||||
return request<Api.Www.ProductSeries>({ url: `/www/product/series/${id}`, method: 'put', data });
|
||||
}
|
||||
|
||||
export function fetchDeleteProductSeries(id: number) {
|
||||
return request({ url: `/www/product/series/${id}`, method: 'delete' });
|
||||
}
|
||||
|
||||
export function fetchSortProductSeries(data: Array<{ id: number; sort_order: number }>) {
|
||||
return request({ url: '/www/product/series/sort', method: 'patch', data });
|
||||
}
|
||||
|
||||
// ===== 产品 =====
|
||||
export function fetchGetProducts(params?: PageParams & { series_id?: number; is_visible?: 0 | 1; name?: string }) {
|
||||
return request<Api.Common.PageResult<Api.Www.Product>>({ url: '/www/products', method: 'get', params });
|
||||
}
|
||||
|
||||
export function fetchGetProduct(id: number) {
|
||||
return request<Api.Www.Product>({ url: `/www/products/${id}`, method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchCreateProduct(data: Api.Www.ProductPayload) {
|
||||
return request<Api.Www.Product>({ url: '/www/products', method: 'post', data });
|
||||
}
|
||||
|
||||
export function fetchUpdateProduct(id: number, data: Partial<Api.Www.ProductPayload>) {
|
||||
return request<Api.Www.Product>({ url: `/www/products/${id}`, method: 'put', data });
|
||||
}
|
||||
|
||||
export function fetchDeleteProduct(id: number) {
|
||||
return request({ url: `/www/products/${id}`, method: 'delete' });
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
import { request } from '../request';
|
||||
|
||||
// ===== Section 区块 =====
|
||||
export function fetchGetSections(params: { page_type: string; product_id?: number }) {
|
||||
return request<{ items: Api.Www.SectionBlock[]; total: number }>({
|
||||
url: '/www/sections',
|
||||
method: 'get',
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
export function fetchGetSection(id: number) {
|
||||
return request<Api.Www.SectionBlock>({ url: `/www/sections/${id}`, method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchCreateSection(data: Api.Www.SectionPayload) {
|
||||
return request<Api.Www.SectionBlock>({ url: '/www/sections', method: 'post', data });
|
||||
}
|
||||
|
||||
export function fetchUpdateSection(id: number, data: Partial<Api.Www.SectionPayload>) {
|
||||
return request<Api.Www.SectionBlock>({ url: `/www/sections/${id}`, method: 'put', data });
|
||||
}
|
||||
|
||||
export function fetchDeleteSection(id: number) {
|
||||
return request({ url: `/www/sections/${id}`, method: 'delete' });
|
||||
}
|
||||
|
||||
export function fetchSortSections(data: Array<{ id: number; sort_order: number }>) {
|
||||
return request({ url: '/www/sections/sort', method: 'patch', data });
|
||||
}
|
||||
|
||||
export function fetchDuplicateSection(id: number) {
|
||||
return request<Api.Www.SectionBlock>({ url: `/www/sections/${id}/duplicate`, method: 'post' });
|
||||
}
|
||||
|
||||
// ===== 参数分组 =====
|
||||
export function fetchGetSpecGroups(sectionId: number) {
|
||||
return request<Api.Www.SpecGroup[]>({ url: `/www/sections/${sectionId}/spec-groups`, method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchCreateSpecGroup(sectionId: number, data: { title_zh: string; title_en: string; default_visible?: number }) {
|
||||
return request<Api.Www.SpecGroup>({ url: `/www/sections/${sectionId}/spec-groups`, method: 'post', data });
|
||||
}
|
||||
|
||||
export function fetchUpdateSpecGroup(sectionId: number, groupId: number, data: Partial<{ title_zh: string; title_en: string; default_visible: number }>) {
|
||||
return request<Api.Www.SpecGroup>({ url: `/www/sections/${sectionId}/spec-groups/${groupId}`, method: 'put', data });
|
||||
}
|
||||
|
||||
export function fetchDeleteSpecGroup(sectionId: number, groupId: number) {
|
||||
return request({ url: `/www/sections/${sectionId}/spec-groups/${groupId}`, method: 'delete' });
|
||||
}
|
||||
|
||||
export function fetchSortSpecGroups(sectionId: number, data: Array<{ id: number; sort_order: number }>) {
|
||||
return request({ url: `/www/sections/${sectionId}/spec-groups/sort`, method: 'patch', data });
|
||||
}
|
||||
|
||||
// ===== 参数项 =====
|
||||
export function fetchGetSpecItems(groupId: number) {
|
||||
return request<Api.Www.SpecItem[]>({ url: `/www/spec-groups/${groupId}/items`, method: 'get' });
|
||||
}
|
||||
|
||||
export function fetchCreateSpecItem(groupId: number, data: { name_zh: string; name_en: string; value_zh: string; value_en: string }) {
|
||||
return request<Api.Www.SpecItem>({ url: `/www/spec-groups/${groupId}/items`, method: 'post', data });
|
||||
}
|
||||
|
||||
export function fetchUpdateSpecItem(id: number, data: Partial<{ name_zh: string; name_en: string; value_zh: string; value_en: string }>) {
|
||||
return request<Api.Www.SpecItem>({ url: `/www/spec-items/${id}`, method: 'put', data });
|
||||
}
|
||||
|
||||
export function fetchDeleteSpecItem(id: number) {
|
||||
return request({ url: `/www/spec-items/${id}`, method: 'delete' });
|
||||
}
|
||||
|
||||
export function fetchSortSpecItems(groupId: number, data: Array<{ id: number; sort_order: number }>) {
|
||||
return request({ url: `/www/spec-groups/${groupId}/items/sort`, method: 'patch', data });
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { request } from '../request';
|
||||
|
||||
export function fetchGetPageSeo(params: { page_type: string; entity_id?: number }) {
|
||||
return request<Api.Www.PageSeo>({ url: '/www/page-seo', method: 'get', params });
|
||||
}
|
||||
|
||||
export function fetchUpdatePageSeo(data: Omit<Api.Www.PageSeo, 'id'>) {
|
||||
return request<Api.Www.PageSeo>({ url: '/www/page-seo', method: 'put', data });
|
||||
}
|
||||
Reference in New Issue
Block a user