fix(app-iced, presenter): M114 r3 —— 登录成功提示走 i18n key+参数,离线名字提交判据与 host 同源

- 新增 Key::AccountLoginSucceeded(Signed in as {name} / 已登录 {name}):
  presenter 不再拼「已登录:{name}」这类人类可读句子(复审 r1 P1-1 的收尾)
- valid_offline_name 从 host 搬到 dto(UI 与 host 共用的同一个判据),
  Form::offline_ready 改用它:按钮不再「亮着但必然失败」
- 视图模型测试:成功提示按 i18n 渲染进 on_screen;离线提交判据加「太短也拒绝」断言
This commit is contained in:
AskaEth committed 2026-11-05 05:09:52 +08:00
1 parent 8d8552113a
commit 9d0d985b1b
9 files changed
+38 -21

No files matched your search

+11
View File
@@ -76,6 +76,17 @@ impl AccountView {
}
}
/// 离线名字的**界面契约**(3–16 位 ascii 字母/数字/下划线)。
///
/// 放在 `dto` 而不是 host 里:它是 UI(提交按钮能不能点)与 host(写盘前的最后一道校验)
/// 共用的**同一个判据**——两处各写一遍就会出现「按钮亮着但必然失败」的坑。
/// core 侧还有一道同名规则做兜底(`offline_meta`),这里只管界面这条。
#[must_use]
pub fn valid_offline_name(name: &str) -> bool {
let len = name.chars().count();
(3..=16).contains(&len) && name.chars().all(|c| c.is_ascii_alphanumeric() || c == '_')
}
/// 一张皮肤原图。
///
/// **停在「原图」这一层是刻意的**:presenter 不引入图片解码依赖(`presenter-no-ui` +
+3 -3
View File
@@ -29,9 +29,9 @@ mod settings;
mod versions;
pub use accounts::{
looks_like_jwt, redact, AccountKind, AccountNotice, AccountNoticeCode, AccountView,
AuthlibLoginView, AuthlibRequest, DeviceLoginPhase, DeviceLoginView, LoginFailure, SkinImage,
REDACTED,
looks_like_jwt, redact, valid_offline_name, AccountKind, AccountNotice, AccountNoticeCode,
AccountView, AuthlibLoginView, AuthlibRequest, DeviceLoginPhase, DeviceLoginView, LoginFailure,
SkinImage, REDACTED,
};
pub use agent::{AgentEvent, ChatMessage, ChatRole, ConfirmRequest, Sensitivity, ToolCallView};
pub use content::{
+3 -2
View File
@@ -21,7 +21,8 @@ use unlucky_core::download::blocking::block_on;
use crate::dto::CoreEvent;
use crate::dto::{
AccountKind, AccountNotice, AccountNoticeCode, AccountView, DeviceLoginView, LoginFailure,
valid_offline_name, AccountKind, AccountNotice, AccountNoticeCode, AccountView,
DeviceLoginView, LoginFailure,
};
use super::env::HostEnv;
@@ -33,7 +34,7 @@ pub mod authlib;
mod failure;
pub use failure::{valid_offline_name, AccountFailure};
pub use failure::AccountFailure;
use failure::classify;
@@ -33,13 +33,6 @@ impl AccountFailure {
}
}
/// 离线名字的界面契约(3–16 位 ascii 字母/数字/下划线)。core 侧还有一道同名规则做兜底。
#[must_use]
pub fn valid_offline_name(name: &str) -> bool {
let len = name.chars().count();
(3..=16).contains(&len) && name.chars().all(|c| c.is_ascii_alphanumeric() || c == '_')
}
/// `AuthError` → 原因码(**只看变体与 ascii 码,不看中文文案**)。
pub(super) fn classify(error: &AuthError) -> LoginFailure {
match error {