mothercup/SmartAssiter/docs/修改记录_2026-07-17_登录页历史账号选择.md
2026-09-04 08:56:15 +08:00

32 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 修改记录:登录页历史账号选择
日期:2026-07-17
本次修改在登录页新增**历史账号记录**功能:登录成功的账号密码都会保存到本地历史列表,下次登录时可直接选择回填,无需再次输入。
## 1. 历史账号存储层
### `common/auth.uts`
新增 `AccountRecord` 类型(`account` + `password`)及 3 个方法:
- `getAccountHistory()`:读取历史账号列表(最新登录的在前)。数据以 JSON 字符串存于本地存储 key `accountHistory`,解析失败时安全返回空数组。
- `addAccountHistory(account, password)`:保存一条历史记录,同账号去重并置顶,最多保留 5 条(`ACCOUNT_HISTORY_MAX`)。
- `removeAccountHistory(account)`:删除指定账号的历史记录。
## 2. 登录页 UI 与逻辑
### `pages/login/login.uvue`
- 密码登录表单「remember password」下方新增「saved accounts (n)」折叠行,点击展开/收起历史账号列表(`historyOpen`);无历史记录时整个入口不显示。
- 点击列表中某条账号:自动回填账号 + 密码,自动勾选「remember password」,并收起列表(`onPickHistory`)。
- 每条记录右侧「✕」可单独删除该条历史(`onRemoveHistory`,`@tap.stop` 阻止触发选中)。
- `onLoad` 时调用 `getAccountHistory()` 加载历史列表(`historyList`)。
- 密码登录成功后无条件调用 `addAccountHistory()` 写入历史;原有单账号「记住密码」(`savedAccount` / `savedPassword`)逻辑保持不变。
- 新增样式:`.history-row` / `.history-text` / `.history-list` / `.history-item` / `.history-account` / `.history-del`。
## 注意事项
- 历史账号的密码以**明文**存储在本地 storage(`accountHistory`),与已有 `savedPassword` 相同,仅适合内部测试用途;如需对外发布,建议改为加密存储或仅保存账号。
- 历史列表上限 5 条,超出时最旧的记录被移除;清除应用数据后历史记录丢失。