feat: migrate app routes and business modules

This commit is contained in:
2026-08-12 18:22:59 +08:00
parent 555aa00043
commit cc706378c2
247 changed files with 28623 additions and 14988 deletions
+55
View File
@@ -0,0 +1,55 @@
import { hasRemoteConfig } from '@/utils/runtime-config.js'
import {
normalizeAppPromotions,
normalizeComplianceDocument,
normalizeComplianceDocumentKey,
normalizeHelpArticles,
normalizePromotionPlacement
} from './site-content-contract.js'
import {
createRequestError,
requestStrict
} from './request-client.js'
const requireRemoteSiteContent = (label) => {
if (hasRemoteConfig()) return
throw createRequestError(`${label}读取需要真实服务,当前本地预览不会伪造结果`, 'REMOTE_READ_REQUIRED')
}
export const siteContentApi = {
async getHelpArticles(requestOptions = {}) {
requireRemoteSiteContent('帮助文章')
const helpArticles = await requestStrict({
url: '/genealogy/app/help-articles',
method: 'GET'
}, {
requestController: requestOptions.requestController ?? null
})
return normalizeHelpArticles(helpArticles)
},
async getPromotions(requestOptions = {}) {
const placement = normalizePromotionPlacement(requestOptions.placement ?? 'home_banner')
requireRemoteSiteContent('应用推广')
const promotions = await requestStrict({
url: '/genealogy/app/promotions',
method: 'GET',
data: { platform: 'app', placement }
}, {
requestController: requestOptions.requestController ?? null
})
return normalizeAppPromotions(promotions, placement)
},
async getComplianceDocument(documentKey, requestOptions = {}) {
requireRemoteSiteContent('协议正文')
const normalizedKey = normalizeComplianceDocumentKey(documentKey)
const complianceDocument = await requestStrict({
url: `/genealogy/app/compliance/documents/${normalizedKey}`,
method: 'GET'
}, {
requestController: requestOptions.requestController ?? null
})
return normalizeComplianceDocument(complianceDocument, normalizedKey)
}
}