加强了多个组件的预览百分比处理。
在 API 中新增了章节专属的预览百分比,并更新了相关模型和处理器。 改进了阅读场景下确定有效预览百分比的逻辑。 更新了小程序配置,加入了新的阅读页面入口。
This commit is contained in:
@@ -39,12 +39,17 @@ function getContentParseConfig() {
|
||||
}
|
||||
|
||||
/** 补全 mentionDisplay,避免旧数据无字段;昵称去空白防「@ 名」 */
|
||||
/** 付费墙「已阅读 x%」:与章节接口 previewPercent 一致(未全文解锁时),缺省 20 */
|
||||
/** 试读比例:优先 data.previewPercent(章节私有),否则顶层 previewPercent(全局 unpaid_preview_percent),缺省 20 */
|
||||
function normalizePreviewPercent(res) {
|
||||
const p = res && res.previewPercent
|
||||
const n = typeof p === 'number' ? Math.round(p) : parseInt(String(p), 10)
|
||||
if (!isNaN(n) && n >= 1 && n <= 100) return n
|
||||
return 20
|
||||
if (!res) return 20
|
||||
const tryNum = (v) => {
|
||||
const n = typeof v === 'number' ? Math.round(v) : parseInt(String(v), 10)
|
||||
if (!isNaN(n) && n >= 1 && n <= 100) return n
|
||||
return undefined
|
||||
}
|
||||
const inner = res.data && res.data.previewPercent
|
||||
const outer = res.previewPercent
|
||||
return tryNum(inner) ?? tryNum(outer) ?? 20
|
||||
}
|
||||
|
||||
function normalizeMentionSegments(segments) {
|
||||
@@ -93,7 +98,7 @@ Page({
|
||||
|
||||
// 阅读进度
|
||||
readingProgress: 0,
|
||||
/** 未解锁时付费墙展示:与 /api/miniprogram/book/chapter/* 的 previewPercent 对齐 */
|
||||
/** 未解锁付费墙:合并 data.previewPercent(章节)与顶层 previewPercent(全局) */
|
||||
previewPercent: 20,
|
||||
showPaywall: false,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user