更新首页
This commit is contained in:
@@ -0,0 +1,341 @@
|
||||
import request from '@/utils/request'
|
||||
import type { ApiResult, PageResult } from '@/api'
|
||||
import { APP_API_URL } from '@/config/setting'
|
||||
|
||||
const BASE = APP_API_URL + '/site'
|
||||
|
||||
function isSuccess(code?: number) {
|
||||
return code === 0 || code === 200
|
||||
}
|
||||
|
||||
function unwrap<T>(res: { data: ApiResult<T> }) {
|
||||
if (isSuccess(res.data.code)) {
|
||||
return res.data.data as T
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message || '请求失败'))
|
||||
}
|
||||
|
||||
export interface SiteArticleCategory {
|
||||
categoryId: number
|
||||
categoryCode?: string
|
||||
routeKey?: string
|
||||
title: string
|
||||
type?: number
|
||||
image?: string
|
||||
parentId?: number
|
||||
path?: string
|
||||
count?: number
|
||||
sortNumber?: number
|
||||
description?: string
|
||||
status?: number
|
||||
children?: SiteArticleCategory[]
|
||||
}
|
||||
|
||||
export interface SiteArticle {
|
||||
id: number
|
||||
articleId: number
|
||||
title: string
|
||||
code?: string
|
||||
categoryId?: number
|
||||
categoryName?: string
|
||||
categoryPath?: string
|
||||
type?: string
|
||||
image?: string
|
||||
source?: string
|
||||
overview?: string
|
||||
content?: string
|
||||
views?: number
|
||||
actualViews?: number
|
||||
likes?: number
|
||||
author?: string
|
||||
recommend?: number
|
||||
publishTime?: string
|
||||
createTime?: string
|
||||
updateTime?: string
|
||||
}
|
||||
|
||||
export interface SiteAdSlot {
|
||||
id: number
|
||||
adId: number
|
||||
slotCode: string
|
||||
slotName?: string
|
||||
title: string
|
||||
image?: string
|
||||
linkUrl?: string
|
||||
target?: number
|
||||
description?: string
|
||||
}
|
||||
|
||||
export interface SiteExpertResearchResult {
|
||||
year?: string
|
||||
title?: string
|
||||
description?: string
|
||||
}
|
||||
|
||||
export interface SiteExpert {
|
||||
id: number
|
||||
expertId: number
|
||||
avatar?: string
|
||||
name: string
|
||||
birthDate?: string
|
||||
gender?: string
|
||||
ethnicity?: string
|
||||
politicalStatus?: string
|
||||
nationality?: string
|
||||
title?: string
|
||||
idCardNumber?: string
|
||||
address?: string
|
||||
organization?: string
|
||||
workDuty?: string
|
||||
societyPosition?: string
|
||||
societyEmploymentType?: number
|
||||
otherSocialPosition?: string
|
||||
hasOtherSocietyPosition?: number
|
||||
isPublicServant?: number
|
||||
unitType?: string
|
||||
unitLevel?: string
|
||||
isRetired?: number
|
||||
researchArea?: string
|
||||
education?: string
|
||||
email?: string
|
||||
phone?: string
|
||||
introduction?: string
|
||||
bio?: string
|
||||
workExperience?: Array<{ period?: string; organization?: string }>
|
||||
mainResearchAchievements?: string
|
||||
profile?: string
|
||||
resume?: string
|
||||
certificate?: string
|
||||
idCard?: string
|
||||
degreeCertificate?: string
|
||||
titleCertificate?: string
|
||||
achievements?: string[]
|
||||
serialNo?: string
|
||||
honors?: string[]
|
||||
researchResults?: SiteExpertResearchResult[]
|
||||
joinTime?: string
|
||||
createTime?: string
|
||||
updateTime?: string
|
||||
}
|
||||
|
||||
export interface SiteArticlePageParams {
|
||||
page?: number
|
||||
limit?: number
|
||||
keywords?: string
|
||||
recommend?: number
|
||||
categoryId?: number
|
||||
category?: string
|
||||
type?: string
|
||||
}
|
||||
|
||||
export interface SiteExpertPageParams {
|
||||
page?: number
|
||||
limit?: number
|
||||
keywords?: string
|
||||
}
|
||||
|
||||
export interface SiteDictionaryItem {
|
||||
itemId: number
|
||||
dictCode: string
|
||||
dictName: string
|
||||
itemKey: string
|
||||
itemLabel: string
|
||||
itemValue: string
|
||||
description?: string
|
||||
sortNumber?: number
|
||||
status?: number
|
||||
}
|
||||
|
||||
export interface SiteJoinApplication {
|
||||
id: number
|
||||
applicationId: number
|
||||
type?: string
|
||||
name: string
|
||||
creditCode?: string
|
||||
contact?: string
|
||||
phone?: string
|
||||
email?: string
|
||||
address?: string
|
||||
bio?: string
|
||||
title?: string
|
||||
organization?: string
|
||||
intro?: string
|
||||
reviewedAt?: number
|
||||
joinTime?: string
|
||||
}
|
||||
|
||||
export interface SiteSuggestion {
|
||||
id: number
|
||||
suggestionId: number
|
||||
title: string
|
||||
content?: string
|
||||
status?: number
|
||||
reply?: string
|
||||
processedAt?: number
|
||||
processedTime?: string
|
||||
createTime?: string
|
||||
}
|
||||
|
||||
export interface SiteModuleEntry {
|
||||
id: number
|
||||
entryId: number
|
||||
type?: string
|
||||
title: string
|
||||
summary?: string
|
||||
content?: string
|
||||
image?: string
|
||||
attachmentName?: string
|
||||
attachmentPath?: string
|
||||
publishTime?: string
|
||||
createTime?: string
|
||||
updateTime?: string
|
||||
}
|
||||
|
||||
export interface SiteMembershipService {
|
||||
id: number
|
||||
serviceId: number
|
||||
categoryKey: string
|
||||
categoryName: string
|
||||
title: string
|
||||
summary?: string
|
||||
content?: string
|
||||
icon?: string
|
||||
tags?: string[]
|
||||
publishTime?: string
|
||||
createTime?: string
|
||||
updateTime?: string
|
||||
}
|
||||
|
||||
export interface SiteFriendLink {
|
||||
id: number
|
||||
linkId: number
|
||||
categoryId?: number
|
||||
categoryName?: string
|
||||
categorySort?: number
|
||||
title: string
|
||||
linkUrl: string
|
||||
target?: number
|
||||
description?: string
|
||||
}
|
||||
|
||||
export async function listSiteArticleCategories(params?: { category?: string }) {
|
||||
const res = await request.get<ApiResult<SiteArticleCategory[]>>(BASE + '/article-categories', { params })
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function pageSiteArticles(params?: SiteArticlePageParams) {
|
||||
const res = await request.get<ApiResult<PageResult<SiteArticle>>>(BASE + '/articles', { params })
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function getSiteArticle(id: number | string) {
|
||||
const res = await request.get<ApiResult<SiteArticle>>(BASE + `/article/${id}`)
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function listSiteAdSlots(params?: { slotCode?: string }) {
|
||||
const res = await request.get<ApiResult<SiteAdSlot[]>>(BASE + '/ad-slots', { params })
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function pageSiteExperts(params?: SiteExpertPageParams) {
|
||||
const res = await request.get<ApiResult<PageResult<SiteExpert>>>(BASE + '/experts', { params })
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function getSiteExpert(id: number | string) {
|
||||
const res = await request.get<ApiResult<SiteExpert>>(BASE + `/expert/${id}`)
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function uploadSiteExpertFile(formData: FormData) {
|
||||
const res = await request.post<ApiResult<{ path: string; url: string; name: string }>>(BASE + '/expert/upload-file', formData)
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function submitSiteExpertApplication(data: Record<string, unknown>) {
|
||||
const res = await request.post<ApiResult<unknown>>(BASE + '/expert-application', data)
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function submitSiteSuggestion(data: Record<string, unknown>) {
|
||||
const res = await request.post<ApiResult<unknown>>(BASE + '/suggestion', data)
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function pageSiteSuggestions(params?: { page?: number; limit?: number; keywords?: string }) {
|
||||
const res = await request.get<ApiResult<PageResult<SiteSuggestion>>>(BASE + '/suggestions', { params })
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function getSiteSuggestion(id: number | string) {
|
||||
const res = await request.get<ApiResult<SiteSuggestion>>(BASE + `/suggestion/${id}`)
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function pageSiteModuleEntries(params?: { page?: number; limit?: number; type?: string; keywords?: string }) {
|
||||
const res = await request.get<ApiResult<PageResult<SiteModuleEntry>>>(BASE + '/module-entries', { params })
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function getSiteModuleEntry(id: number | string) {
|
||||
const res = await request.get<ApiResult<SiteModuleEntry>>(BASE + `/module-entry/${id}`)
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function pageSiteMembershipServices(params?: { page?: number; limit?: number; categoryKey?: string; type?: string; keywords?: string }) {
|
||||
const res = await request.get<ApiResult<PageResult<SiteMembershipService>>>(BASE + '/membership-services', { params })
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function getSiteMembershipService(id: number | string) {
|
||||
const res = await request.get<ApiResult<SiteMembershipService>>(BASE + `/membership-service/${id}`)
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function listSiteFriendLinks(params?: { keywords?: string }) {
|
||||
const res = await request.get<ApiResult<SiteFriendLink[]>>(BASE + '/friend-links', { params })
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function submitSiteConsultationMessage(data: Record<string, unknown>) {
|
||||
const res = await request.post<ApiResult<unknown>>(BASE + '/consultation-message', data)
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function uploadSiteJoinApplicationFile(formData: FormData) {
|
||||
const res = await request.post<ApiResult<{ path: string; url: string; name: string }>>(BASE + '/join-application/upload-file', formData)
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function submitSiteJoinApplication(data: Record<string, unknown>) {
|
||||
const res = await request.post<ApiResult<unknown>>(BASE + '/join-application', data)
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function pageSiteJoinApplications(params?: { page?: number; limit?: number; type?: string; keywords?: string }) {
|
||||
const res = await request.get<ApiResult<PageResult<SiteJoinApplication>>>(BASE + '/join-applications', { params })
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function getSiteJoinApplication(id: number | string) {
|
||||
const res = await request.get<ApiResult<SiteJoinApplication>>(BASE + `/join-application/${id}`)
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export async function listSiteDictionaryItems(params?: { dictCode?: string }) {
|
||||
const res = await request.get<ApiResult<SiteDictionaryItem[]>>(BASE + '/dictionary-items', { params })
|
||||
return unwrap(res)
|
||||
}
|
||||
|
||||
export function resolveSiteAssetUrl(path?: string | null) {
|
||||
if (!path) {
|
||||
return ''
|
||||
}
|
||||
|
||||
if (/^(https?:)?\/\//i.test(path) || /^data:/i.test(path) || /^blob:/i.test(path)) {
|
||||
return path
|
||||
}
|
||||
|
||||
return path.startsWith('/') ? path : `/${path}`
|
||||
}
|
||||
Reference in New Issue
Block a user