Repository navigation
fix: improve third-party QR code login layouts - #8098
Conversation
| transform-origin: top center; | ||
| } | ||
| } | ||
| </style> |
There was a problem hiding this comment.
Here's my review of the diff:
Potential Issues
-
Missing
tusage was fixed, but verify i18n keys exist — You addedtfromuseI18n. Ensureauth.qrCode.title,auth.methods.wecomkeys are defined in both locales; otherwise runtime warnings/fallback may appear. -
Hard-coded pixel values for iframe cropping (fragile) —
-104px,280px,192px,200pxare all magic numbers tied to WeCom's internal iframe layout. If WeCom changes their embed UI (size/padding), this breaks silently. Consider documenting source or extracting to named CSS variables / constants with comments referencing where these numbers come from. -
scrolling="no"on iframe — Deprecated attribute in HTML5 (still widely supported, but non-standard). Prefer CSSoverflow: hidden(already applied to container) and/or note it's a legacy fallback. Not blocking. -
transform: scalecombined withtopoffset — The negativetopshifts the element before transform, then scaling happens aroundtransform-origin: top center. The visual result depends on order; double-check that the offset–scale combination actually produces the intended crop across browsers (Safari sometimes differs with transformed iframes). Test in Safari/Firefox. -
Removed
panel_size: 'small'— This changes the QR panel mode. Confirm the embedding flow still returns a usable code and no downstream logic depended on "small". Also confirm size assumptions (192→280px) match the default panel size now used. -
alt=""on logo image — Acceptable for decorative image alongside text heading, so fine. But if it conveys meaning, give italt. -
Accessibility — The title is now an
<h2>; good. Consideraria-labelon iframe for screen readers (iframes without title are an a11y issue): addtitle="WeCom login"or similar. -
Reduced height
h-95 → h-90— Combined with the new wrapper height, verify total layout doesn't cause scrollbars or clipping in narrow viewports. The hard-codedheighton.wecom-qr-layoutmay conflict with responsive needs; considermax-heightor media query.
Optimization Suggestions
- Extract magic numbers into SCSS variables with comments, e.g.
$wecom-inner-qr-size: 192px; $wecom-target-size: 200px;. - Add iframe
titleattribute for accessibility. - Consider
loading="lazy"on iframe if it's below the fold (minor). - Use
calc(200 / 192)→ better as1.0417or keep calc but ensure unitless division works —calc(200 / 192)is valid in modern CSS but dividing by unitless numbers is fine; just note older browser support if targeting legacy. - Cache the computed URL:
iframeUrlrecomputes on any reactive dependency change includinglocale; that's expected, but ifprops.configis large/unstable, memoization won't help here since it's alreadycomputed. Fine. - Locale mapping
locale.value === 'en-US' ? 'en' : 'zh'— brittle if more locales are added later. Consider a lookup map for extensibility.
Minor
- Comment is in Chinese while codebase/i18n otherwise — consistent with team style presumably, leave as is.
- Overall the change looks intentional and reasonable; main risks are the fragile pixel math and the removed
panel_sizeparameter.
| top: -15px; | ||
| } | ||
| } | ||
| </style> |
There was a problem hiding this comment.
Here's my review of the diff:
Potential Issues
-
Inconsistent offset vs. comment (most important). The comment says "扣除飞书 iframe 内部顶部 28px 留白" (accounting for 28px internal top padding), but the style uses
top: -15px. These don't match. If the goal is to cancel 28px of whitespace, either the comment or the value is wrong. This is a maintenance trap — clarify whether it's 28px or 15px and align both. -
height/widthmismatch with original layout. You changed from266→280and removed the explicitstyle. Previously the container was explicitly280x280with the QR itself at 266. Now you passwidth/height: '280'to the SDK. Verify the Lark QRLogin SDK accepts280and that the generated iframe actually sizes to 280; otherwise there may be a clipping/scaling regression. Also confirm'280'is a string — if the SDK expects numbers in some versions this could break. -
Negative
top+position: relativeleaves a gap. Moving the iframe up by 15px creates empty space at the bottom of the.lark-qr-layoutcontainer (and doesn't reclaim it). Consider usingmargin-top: -15pxinstead, which collapses layout space rather than visually overlapping. Otherwise themb-3spacing below may look off. -
Brittle
:deep(iframe)selector. It targets any iframe inside#lark-qr-code. If the SDK injects multiple nodes or changes structure, this could misfire. Consider scoping more tightly (e.g.,#lark-qr-code :deep(iframe)). -
Magic number.
-15pxis a magic offset tied to Lark's iframe internal padding. Add a brief note on why 15px, or define it as a CSS variable so it's easier to tune.
Minor / Optimization
- Mix of Tailwind + SCSS. You now have
mx-auto w-70plus a custom.lark-qr-layoutclass.w-70is a non-standard Tailwind value (default scale goesw-64,w-72); confirm your config supports it or usew-[280px]/w-[17.5rem]for clarity. - The
<img>lacks descriptive alt under the logo — unchanged, but notealt=""combined with an adjacent<h2>is acceptable here since the title conveys meaning. Fine as-is. width="24px"attribute on<img>— HTML width should be a unitless number (width="24") per spec;24pxworks in practice but is technically invalid. Could move to a class instead.- Event listener cleanup is correctly handled via
onBeforeUnmountand reassignment — good.
Summary
The main blocker is the comment/value inconsistency (28px vs 15px) and verifying the SDK accepts 280. The top: -15px approach also leaves dead space; margin-top is cleaner. Everything else is minor.
| transform-origin: top center; | ||
| } | ||
| } | ||
| </style> |
There was a problem hiding this comment.
Here are the observations:
Potential issues
-
Fragile magic numbers tied to third‑party SDK layout. The values
-48px,40px, andscale(7/6)depend on the current internal padding of the DingTalk SDK's QR iframe. If the SDK updates its layout, the QR code will be cropped or misaligned. Consider documenting the SDK version these were validated against, or detecting the iframe size at runtime. -
transform: scale()does not affect layout size. Scaling an iframe visually enlarges it but the element still occupies its original box. This is why the manualheight: calc(...)and negativemarginhacks are needed. This works but is brittle; it also means the QR is raster‑scaled (blurry on high‑DPI screens) since it's a scaled iframe, not a real vector resize. A better approach would be to let the SDK render at the correct size, or use CSSzoomif cross‑browser support is acceptable in your target browsers. -
Negative
margin-top: -48pxmay overlap the title. Withz-10on the heading, the heading now sits above the QR area — verify the QR isn't clipped or overlapping on small viewports / narrow layouts. -
Mixed units.
width: 280pxcombined withcalc((280px - 40px) * 7 / 6)is fine, but hard‑coding280pxin two places makes maintenance error‑prone. Extract to a CSS variable.--qr-size: 280px; --qr-inset: 40px; width: var(--qr-size); height: calc((var(--qr-size) - var(--qr-inset)) * 7 / 6);
-
:deep(iframe)applies to any iframe inside.ding-talk-layout. Fine today, but if the component later renders additional iframes this selector would affect them too. Scoping more tightly (#dingtalk-qr-code iframe) is safer. -
Accessibility. The new hint
<p>has no issue, but the logo<img alt="" />is decorative (good). Confirm the hint text isn't purely visual info that screen readers would miss — it should be fine as normal text. -
mb-3/mt-3spacing vs. the explicitmargin: -48px— the combination of utility margins and manual negative margin can make final spacing hard to reason about. Consider consolidating the vertical spacing logic in one place. -
No fallback if the iframe fails to load. The fixed height means an empty grey box if the SDK errors. Consider an error/loading state.
Optimization suggestions
- Replace hard‑coded values with CSS custom properties (see feat: 添加issues 模版 #4).
- Prefer rendering the QR at the desired size via the SDK's own config instead of CSS scaling, if the SDK exposes a size option.
- Add a comment (or test) tying these offsets to a specific SDK version.
- Consider
will-change: transformonly if you observe repaint jank (likely unnecessary here).
Overall the change is functional but relies on undocumented SDK internals; the main risk is future breakage when the SDK's iframe padding changes.
fix: improve third-party QR code login layouts