release
This commit is contained in:
@@ -415,6 +415,7 @@ class HomeController extends GetxController with NetworkListenerMixin {
|
||||
'keywords': true,
|
||||
'introduction': true,
|
||||
};
|
||||
update(); // 立即通知UI更新,显示骨架屏
|
||||
|
||||
try {
|
||||
final offlineDataManager = OfflineDataManager();
|
||||
@@ -490,7 +491,7 @@ class HomeController extends GetxController with NetworkListenerMixin {
|
||||
}
|
||||
}
|
||||
|
||||
// 模拟分步加载过程
|
||||
// 模拟分步加载过程 - 简化版,避免闪烁
|
||||
Future<void> simulateSectionLoading(PoetryData newPoetryData) async {
|
||||
// 记录浏览统计
|
||||
try {
|
||||
@@ -501,60 +502,27 @@ class HomeController extends GetxController with NetworkListenerMixin {
|
||||
// 忽略错误
|
||||
}
|
||||
|
||||
// 1. 加载标题区域
|
||||
var states = <String, bool>{};
|
||||
sectionLoadingStates.forEach((key, value) {
|
||||
states[key] = value;
|
||||
});
|
||||
states['title'] = false;
|
||||
sectionLoadingStates.assignAll(states);
|
||||
// 1. 立即更新所有数据
|
||||
poetryData.value = newPoetryData;
|
||||
update(); // 通知UI更新
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
|
||||
// 2. 加载诗句区域
|
||||
states = <String, bool>{};
|
||||
sectionLoadingStates.forEach((key, value) {
|
||||
states[key] = value;
|
||||
});
|
||||
states['name'] = false;
|
||||
sectionLoadingStates.assignAll(states);
|
||||
update(); // 通知UI更新
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
|
||||
// 3. 加载原文区域
|
||||
states = <String, bool>{};
|
||||
sectionLoadingStates.forEach((key, value) {
|
||||
states[key] = value;
|
||||
});
|
||||
states['content'] = false;
|
||||
sectionLoadingStates.assignAll(states);
|
||||
update(); // 通知UI更新
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
|
||||
// 4. 加载关键词区域
|
||||
states = <String, bool>{};
|
||||
sectionLoadingStates.forEach((key, value) {
|
||||
states[key] = value;
|
||||
});
|
||||
states['keywords'] = false;
|
||||
sectionLoadingStates.assignAll(states);
|
||||
keywordList.value = PoetryDataUtils.extractKeywords(newPoetryData);
|
||||
update(); // 通知UI更新
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
|
||||
// 5. 加载译文区域
|
||||
states = <String, bool>{};
|
||||
sectionLoadingStates.forEach((key, value) {
|
||||
states[key] = value;
|
||||
});
|
||||
states['introduction'] = false;
|
||||
sectionLoadingStates.assignAll(states);
|
||||
starDisplay.value = PoetryDataUtils.getStarDisplay(newPoetryData);
|
||||
isLiked.value = false;
|
||||
errorMessage.value = '';
|
||||
update(); // 通知UI更新
|
||||
|
||||
// 2. 短暂延迟后,一次性关闭所有加载状态
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
|
||||
// 一次性关闭所有加载状态
|
||||
sectionLoadingStates.value = {
|
||||
'title': false,
|
||||
'content': false,
|
||||
'name': false,
|
||||
'keywords': false,
|
||||
'introduction': false,
|
||||
};
|
||||
update();
|
||||
|
||||
checkIfLiked();
|
||||
updateCurrentHistoryIndex();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user