从下载记录,收藏夹和已下载页面进入漫画详情页支持离线先本地后网络的分阶段加载#270
Open
FC383 wants to merge 32 commits into
Open
Conversation
comic_page.dart 中 ComicPageLogic.get() 原为"全网络或全无"模式, 无网络时 data 为 null,直接显示 NetworkError,用户看不到任何信息。 改为"先本地、后网络"两阶段加载: - 阶段1:立即从下载记录/阅读历史提取本地已有的标题、封面, 先渲染页面使收藏/删除下载等操作按钮离线可用 - 阶段2:同时发起网络请求获取完整数据,成功后覆盖本地数据 具体改动: - ComicPageLogic 新增 networkMessage、loadLocalData 字段 - get() 拆分为两个阶段,本地数据命中时提前 setState 渲染 - BaseComicPage 新增 loadLocalData() 方法(默认返回 null,不影响已有子类) - _ComicPageImpl.loadLocalData() 按优先级查询下载记录→阅读历史 - loadFavorite() 改为 OR 逻辑,平台和本地任意一边收藏即为"已收藏" - build() 注入 loadLocalData 回调,网络失败时 toast 提示 - refresh_() 清空 networkMessage 状态 仅影响走 _ComicPageImpl 路径的自定义源; 内置源的 PicacgComicPage 等子类 loadLocalData 默认 null,行为不变。
Author
|
6 个内置漫画源详情页新增离线分阶段加载。 comic_page.dart:BaseComicPage 新增 6 个页面:各新增
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
漫画详情页离线体验优化方案
问题描述
进入漫画详情页时原为“全网络或全无”模式——网络请求失败则 data 为 null,直接显示 NetworkError,不展示任何信息。但本地已有的标题、封面、收藏状态、下载记录均未利用,导致离线时收藏/删除下载等操作按钮完全不可用。
解决方案
将
ComicPageLogic.get()拆为两阶段:具体改动
ComicPageLogic新增networkMessage、loadLocalData字段。get()拆为两阶段,refresh_()清空新增状态。BaseComicPage新增loadLocalData()(默认返回null,不影响已有子类)。_ComicPageImpl.loadLocalData()按优先级查询:下载记录 → 阅读历史。loadFavorite()改为 OR 逻辑,平台和本地任意一边收藏即为“已收藏”。build()注入loadLocalData回调 + 网络失败 toast。影响范围
仅影响走
_ComicPageImpl路径的自定义 JS 源。6 个内置源子类(PicacgComicPage等)loadLocalData默认null,行为不变。