feat(app-iced): M114 账户页三轨登录(微软正版 / 第三方皮肤站 / 本地档案)

- 账户页:当前账户卡 + 全部账户列表 + 空态三入口 + 皮肤区;五项动作(添加/切换/删除/重新登录/校验)
- 三轨添加流程:设备码(用户码+链接+倒计时+过期重试+取消)、授权码(浏览器+可复制链接+取消)、
  本地档案(名字校验)、第三方站(服务地址 + 服务发现校验 + 密码登录,密码掩码且用完即弃)
- 导航:账户为一等页,入口是轨底头像位(未登录=描边剪影 / 已登录=首字母块+名字;窄高收成图标条)
- 凭据红线:DTO 侧形状脱敏 + 状态层二次脱敏 + 密码掩码;Inject-JWT 测试断言视图模型干净(已做变异取证)
- presenter:authlib 登录/服务发现/皮肤抓取(复用下载引擎的 HTTP 客户端,无新增依赖)、
  皮肤原图经 DTO 到 UI 裁剪成头像(既有 image 依赖,未改 Cargo.toml)
- i18n:新增 account 域 51 条中英文案(离线档案口径全量写入),金表同步
This commit is contained in:
AskaEth committed 2026-11-05 05:08:35 +08:00
1 parent e7b04c4afe
commit 1ff00bbe50
43 files changed
+4343 -117

No files matched your search

+233
View File
@@ -0,0 +1,233 @@
//! 账户列表:当前账户卡片 + 全部账户行 + 皮肤预览区。
use iced::widget::{column, container, image, row, space};
use iced::{Alignment, ContentFit, Element, Length};
use unlucky_design::color::Role;
use unlucky_design::spacing::Space;
use unlucky_design::typography::TypeRole;
use unlucky_i18n::{Catalog, Key, Lang};
use crate::app::components::buttons::{self, Button};
use crate::pages::frame;
use crate::theme::Ui;
use crate::pages::account::{model::Page as Model, widgets};
use crate::pages::Message as PageMessage;
use super::Message as Account;
/// 当前账户卡片(含皮肤预览区)。
pub fn active_card<'a>(
ui: &'a Ui,
page: &'a Model,
catalog: Catalog,
lang: Lang,
) -> Element<'a, PageMessage> {
let Some(current) = page.active_row() else {
return container(space::vertical()).into();
};
let _ = lang;
let mut actions = row![]
.spacing(ui.space(Space::X2))
.align_y(Alignment::Center);
actions = actions.push(buttons::text(
ui,
Button::new(
catalog.text(Key::AccountRelogin),
Account::Relogin.into_page(),
),
));
actions = actions.push(buttons::text(
ui,
Button::new(
catalog.text(Key::AccountRemove),
Account::Remove(current.id.clone()).into_page(),
),
));
let mut name_line = row![
frame::text_role(
ui,
TypeRole::TitleMedium,
true,
&current.name,
ui.color(Role::OnSurface),
),
widgets::badge(ui, &current.kind_label, false),
]
.spacing(ui.space(Space::X2))
.align_y(Alignment::Center);
if current.active {
name_line = name_line.push(widgets::badge(
ui,
catalog.text(Key::AccountActiveChip),
true,
));
}
let identity = column![
name_line,
frame::text_role(
ui,
TypeRole::BodySmall,
false,
&current.added,
ui.color(Role::OnSurfaceVariant),
),
]
.spacing(ui.space(Space::X1));
let left = row![
widgets::avatar(ui, current, widgets::AVATAR_ACTIVE),
container(identity).width(Length::Fill),
actions,
]
.spacing(ui.space(Space::X4))
.align_y(Alignment::Center);
let mut body = column![
widgets::section(ui, catalog.text(Key::AccountCurrentTitle), None),
left,
]
.spacing(ui.space(Space::X4));
if let Some(skin) = page.active_skin() {
body = body.push(skin_preview(ui, skin.clone(), catalog));
}
frame::card(ui, body)
}
/// 皮肤预览区:**原图直出**(64×64),旁边一句话说清「皮肤从哪来」。
fn skin_preview<'a>(
ui: &'a Ui,
skin: iced::widget::image::Handle,
catalog: Catalog,
) -> Element<'a, PageMessage> {
let size = ui.space(Space::X8) * 2.0;
row![
container(
image(skin)
.width(Length::Fixed(size))
.height(Length::Fixed(size))
.content_fit(ContentFit::Contain),
)
.width(Length::Fixed(size))
.height(Length::Fixed(size)),
column![
frame::text_role(
ui,
TypeRole::LabelMedium,
true,
catalog.text(Key::AccountSkinTitle),
ui.color(Role::OnSurface),
),
frame::text_role(
ui,
TypeRole::BodySmall,
false,
catalog.text(Key::AccountSkinHint),
ui.color(Role::OnSurfaceVariant),
),
]
.spacing(ui.space(Space::X1)),
]
.spacing(ui.space(Space::X4))
.align_y(Alignment::Center)
.into()
}
/// 「全部账户」列表。
pub fn list<'a>(
ui: &'a Ui,
page: &'a Model,
catalog: Catalog,
lang: Lang,
) -> Element<'a, PageMessage> {
let _ = lang;
let mut items = column![widgets::section(
ui,
catalog.text(Key::AccountListTitle),
None
)]
.spacing(ui.space(Space::X3));
for row in &page.rows {
items = items.push(item(ui, row, catalog));
}
frame::card(ui, items)
}
/// 一行账户。
fn item<'a>(
ui: &'a Ui,
row: &'a crate::pages::account::model::Row,
catalog: Catalog,
) -> Element<'a, PageMessage> {
let mut detail = column![
frame::text_role(
ui,
TypeRole::LabelMedium,
false,
&row.name,
ui.color(Role::OnSurface),
),
frame::text_role(
ui,
TypeRole::BodySmall,
false,
&row.added,
ui.color(Role::OnSurfaceVariant),
),
]
.spacing(ui.space(Space::X1));
if !row.detail.is_empty() {
detail = detail.push(frame::text_role(
ui,
TypeRole::BodySmall,
false,
&row.detail,
ui.color(Role::OnSurfaceVariant),
));
}
let mut trailing = row![widgets::badge(ui, &row.kind_label, false),]
.spacing(ui.space(Space::X2))
.align_y(Alignment::Center);
if row.active {
trailing = trailing.push(widgets::badge(
ui,
catalog.text(Key::AccountActiveChip),
true,
));
} else {
trailing = trailing.push(buttons::text(
ui,
Button::new(
catalog.text(Key::AccountSwitch),
Account::Switch(row.id.clone()).into_page(),
),
));
}
trailing = trailing.push(buttons::text(
ui,
Button::new(
catalog.text(Key::AccountRemove),
Account::Remove(row.id.clone()).into_page(),
),
));
row![
widgets::avatar(ui, row, widgets::AVATAR_LIST),
container(detail).width(Length::Fill),
trailing,
]
.spacing(ui.space(Space::X3))
.align_y(Alignment::Center)
.padding(iced::Padding::from([0.0, ui.space(Space::X2)]))
.into()
}