feat: 新增资源收藏功能 - #1541
Open
leemwood wants to merge 7 commits into
Open
Conversation
Contributor
|
这类数据通常不太敏感,建议使用MMKV来存储,读写更高效,且能避免破坏原本的数据库结构 |
leemwood
force-pushed
the
feature/asset_favorites
branch
from
July 10, 2026 23:49
cba71e3 to
6172602
Compare
Contributor
Author
|
已通过真机测试,可以合并(或合并至分支进行修改)。 |
- Room 持久化 FavoriteAsset 实体(platform+projectId 唯一),AppDatabase v2→3 迁移 - FavoriteManager 管理器 + StateFlow,三处入口(搜索结果卡/下载详情版本行/收藏列表) - 收藏列表页支持按类别筛选(带侧边栏同款图标)与搜索 - 链接语义:存平台原始直链,下载时再走 MCIM 镜像
- FavoriteAsset 新增 type 字段(PROJECT/VERSION),唯一约束改为 (platform, projectId, type, downloadUrl),AppDatabase v3→4 迁移 - 搜索结果卡仅切换项目收藏(isProjectFavorite), 下载详情页版本行按 downloadUrl 切换版本收藏(isVersionFavorite), 两者互不覆盖 - 收藏列表按 (platform, projectId) 分组合并为一行, 展示项目收藏态与已收藏版本数/单版本名 - 仅收藏单版本(无项目收藏)时点击直接触发下载, 其他情况跳转资源详情页 - 复用现有 DownloadSingleOperation 对话框与下载流程, 新增 FavoriteAssetSnapshot 实现 PlatformVersion 快照 - FavoriteManager 新增 isProjectFavorite/isVersionFavorite/ findProject/findVersions/removeProject/removeVersion/ removeAllByProject/toggleProject/toggleVersion API
收藏功能未随版本发布,无需 v3→4 迁移,直接在 MIGRATION_2_3 建表语句中包含 type 列与新唯一索引 (platform, projectId, type, downloadUrl)
- FavoriteAsset移除Room注解与id字段,改为纯Parcelable - 新增_MMKV.kt,收藏以复合键(platform|projectId|type|downloadUrl)存储 - 删除FavoriteAssetDao - FavoriteManager改用MMKV读写,不再依赖AppDatabase - AppDatabase回退至v2(收藏未发布,无需v3表) - Converters移除FavoriteType等收藏相关转换器
…DownloadFavorites 路由)
leemwood
force-pushed
the
feature/asset_favorites
branch
from
July 13, 2026 16:46
6172602 to
d958add
Compare
Contributor
Author
|
怎么又冲突了( |
|
Hmmm... Why??? |
Contributor
Author
|
抱歉,刚才误操作删除了该 PR 的源分支,导致 PR 被 GitHub 自动关闭。目前分支已经恢复,PR 也已重新开启。 |
|
Ah |
- 数据层 6 文件收敛为 2 个:AssetFavorite + AssetFavoriteManager - 存储改 GSON JSON + schemaVersion,主键改 (platform, projectId, type, versionId) - 收藏态乐观更新 StateFlow,派生 favoriteKeys 集合供行级 O(1) 查询 - 收藏列表页重写:ViewModel、入场动画、滚动条、确认对话框、可展开版本子列表(下载/复制直链/单条移除) - 共享组件改 trailingContent slot 注入,移除 favoriteProvider/FavoriteAction - 详情页头部补项目收藏入口,版本行收藏态改按 versionId 判定 - 修复 savedAt 继承错误、AssetsVersionListItem 丢失的 padding、陈旧闭包 - 字符串收敛 download_favorites_* 前缀,删除 Weblate 托管语言(tr/vi/pt-rBR)改动
Contributor
Author
更新:按项目规范重写资源收藏功能本次推送( 数据层(6 文件 → 2 文件)
UI 层
资源与翻译
验证
改动面集中在 favorites 相关文件 + 5 处小 diff,共 28 个文件(+1485/-1004)。 |
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.
功能概述
新增「资源收藏」功能,用户可收藏资源(整合包/模组/资源包/地图/光影)的项目 + 特定版本下载链接到本地,不收藏本地模组文件本身。
实现要点
持久化(Room)
FavoriteAsset实体,复合唯一索引(platform, projectId),DB v2 → v3 +MIGRATION_2_3FavoriteAssetDao全suspend,FavoriteManagerobject管理器暴露StateFlow<List<FavoriteAsset>>(参照GamePathManager模式)Converters补Platform/PlatformClasses/PlatformReleaseType的@TypeConverter收藏入口(三处统一调
FavoriteManager)_Search.Result.kt):仅有项目元信息,首次收藏downloadUrl留空 +versionName=null,UI 灰色徽标「未指定版本」DownloadAssetsScreen/DownloadAssetsElements):收藏「项目 + 特定版本链接」,语义最完整,每个版本行独立显示收藏态FavoritesListScreen):卡片右侧图标显示已收藏态,点击取消链接语义
downloadUrl存平台原始直链(未经 MCIM 映射),下载时再mapMCIMMirrorUrlsdownloadUrl=""+versionName=null路由
NormalNavKey.DownloadAssets(platform, projectId, classes, iconUrl)NestedNavKey.DownloadFavorites,由ScreenBackStackViewModel持有downloadFavoritesScreenDownloadScreen.ktdownloadsList追加收藏分类(ic_favorite_outlined)收藏列表页
ic_*(整合包/模组/资源包/地图/光影)字符串
favorites_前缀,5 语言(en/zh-rCN/tr/vi/pt-rBR)CurrentGameInfo.favoritesMap)命名冲突关键修复
FavoriteMapper的projectId取自PlatformProject.platformId()(非PlatformVersion.platformId(),后者是 version id 会导致 404)downloadUrl比对判断收藏态,切换版本时保留原savedAt测试
./gradlew :ZalithLauncher:assembleDebug编译打包通过不包含
AGENTS.md开发规范文档兼容性
accounts/servers/gamePaths表CurrentGameInfo.favoritesMap(旧「版本收藏」语义保留)