feat(theme): 添加全局深色模式支持与主题适配
- 引入 DarkMode 工具类,提供系统栏、颜色、色调的暗色适配能力 - AppColors 调色板改为 CupertinoDynamicColor.withBrightness 自适应 - app.dart 增加 AnnotatedRegion 与 Material Theme 包裹以联动暗色系统栏 - 移除 system_ui_util 中硬编码的浅色图标配置,改由主题驱动 - CardBox、AppDivider、SectionTitle 等公共组件适配深色卡片与分割线 - settings_ui、change_mobile、change_password、login_devices、wechat_binding 等页面全面接入 DarkMode 颜色 - dio_client 新增 allowStale 响应缓存机制,网络异常时回退本地缓存 - token_storage 增加 currentAccountId(JWT 解析)及按用户隔离的设备偏好存取 - ApiException 改为通过私有构造持有真实 AppError 实例,appError getter 返回结构化错误 - 闹钟模块迁移至 FutureProvider.autoDispose.family,消除手动 loading 状态管理 - 闹钟编辑页 CupertinoTimerPicker 替换为 CupertinoDatePicker(24h 格式),标签输入改为 TextEditingController
This commit is contained in:
1 parent
861c404017
commit
71dd8eb52c
61 files changed
+1639
-588
No files matched your search
@@ -22,6 +22,7 @@ class DeviceApi {
|
||||
try {
|
||||
final data = await DioClient.get(
|
||||
'v1/client/sn/my-devices',
|
||||
allowStale: true,
|
||||
);
|
||||
return _parseList(data, DeviceBrief.fromJson);
|
||||
} on ApiException {
|
||||
@@ -63,6 +64,7 @@ class DeviceApi {
|
||||
'v1/client/sn/unbind',
|
||||
queryParameters: {'sn': sn},
|
||||
);
|
||||
await DioClient.invalidateReadCache('v1/client/sn/my-devices');
|
||||
debugPrint('[DeviceApi] unbindDevice sn=$sn data=$data');
|
||||
return null;
|
||||
} on ApiException catch (e) {
|
||||
@@ -76,6 +78,7 @@ class DeviceApi {
|
||||
try {
|
||||
final data = await DioClient.get(
|
||||
'v1/client/sn/device-info',
|
||||
allowStale: true,
|
||||
queryParameters: {'sn': sn},
|
||||
);
|
||||
return data is Map<String, dynamic> ? DeviceSystemInfo.fromJson(data) : null;
|
||||
@@ -89,6 +92,7 @@ class DeviceApi {
|
||||
try {
|
||||
final data = await DioClient.get(
|
||||
'v1/client/sn/location',
|
||||
allowStale: true,
|
||||
queryParameters: {'sn': sn},
|
||||
);
|
||||
return data is Map<String, dynamic> ? DeviceLocation.fromJson(data) : null;
|
||||
@@ -102,6 +106,7 @@ class DeviceApi {
|
||||
try {
|
||||
final data = await DioClient.get(
|
||||
'v1/client/sn/apks',
|
||||
allowStale: true,
|
||||
queryParameters: {'sn': sn},
|
||||
);
|
||||
return _parseList(data, DeviceApkInfo.fromJson);
|
||||
@@ -280,6 +285,7 @@ class DeviceApi {
|
||||
try {
|
||||
final data = await DioClient.get(
|
||||
'v1/client/sn/wallpaper',
|
||||
allowStale: true,
|
||||
queryParameters: {'sn': sn},
|
||||
);
|
||||
return data is Map<String, dynamic>
|
||||
@@ -318,31 +324,46 @@ class DeviceApi {
|
||||
/// 查询已发送到设备的图片列表(家属端)。
|
||||
///
|
||||
/// 对应后台 `GET /api/v1/client/sn/picture/list?sn=xxx`(按发送时间倒序)。
|
||||
/// 返回补全源地址的图片信息列表(含收藏状态);无记录或失败时返回空列表。
|
||||
/// 返回补全源地址的图片信息列表(含收藏状态)。
|
||||
Future<List<DevicePictureInfo>> getPictureList(String sn) async {
|
||||
try {
|
||||
final payload = await DioClient.get(
|
||||
'v1/client/sn/picture/list',
|
||||
queryParameters: {'sn': sn},
|
||||
);
|
||||
final listData = payload is List
|
||||
? payload
|
||||
: (payload is Map && payload['data'] is List
|
||||
? payload['data'] as List
|
||||
: const <dynamic>[]);
|
||||
final origin = Uri.parse(AppConstants.kBaseUrl).origin;
|
||||
return listData.whereType<Map>().map((e) {
|
||||
final vo = DevicePictureInfo.fromJson(
|
||||
e.map((k, v) => MapEntry(k.toString(), v)));
|
||||
return DevicePictureInfo(
|
||||
url: vo.url.startsWith('/') ? '$origin${vo.url}' : vo.url,
|
||||
favorite: vo.favorite,
|
||||
fileSize: vo.fileSize,
|
||||
);
|
||||
}).toList(growable: false);
|
||||
} on ApiException {
|
||||
return const [];
|
||||
final payload = await DioClient.get(
|
||||
'v1/client/sn/picture/list',
|
||||
allowStale: true,
|
||||
queryParameters: {'sn': sn},
|
||||
);
|
||||
final list = payload is Map ? payload['data'] : payload;
|
||||
if (list is! List) throw const FormatException('Invalid picture list');
|
||||
final base = Uri.parse(AppConstants.kBaseUrl);
|
||||
final pictures = <DevicePictureInfo>[];
|
||||
for (final row in list.whereType<Map>()) {
|
||||
if (row['url'] is! String) continue;
|
||||
final picture = DevicePictureInfo.fromJson(Map<String, dynamic>.from(row));
|
||||
final path = picture.url.trim();
|
||||
if (path.isEmpty) continue;
|
||||
final relative = Uri.tryParse(path);
|
||||
if (relative == null) continue;
|
||||
final uri = base.resolveUri(relative);
|
||||
if (!uri.isScheme('http') && !uri.isScheme('https')) continue;
|
||||
pictures.add(DevicePictureInfo(
|
||||
url: uri.toString(),
|
||||
sourceUrl: picture.url,
|
||||
favorite: picture.favorite,
|
||||
fileSize: picture.fileSize,
|
||||
));
|
||||
}
|
||||
return pictures;
|
||||
}
|
||||
|
||||
Future<void> deletePicture(String sn, String url) async {
|
||||
final uri = Uri(
|
||||
path: 'v1/client/sn/picture',
|
||||
queryParameters: {'sn': sn, 'url': url},
|
||||
);
|
||||
await DioClient.delete(uri.toString());
|
||||
await DioClient.invalidateReadCache(
|
||||
'v1/client/sn/picture/list',
|
||||
queryParameters: {'sn': sn},
|
||||
);
|
||||
}
|
||||
|
||||
/// 设置图片收藏状态(家属端)。
|
||||
@@ -415,6 +436,7 @@ class DeviceApi {
|
||||
// 后台返回结构为 { code, msg, data: [...] },故此处 payload 即为截图数组。
|
||||
final payload = await DioClient.get(
|
||||
'v1/client/sn/upload-screenshot',
|
||||
allowStale: true,
|
||||
queryParameters: query,
|
||||
);
|
||||
// 防御性提取:兼容后台直接返回 List,或返回 { data: [...] } 的包裹结构。
|
||||
|
||||
Reference in new issue
Block a user