feat: 完成前端业务闭环与后端联调
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { hasRemoteConfig } from '@/utils/runtime-config.js'
|
||||
import {
|
||||
normalizeAppPromotions,
|
||||
normalizeComplianceDocument,
|
||||
@@ -6,19 +5,10 @@ import {
|
||||
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')
|
||||
}
|
||||
import { requestStrict } from './request-client.js'
|
||||
|
||||
export const siteContentApi = {
|
||||
async getHelpArticles(requestOptions = {}) {
|
||||
requireRemoteSiteContent('帮助文章')
|
||||
const helpArticles = await requestStrict({
|
||||
url: '/genealogy/app/help-articles',
|
||||
method: 'GET'
|
||||
@@ -30,7 +20,6 @@ export const siteContentApi = {
|
||||
|
||||
async getPromotions(requestOptions = {}) {
|
||||
const placement = normalizePromotionPlacement(requestOptions.placement ?? 'home_banner')
|
||||
requireRemoteSiteContent('应用推广')
|
||||
const promotions = await requestStrict({
|
||||
url: '/genealogy/app/promotions',
|
||||
method: 'GET',
|
||||
@@ -42,12 +31,12 @@ export const siteContentApi = {
|
||||
},
|
||||
|
||||
async getComplianceDocument(documentKey, requestOptions = {}) {
|
||||
requireRemoteSiteContent('协议正文')
|
||||
const normalizedKey = normalizeComplianceDocumentKey(documentKey)
|
||||
const complianceDocument = await requestStrict({
|
||||
url: `/genealogy/app/compliance/documents/${normalizedKey}`,
|
||||
method: 'GET'
|
||||
}, {
|
||||
authenticated: false,
|
||||
requestController: requestOptions.requestController ?? null
|
||||
})
|
||||
return normalizeComplianceDocument(complianceDocument, normalizedKey)
|
||||
|
||||
Reference in New Issue
Block a user