feat(devices): 设备默认名「平台简写·主机名」+ 支持重命名(1.0.13)
ci-pangolin / Lint — shellcheck (push) Successful in 7s
ci-pangolin / OpenAPI Sync Check (push) Successful in 17s
ci-pangolin / Redline Scan — 脱敏 (UI 文案) (push) Successful in 6s
ci-pangolin / Flutter — analyze + test (push) Failing after 14s
ci-pangolin / Portable SQL — 可移植性 (mysql/sqlite) (push) Successful in 5s
ci-pangolin / Codegen Drift — token 生成物未漂移 (push) Successful in 6s
ci-pangolin / Go — build + test (push) Successful in 11s
ci-pangolin / E2E Smoke — L4 进程级端到端 (push) Successful in 14s
ci-pangolin / Go — integration (mysql/redis testcontainers) (push) Failing after 4m3s
ci-pangolin / Golden — 视觉回归 (components + auth) (push) Successful in 14s
ci-pangolin / Lint — shellcheck (push) Successful in 7s
ci-pangolin / OpenAPI Sync Check (push) Successful in 17s
ci-pangolin / Redline Scan — 脱敏 (UI 文案) (push) Successful in 6s
ci-pangolin / Flutter — analyze + test (push) Failing after 14s
ci-pangolin / Portable SQL — 可移植性 (mysql/sqlite) (push) Successful in 5s
ci-pangolin / Codegen Drift — token 生成物未漂移 (push) Successful in 6s
ci-pangolin / Go — build + test (push) Successful in 11s
ci-pangolin / E2E Smoke — L4 进程级端到端 (push) Successful in 14s
ci-pangolin / Go — integration (mysql/redis testcontainers) (push) Failing after 4m3s
ci-pangolin / Golden — 视觉回归 (components + auth) (push) Successful in 14s
① 默认名:DeviceIdentity 改「平台简写(Win/Mac/Linux/iOS/Andr)·主机名」,主机名截
到 8、总长≈12(替代裸主机名,更短)。
② 重命名:新端点 POST /v1/me/devices/{uuid}/rename(Service.RenameDevice 校验归属+
截 64);store.UpdateName;客户端 account_api.renameDevice + provider.rename +
「我的设备」⋯ 菜单加「重命名」+ 输入弹窗;l10n(zh/en)。
③ 版本 1.0.13。
测试:server RenameDevice(归属/空名/404)+ 客户端 rename widget;全量 go/flutter 绿。
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -64,6 +64,11 @@ class AccountApi {
|
||||
await _c.postJson('/v1/me/devices/$uuid/logout');
|
||||
}
|
||||
|
||||
/// POST /v1/me/devices/{uuid}/rename — 重命名设备。
|
||||
Future<void> renameDevice(String uuid, String name) async {
|
||||
await _c.postJson('/v1/me/devices/$uuid/rename', {'name': name});
|
||||
}
|
||||
|
||||
/// GET /v1/usage?days=N&tz_offset=M — 最近 N 天用量(默认 7,后端范围 [1,90])。
|
||||
/// 带本机时区偏移(分钟,如 UTC+8=480),服务端按「本地日」聚合 → 「今天」与本地日历一致
|
||||
/// (修「29 号却显示 28 号数据」的时区 bug)。
|
||||
|
||||
@@ -103,21 +103,37 @@ class DeviceIdentity {
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
/// 平台简写(默认名前缀,保持短)。
|
||||
static String _shortPlatform(String p) => switch (p) {
|
||||
'windows' => 'Win',
|
||||
'macos' => 'Mac',
|
||||
'linux' => 'Linux',
|
||||
'ios' => 'iOS',
|
||||
'android' => 'Andr',
|
||||
_ => p,
|
||||
};
|
||||
|
||||
// 默认名 = 平台简写·主机名(桌面用主机名,移动用机型);主机名截到 8、总长≈12,尽量短。
|
||||
// 用户可在「我的设备」改名覆盖。
|
||||
Future<String> _name() async {
|
||||
var host = '';
|
||||
try {
|
||||
if (Platform.isIOS) {
|
||||
final i = await DeviceInfoPlugin().iosInfo;
|
||||
return i.name.isNotEmpty ? i.name : i.utsname.machine;
|
||||
}
|
||||
if (Platform.isAndroid) {
|
||||
host = i.name.isNotEmpty ? i.name : i.utsname.machine;
|
||||
} else if (Platform.isAndroid) {
|
||||
final a = await DeviceInfoPlugin().androidInfo;
|
||||
return '${a.manufacturer} ${a.model}'.trim();
|
||||
host = a.model;
|
||||
} else {
|
||||
host = Platform.localHostname;
|
||||
}
|
||||
// 桌面:主机名最有意义(MacBook-Pro / DESKTOP-XXXX)。
|
||||
return Platform.localHostname;
|
||||
} catch (_) {
|
||||
return currentPlatform();
|
||||
host = '';
|
||||
}
|
||||
host = host.trim();
|
||||
if (host.length > 8) host = host.substring(0, 8);
|
||||
final short = _shortPlatform(currentPlatform());
|
||||
return host.isEmpty ? short : '$short·$host';
|
||||
}
|
||||
|
||||
Future<String> _clientVersion() async {
|
||||
|
||||
Reference in New Issue
Block a user