Skip to content

fix: improve third-party QR code login layouts - #8098

Merged
wangdan-fit2cloud merged 1 commit into
v3from
pr@v3@fix_qr_login_layout
Nov 23, 2026
Merged

wangdan-fit2cloud merged 1 commit into
v3from
pr@v3@fix_qr_login_layout

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: improve third-party QR code login layouts

transform-origin: top center;
}
}
</style>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's my review of the diff:

Potential Issues

  1. Missing t usage was fixed, but verify i18n keys exist — You added t from useI18n. Ensure auth.qrCode.title, auth.methods.wecom keys are defined in both locales; otherwise runtime warnings/fallback may appear.

  2. Hard-coded pixel values for iframe cropping (fragile) — -104px, 280px, 192px, 200px are 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.

  3. scrolling="no" on iframe — Deprecated attribute in HTML5 (still widely supported, but non-standard). Prefer CSS overflow: hidden (already applied to container) and/or note it's a legacy fallback. Not blocking.

  4. transform: scale combined with top offset — The negative top shifts the element before transform, then scaling happens around transform-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.

  5. 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.

  6. alt="" on logo image — Acceptable for decorative image alongside text heading, so fine. But if it conveys meaning, give it alt.

  7. Accessibility — The title is now an <h2>; good. Consider aria-label on iframe for screen readers (iframes without title are an a11y issue): add title="WeCom login" or similar.

  8. 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-coded height on .wecom-qr-layout may conflict with responsive needs; consider max-height or 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 title attribute for accessibility.
  • Consider loading="lazy" on iframe if it's below the fold (minor).
  • Use calc(200 / 192) → better as 1.0417 or 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: iframeUrl recomputes on any reactive dependency change including locale; that's expected, but if props.config is large/unstable, memoization won't help here since it's already computed. 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_size parameter.

top: -15px;
}
}
</style>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's my review of the diff:

Potential Issues

  1. 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.

  2. height/width mismatch with original layout. You changed from 266→280 and removed the explicit style. Previously the container was explicitly 280x280 with the QR itself at 266. Now you pass width/height: '280' to the SDK. Verify the Lark QRLogin SDK accepts 280 and 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.

  3. Negative top + position: relative leaves a gap. Moving the iframe up by 15px creates empty space at the bottom of the .lark-qr-layout container (and doesn't reclaim it). Consider using margin-top: -15px instead, which collapses layout space rather than visually overlapping. Otherwise the mb-3 spacing below may look off.

  4. 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)).

  5. Magic number. -15px is 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

  1. Mix of Tailwind + SCSS. You now have mx-auto w-70 plus a custom .lark-qr-layout class. w-70 is a non-standard Tailwind value (default scale goes w-64, w-72); confirm your config supports it or use w-[280px] / w-[17.5rem] for clarity.
  2. The <img> lacks descriptive alt under the logo — unchanged, but note alt="" combined with an adjacent <h2> is acceptable here since the title conveys meaning. Fine as-is.
  3. width="24px" attribute on <img> — HTML width should be a unitless number (width="24") per spec; 24px works in practice but is technically invalid. Could move to a class instead.
  4. Event listener cleanup is correctly handled via onBeforeUnmount and 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.

@wangdan-fit2cloud
wangdan-fit2cloud merged commit 2112f1c into v3 Nov 23, 2026
3 of 4 checks passed
@wangdan-fit2cloud
wangdan-fit2cloud deleted the pr@v3@fix_qr_login_layout branch November 23, 2026 11:23
transform-origin: top center;
}
}
</style>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are the observations:

Potential issues

  1. Fragile magic numbers tied to third‑party SDK layout. The values -48px, 40px, and scale(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.

  2. 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 manual height: calc(...) and negative margin hacks 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 CSS zoom if cross‑browser support is acceptable in your target browsers.

  3. Negative margin-top: -48px may overlap the title. With z-10 on the heading, the heading now sits above the QR area — verify the QR isn't clipped or overlapping on small viewports / narrow layouts.

  4. Mixed units. width: 280px combined with calc((280px - 40px) * 7 / 6) is fine, but hard‑coding 280px in 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);
  5. :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.

  6. 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.

  7. mb-3 / mt-3 spacing vs. the explicit margin: -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.

  8. 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: transform only 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants