feat(profile): 实现个人资料编辑与策略本地缓存
- 将资料编辑页重构为可交互表单,支持昵称、签名编辑与头像更换 - 新增 DioClient 本地缓存读取与写入方法,支持离线读取策略快照 - 设备策略切换后自动使本地缓存失效,避免数据不一致 - Home Tab 切换时选中态跟随可见页面,滑动过程中实时更新底栏高亮 - 系统设置页引入 loading 遮罩层,防止切换开关时重复操作 - 个人资料页接入 profileController 展示真实用户信息与加载状态 - 适配深色模式,修正 home_tab 中头像与文字颜色硬编码问题
This commit is contained in:
1 parent
5f84a64c3e
commit
e06e12fbbc
30 files changed
+2059
-336
No files matched your search
@@ -163,6 +163,22 @@ class DioClient {
|
||||
}
|
||||
}
|
||||
|
||||
/// 读取当前账号的接口缓存,不发起网络请求。
|
||||
static Future<dynamic> readCachedGet(
|
||||
String path, {
|
||||
Map<String, dynamic>? queryParameters,
|
||||
}) async {
|
||||
final account = TokenStorage.currentAccountId;
|
||||
if (kIsWeb || account == null) return null;
|
||||
final version = TokenStorage.sessionVersion;
|
||||
final uri = Options()
|
||||
.compose(instance.options, path, queryParameters: queryParameters)
|
||||
.uri;
|
||||
final file = await ResponseCache.fileFor(account, uri);
|
||||
final cached = file == null ? null : await ResponseCache.read(file);
|
||||
return version == TokenStorage.sessionVersion ? cached?.data : null;
|
||||
}
|
||||
|
||||
/// 统一 GET 请求,返回解析后的 data。
|
||||
static Future<dynamic> get(
|
||||
String path, {
|
||||
@@ -259,6 +275,18 @@ class DioClient {
|
||||
if (file != null) await ResponseCache.remove(file);
|
||||
}
|
||||
|
||||
/// Update the local snapshot after an endpoint returns an updated resource.
|
||||
static Future<void> storeReadCache(String path, Object? data) async {
|
||||
final account = kIsWeb ? null : TokenStorage.currentAccountId;
|
||||
if (account == null) return;
|
||||
final version = TokenStorage.sessionVersion;
|
||||
final uri = Options().compose(instance.options, path).uri;
|
||||
final file = await ResponseCache.fileFor(account, uri);
|
||||
if (file != null && version == TokenStorage.sessionVersion) {
|
||||
await ResponseCache.write(file, data);
|
||||
}
|
||||
}
|
||||
|
||||
/// 统一 POST 请求,返回解析后的 data。
|
||||
static Future<dynamic> post(
|
||||
String path, {
|
||||
|
||||
Reference in new issue
Block a user