feat(client): P6 DevicesScreen 重做 + DevicePlatform 枚举
ci-pangolin / Lint — shellcheck (push) Successful in 7s
ci-pangolin / OpenAPI Sync Check (push) Successful in 19s
ci-pangolin / Redline Scan — 脱敏 (UI 文案) (push) Successful in 7s
ci-pangolin / Flutter — analyze + test (push) Successful in 23s
ci-pangolin / Portable SQL — 可移植性 (mysql/sqlite) (push) Successful in 5s
ci-pangolin / Codegen Drift — token 生成物未漂移 (push) Successful in 5s
ci-pangolin / Go — build + test (push) Successful in 9s
ci-pangolin / E2E Smoke — L4 进程级端到端 (push) Successful in 14s
ci-pangolin / Go — integration (mysql/redis testcontainers) (push) Failing after 4m12s
ci-pangolin / Golden — 视觉回归 (components + auth) (push) Successful in 15s

回应「状态码用枚举更好」:新增 DevicePlatform 枚举(线格式 fromWire 解析,
UI 只碰枚举,穷尽 switch),Device.platformKind getter;platform 图标按枚举 switch。
DevicesScreen 按 §7 视觉稿重做:行内 名称+「本机」标 / 平台·客户端版本·最后登录 /
在线绿点光晕·离线灰点 + 行尾 ⋯ 菜单(强制退出 / 清除登录信息·危险红)+ 危险二次
确认弹窗;本机行不显示 ⋯(不自我踢)。l10n 新增在线/离线/最后登录/从未登录/强制
退出/清除登录信息/取消 + 确认文案(中英);「当前设备」改「本机」。
新图标 moreVertical/trash/alertTriangle。localDeviceIdProvider 供本机判定。
测试:devices_screen widget 3 例(本机标+在线/离线+版本渲染 / ⋯菜单→强制退出→
确认→POST logout / 清除→DELETE);全量 flutter test 58 绿。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-29 06:10:37 +08:00
parent bcc114088c
commit 58526b09e6
9 changed files with 332 additions and 26 deletions
+37 -1
View File
@@ -1,4 +1,37 @@
// device.dart — 已登录设备(GET /v1/me/devices)。
/// 设备平台。线格式是字符串(与服务端 devices.platform 对齐),在 model 边界经
/// [fromWire] 解析为枚举,UI/逻辑层只碰枚举(穷尽 switch + 拼错编译期报错)。
enum DevicePlatform {
ios,
android,
windows,
macos,
linux,
unknown;
static DevicePlatform fromWire(String s) => switch (s.toLowerCase().trim()) {
'ios' => DevicePlatform.ios,
'android' => DevicePlatform.android,
'windows' => DevicePlatform.windows,
'macos' => DevicePlatform.macos,
'linux' => DevicePlatform.linux,
_ => DevicePlatform.unknown,
};
/// 展示名(大小写规范化)。
String get label => switch (this) {
DevicePlatform.ios => 'iOS',
DevicePlatform.android => 'Android',
DevicePlatform.windows => 'Windows',
DevicePlatform.macos => 'macOS',
DevicePlatform.linux => 'Linux',
DevicePlatform.unknown => '',
};
bool get isMobile => this == DevicePlatform.ios || this == DevicePlatform.android;
}
class Device {
const Device({
required this.uuid,
@@ -13,9 +46,12 @@ class Device {
final String uuid;
final String name;
/// 'ios' | 'android' | 'windows' | 'macos' | 'linux'
/// 平台线格式(原始字符串,保留以便回传/调试)。UI 用 [platformKind]
final String platform;
/// 平台枚举(由线格式解析)。
DevicePlatform get platformKind => DevicePlatform.fromWire(platform);
/// 最近活跃(UTC);从未上线为 null。
final DateTime? lastSeen;