# 内联 PDF 预览

**URL:** <https://meta.discourse.org/t/inline-pdf-previews/157649>\
**Category:** Theme component\
**Tags:** official, desktop, pdf-previews\
**Created:** [2020年七月13日 21:18 UTC](https://meta.discourse.org/t/inline-pdf-previews/157649 "2020-07-13T21:18:10Z")\
**Posts on this page:** 1\
**Showing post:** 170

<div class="post-metadata">

**Author:** ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)\
**Post date:** [2026年七月15日 08:47 UTC](https://meta.discourse.org/t/inline-pdf-previews/157649/170 "2026-07-15T08:47:02Z")

</div>

@tpetrov 这个问题现在已经修复了 👍

> <https://github.com/discourse/discourse-pdf-previews/pull/60>
>
> \### What & why
> 
> The component read \`site.mobileView\` inside its initializer, whi…ch runs while the application is still booting. Accessing the viewport that early is deprecated (\`discourse.static-viewport-initialization\`) — the value isn't reliable before boot and can't react to viewport changes. As a result, every admin on a site running this component saw a persistent \*\*"\[Admin Notice\] … contains code which needs updating"\*\* banner.
> 
> \### Fix
> 
> \- Move the desktop-only guard into the \`decorateCookedElement\` callback so it is evaluated at render time instead of during initialization.
> \- Read it from the modern \`capabilities.viewport\` service rather than the legacy mobile/desktop split.
> 
> Since \`site.mobileView\` is defined as \`!capabilities.viewport.sm\`, behaviour is unchanged — previews remain desktop-only.
> 
> See https://meta.discourse.org/t/367810 for the viewport guidance.

---

_[View the full topic](https://meta.discourse.org/t/inline-pdf-previews/157649)._
