Skip to content

fix: 随机口令看得见、能复制、创建后不丢失 - #11

Merged
Freecode100Year merged 1 commit into
mainfrom
fix/visible-password
Oct 30, 2026
Merged

Freecode100Year merged 1 commit into
mainfrom
fix/visible-password

Conversation

@Freecode100Year

Copy link
Copy Markdown
Owner

问题

「随机生成口令」把口令填进了密码框:看不见,浏览器也不允许从密码框复制;房间创建完后口令框还会被清空,口令实际上就丢了。

修复

  • 口令好念好抄:5 组、每组 4 个字符,例如 K7QM-3XRP-9DTA-HWVE-N4BC。字母表去掉了 I、L、O、0、1 这些容易看错的字符;强度约 99 位,随机数做了去偏处理。
  • 生成后直接显示:旁边有「复制口令」和「显示 / 隐藏」按钮。
  • 创建后保留:房间建好后,口令仍显示在结果里,并附复制按钮和「换一种方式告诉朋友」的提醒。
  • 进房页面:口令框也有「显示」按钮。
  • 复制的兼容性:剪贴板接口不可用时(部分本地文件或 App 内置浏览器),退回「选中后复制」;失败时文字保持选中状态,可以手动复制。
  • 手机显示:口令框改用等宽字体,在 360 像素宽的手机上也能完整显示。

测试

新增 browser-tests/password-ui.mjs:

  • 生成的口令可见、格式正确,复制后剪贴板内容一致;
  • 显示 / 隐藏可以切换;
  • 创建后结果里保留口令,也能复制;
  • 这串口令能解锁房间并真正进房;
  • 本地文件在没有剪贴板权限时,会退回「选中后复制」。

全部单元测试、10 个浏览器测试和 Pages 测试通过。


Generated by Claude Code

The random password went into a hidden password field (browsers forbid
copying from it) and the field was cleared after creating the room, so
the password was effectively lost. Now:
- readable password: 5 groups of 4 from 31 unambiguous characters (~99 bits)
- shown after generating, with a copy button and a show/hide toggle
- kept on the result after creating, with its own copy button
- show/hide on the room's password field too
- copy falls back to select-and-copy where the Clipboard API is refused
- monospace password fields that fit a 360 px phone

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PCUwNSXQdqfDSugmFo4qmM
@Freecode100Year
Freecode100Year merged commit 37f9bcd into main Oct 30, 2026
16 checks passed
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