feat: 前台 paywall——整篇锁定渲染付费墙,付费块替换为 teaser

- membership/post.rendered 过滤:整篇锁定(members_only)渲染 paywall 视图(封面+标题+价格+单篇解锁/开通会员按钮,游客引导登录);[paid] 块替换为带解锁按钮的 teaser;替换改用 preg_replace_callback 避免 $ 转义问题
- 视图放 resources/views/membership/(主题同名文件可覆盖),两主题补充 .paywall/.paid-teaser 样式
- 修复泄漏:excerpt_or_fallback 对 members_only 文章不再回退截取正文,防止内容泄漏到 paywall 与 SEO meta
- 测试:更新 teaser 断言,新增 guest 见 paywall、登录用户见解锁/会员按钮
This commit is contained in:
ak
2026-08-12 01:02:10 +08:00
parent 6a7daa79da
commit 8ef250ba80
7 changed files with 144 additions and 6 deletions
+5
View File
@@ -126,6 +126,11 @@ class Post extends Model implements HasMedia
return $this->excerpt;
}
// 会员专享文章不落入内容摘要,避免泄漏到 paywall/SEO meta
if (! empty(($this->meta ?? [])['members_only'])) {
return '';
}
$text = strip_tags($this->content);
// 付费块不进入摘要,避免付费内容泄漏到列表页/SEO meta
$text = preg_replace('/\[paid\].*?\[\/paid\]/s', '', $text);