281 Commits
Author SHA1 Message Date
Zhou Weidong 66c03ee245 chore(release): 发布 iOS 分享面板修复
flutter-ci / test (push) Canceled after 0s
# Conflicts:
#	lib/core/config/app_config.dart
2026-10-31 14:02:40 +08:00
Zhou Weidong a3ac007759 fix(config): release 构建自动使用生产环境 2026-10-31 14:00:33 +08:00
Zhou Weidong 8ec6df2be5 merge: 修复 iOS 系统分享面板
flutter-ci / test (push) Canceled after 0s
2026-10-31 13:40:14 +08:00
Zhou Weidong 5ec4db151a fix(ios): 修复分享面板并同步互动栏布局断言 2026-10-31 13:33:13 +08:00
Vicky 525f58c150 chore(release): 合并 develop 到 main
flutter-ci / test (push) Canceled after 0s
2026-10-31 09:49:54 +08:00
Vicky a47af8c3ad style(player): 视频信息区文案统一为 65% 半透明白
flutter-ci / test (push) Canceled after 0s
2026-10-31 09:41:19 +08:00
Vicky 0a02620564 chore(release): 合并 develop 到 main
flutter-ci / test (push) Canceled after 0s
2026-10-31 00:02:59 +08:00
Vicky 2ddf9ee1c6 test(config): 服务地址断言跟随环境开关
flutter-ci / test (push) Canceled after 0s
2026-10-31 00:02:53 +08:00
Vicky 3bc79ad8e2 fix(i18n): 去掉印尼语内容完整性过滤,缺失时回退中文 2026-10-31 00:02:53 +08:00
Vicky 78a33cd4f1 chore(release): 合并 develop 到 main
flutter-ci / test (push) Canceled after 0s
2026-10-30 22:56:52 +08:00
Vicky c307903c42 docs: 修正 README 中的分析基线文案
flutter-ci / test (push) Canceled after 0s
2026-10-30 22:53:18 +08:00
Vicky c5b94633f1 feat(following): 收藏页改为紧凑布局并去掉重复续播横幅 2026-10-30 22:53:18 +08:00
Vicky fd2ba0bf43 feat(player): 重做播放页信息层级与互动栏点击动效 2026-10-30 22:53:18 +08:00
Vicky aed9ee2b01 feat(image): 图片加载占位改为微光骨架 2026-10-30 22:53:18 +08:00
Vicky 335e5dc286 feat(home): 顶部导航随翻页联动并把推荐更名为精选 2026-10-30 22:53:15 +08:00
Vicky e8610b7aed chore(release): 生产包切换为生产环境地址
flutter-ci / test (push) Canceled after 0s
2026-10-30 17:20:48 +08:00
Vicky 2f4593a46e fix(a11y): 限制底栏文字缩放并统一播放页触控尺寸
flutter-ci / test (push) Canceled after 0s
2026-10-30 17:14:40 +08:00
Vicky 7509cf2ecd fix(following): 减淡继续观看封面遮罩亮度 2026-10-30 17:14:40 +08:00
Vicky 501bc66282 fix(wallet): 丢弃切换账号后返回的旧余额响应 2026-10-30 17:14:40 +08:00
Vicky 19196ceb8e fix(i18n): 印尼语内容缺失时不再回退中文 2026-10-30 17:14:37 +08:00
Vicky 9ef8eb15b0 feat(recommend): 轮播只保留标题简介并重做顶部导航 2026-10-30 17:14:34 +08:00
Vicky 53e8c924a6 feat(mine): 重做我的页会员卡与功能宫格布局 2026-10-30 17:14:32 +08:00
Vicky e7399fa3fd feat(auth): 登录页改为 ymb 品牌并支持后台配置背景图 2026-10-30 17:14:30 +08:00
Vicky 22cc669bbe feat(brand): 应用图标、开屏资源与品牌字体切换为 ymb 2026-10-30 17:14:27 +08:00
Vicky 26321e3348 feat(cover): 支持横版封面并收紧底栏图标间距
flutter-ci / test (push) Canceled after 0s
- Drama 新增 coverLandscape,WatchProgress 新增 dramaCoverLandscape
- 继续观看横幅优先使用横版封面,缺省回退竖版
- 底部导航栏图标与文字间距由 5dp 收紧至 1dp
2026-10-29 17:32:41 +08:00
Vicky 3590cd0c55 feat(recommend): 上新板块改按后端语义码判断,顶部轮播改为无缝循环
flutter-ci / test (push) Failing after 30m39s
Drama 新增 tagCode,推荐页只看 NEW_ARRIVAL 这个码决定上新横滑,
不再依赖可变的标签文案;分类网格高度改为复用卡片的统一常量。
头部轮播改用虚拟无限页码,首尾相接且能反向滑,自动播放不再倒滑回第一张。
2026-10-29 15:44:33 +08:00
Vicky c311985601 fix(ui): 列表剧名统一两行省略,收藏卡去掉观看进度副标题
筛选、追剧收藏、新片、榜单、缓存与推荐上新等列表卡都按两行剧名预留高度,
超长标题显示省略号;收藏卡不再显示「看到第 N 集」,文字区高度同步收窄。
2026-10-29 15:44:30 +08:00
Vicky 4dd37b2588 fix(i18n): 缩短我的页收藏、缓存与历史的英文和印尼语文案
My Favorites / Offline downloads / Watch History 在菜单里过长,
统一收成 Favorites / Downloads / History 与 Favorit / Unduhan / Riwayat。
2026-10-29 15:44:26 +08:00
Vicky 543d0aadd5 style(player): 播放页与首页浮层的控件样式统一
播放页顶部按钮与选集条去掉底色、进度条不再画滑块圆点并压到最底部;
剧名与简介收在互动栏左侧,清屏后只留右下角退出按钮。
首页观看条与进度条共用 20pt 页边距,进度槽底色与播放页一致。
2026-10-29 15:44:22 +08:00
Vicky d5bcda54d3 fix(player): 雪碧图缓存补齐槽位预取量,清屏按钮贴近进度条
三个渲染槽位各预取 2 张雪碧图,容量 3 装不下会导致「重建→重新下载解码→
notify→重建」的死循环,真机持续发烫掉帧;容量恢复为 8 并只在未命中时预取。
首页清屏态的退出按钮由距底 56 收到 24,贴着进度条上方。
2026-10-29 15:44:17 +08:00
Vicky 79463e65c2 feat(player): 剧名与选集合并为同一个弹窗
点剧名默认停在详情页签,选集入口直接停在选集页签,不再跳详情页;
详情页签补上简介、标签、收藏与相似推荐,原选集弹窗合并进来后删除。
2026-10-29 15:44:10 +08:00
Vicky ad7aba3daf chore(gitignore): 忽略 IDE 的 Widget Preview 生成目录
flutter-ci / test (push) Failing after 19m31s
.widget_preview/ 是 IDE 里 Flutter Widget Preview 生成的临时工程(含 .dart_tool、build),不入库。
2026-10-29 11:56:23 +08:00
Vicky 47fdd4a29d build(ios): 移除 CocoaPods 集成,插件统一走 Swift Package Manager
iOS 插件已全部支持 SPM,但工程仍保留 Podfile,每次构建都会提示移除 CocoaPods 集成;
按提示 pod deintegrate、删除 Podfile,并去掉两个 Flutter xcconfig 里对 Pods-Runner 配置的 include。
2026-10-29 11:55:35 +08:00
Vicky fe49527dd8 perf(discover): 剧场与新片页网格改为按行懒加载
flutter-ci / test (push) Failing after 19m39s
双列网格原来是两个 Column 一次性建出所有卡片,翻几页后上百张卡连同封面都留在树上;
现在改成按行的 SliverList,只构建可见行,剧场页/新片页/搜索结果的滚动容器一并换成 sliver。
搜索结果、加载失败等状态同步改成 sliver,滚动位置与下拉刷新行为保持不变。
2026-10-29 11:38:21 +08:00
Vicky 4aaa5bbd60 build(deps): 显式声明 intl 依赖,修掉 CI 零告警门禁的存量告警
flutter-ci / test (push) Failing after 19m29s
播放量格式化直接用了 NumberFormat,但 intl 只是 flutter_localizations 的传递依赖;
新增的 dart analyze --fatal-infos 流水线会因此失败,这里按 flutter_localizations 钉住的版本显式声明。
2026-10-29 11:27:53 +08:00
Vicky 5649e4c3d4 perf(home): 四个根 tab 改为首次可见才构建
原先 IndexedStack 冷启动就把推荐/发现/追剧/我的四棵子树全建出来,各自还会发请求;
现在只建当前 tab,切过去再建并常驻,冷启动少三页构建和一次观看历史请求。
2026-10-29 11:25:47 +08:00
Vicky 9f7301305e perf(following): 追剧页不可见时不再提前拉观看历史
首页用 IndexedStack 常驻四个 tab,追剧页一启动就会发一次观看历史请求,和首页 feed 抢网络;
改为切到该 tab 时再加载,收藏列表也只在首次可见且为空时补拉。
2026-10-29 11:25:47 +08:00
Vicky 63191b4692 perf(player): 续看点加载与进度写盘改为并行且复用同一请求
进播放页与首次准备播放会各要一次续看点,同一次请求跑两遍还串在首帧前;
现在并发请求复用同一 Future,并与上一条进度写盘并行等待,少一个网络往返的起播延迟。
剧场网格海报按布局宽度限制解码尺寸,半屏卡片不再按原图解码。
2026-10-29 11:25:47 +08:00
Vicky 0f777b19f2 perf(player): 限制雪碧图与海报预缓存内存并给播放位置缓存加容量上限
雪碧图解码从 2048 降到 1024、缓存从 8 张降到 3 张,避免擦洗预览驻留十几 MB 位图;
相邻集海报预缓存改用 ResizeImage 按 360/720 宽解码,不再缓存整张原图;
播放位置缓存按写入时间淘汰,最多保留 100 条,长会话不再只增不减;
观看记录详情失败日志加 kDebugMode 保护,release 下不再逐条打堆栈。
2026-10-29 11:25:47 +08:00
Zhou Weidong fb9001a02d ci: 新增 Gitea Actions 流水线(测试/分析/构建门禁)
flutter-ci / test (push) Failing after 23m25s
2026-10-29 10:47:36 +08:00
Zhou Weidong 1b80f841be chore(ios): 补齐 CocoaPods 集成配置文件
xcconfig 增加 Pods 引用(PiP 等插件依赖),Podfile 纳入版本管理,
保证任何机器拉取代码后可直接构建 iOS。
2026-10-29 10:46:42 +08:00
Zhou Weidong 3e89c71f50 docs(readme): 更新服务地址配置与双渠道打包说明
补上 dev/prod 配置文件的切换方式,并把生产打包拆成 Google Play 的 AAB
与国内市场的通用 APK,标注实测体积、符号表归档与签名待办。
2026-10-29 10:44:58 +08:00
Zhou Weidong 2ce92aa7dd build(android): 压缩生产包体积至 13MB 并统一双渠道产物
生产包九成体积是两套 ABI 的引擎与快照。release 固定 split-debug-info 与
dart-obfuscation,快照从 8MB 降到 1.1MB/ABI;原生库改为压缩存储;开启
R8 裁剪并补保号规则;只打包实际引用的登录背景,移除零引用的图标字体。
2026-10-29 10:44:54 +08:00
Zhou Weidong a6d6b66d31 refactor(config): 服务地址改为 dev/prod 配置文件与单个环境开关
启动时按环回、局域网、公网顺序探测地址,换网络后会静默切到别处,排查
困难。改为代码内一个布尔开关选择环境,地址分别放在 dev_config.dart 与
prod_config.dart,不再探测;调试条改地址后直接重载,不再重新探测。
release 构建若仍是开发开关会启动即报错,避免线上包连开发机。
2026-10-29 10:44:50 +08:00
Zhou Weidong 57f84c45bd fix(player): 解锁状态登录期内共享,重进播放页不再丢解锁
解锁记录原本是播放页实例的私有集合,退出再进入会先闪一次锁定态,还会
被 selectLocked 提前释放播放器。改为进程内共享的 UnlockedEpisodeRegistry,
由全局注入并在登录态变化时清空;播放器三处渲染分支统一走同一判定,
会话锁态只约束当前页,避免相邻预加载页被误判为锁定。
2026-10-29 10:44:44 +08:00
Zhou Weidong a4d08e7c1e refactor(paging): 抽取分页控制器基类收敛四个列表页
收藏、观看记录、剧单、公告各自手写 loading 互斥、请求序号、跨页去重与
错误映射,修一处要同步改四份。统一到 PagedListController 后子类只提供
取页与条目标识;空页按已加载数收口,避免 total 虚大时反复请求。
2026-10-29 10:44:41 +08:00
Zhou Weidong 9c9a277217 refactor(feed): 合并首页与剧场频道控制器的重复分桶逻辑
两个控制器的缓存优先、请求序号防串台、分页去重、预取与 seed 完全同构,
此前各写一份。抽出 ChannelFeedController 后,子类只保留分桶 key 与取页
实现;顺带修掉刷新被翻页抢占时 loading 永久为 true 的问题。
2026-10-29 10:44:36 +08:00
Zhou Weidong 1be8ebf1f9 refactor(api): 统一响应解析并修复下载错误文案空白
各 *Api 类此前各自实现 data 结构判断,download_api 在结构异常时抛出空
message,界面会显示空白提示。抽出 ResponseDecoders 提供对象、可空对象、
对象数组三种语义,七个文件改为复用;下载侧异常文案与其他接口对齐。
2026-10-29 10:44:32 +08:00
Zhou Weidong 70be941755 chore(build): 忽略 android 构建产物目录 2026-10-29 09:18:47 +08:00
Zhou Weidong 351d0afd09 chore(deps): 补齐 pubspec.lock 中画中画相关依赖 2026-10-29 09:18:43 +08:00
Zhou Weidong 7d32324a2d docs(readme): 补画中画、下载落盘与 iOS 打包说明,更新接口清单
接口从 26 条路径更新到 47 条(补账号设备/注销、搜索、剧单、标签、剧集统计
与解锁、钱包商品订单、评论数);画中画结论由"iOS 未接入"改为双端已接入;
下载由"不落盘、不支持离线播放"改为已落盘可离线、但不支持断点续传;
门禁更新为 dart analyze + flutter test(775 例)。
2026-10-28 19:05:12 +08:00
Zhou Weidong 1d4ab5e0e6 test: 按新 UI 基线重写过期用例
覆盖 155 条失败与 4 处编译错误:入口改走推荐流 tab、弹框换 AppGlowDialog、
rail 尺寸与底部锚定、子页标题字重 w400、底栏选中品牌红、收藏文案改收藏短剧。
全量 flutter test 775 通过。
2026-10-28 18:48:03 +08:00
Zhou Weidong 799f3d1b7d feat(player): 选集面板挑集后记住上次选集 2026-10-28 18:47:51 +08:00
Zhou Weidong 08aa6903d2 fix(player): 推荐流播放器补钱包依赖并统一点赞选中色 2026-10-28 18:47:51 +08:00
Zhou Weidong 4de9417e27 fix(auth): 放大登录注册分段的可点击区域 2026-10-28 18:47:51 +08:00
Zhou Weidong e269d5dce5 fix(ui): 修正卡片正文预留高度,消除底部溢出 2026-10-28 18:47:51 +08:00
Zhou Weidong 78f464f2a4 fix(ui): 弹框富内容加高度约束,长文案恢复滚动 2026-10-28 18:47:51 +08:00
Zhou Weidong 9983d42015 fix(core): 非移动端跳过设备区域读取,避免注册流程卡住 2026-10-28 18:47:51 +08:00
Vicky bfe0df62dc Merge branch 'develop' 2026-10-28 17:14:52 +08:00
Vicky df2654c9d6 fix(player): iOS自动小窗仅在播放页活跃时拉起 2026-10-28 17:14:50 +08:00
Vicky 496b1cb797 Merge branch 'develop' 2026-10-28 16:39:11 +08:00
Vicky 85dedf20fa fix(player): 修复清晰度切换闪屏与还原黑屏 2026-10-28 16:36:55 +08:00
Vicky 43e60e29ec feat(player): 接入双端画中画播放 2026-10-28 16:36:55 +08:00
Vicky 5346be40a9 fix(ui): 打磨推荐追剧我的设置页间距与图标 2026-10-28 16:36:51 +08:00
Vicky de7da64886 feat(ui): 登录页重设计并统一弹框主题渐变外壳 2026-10-28 16:36:43 +08:00
Vicky 709972245f fix(config): release 包固定公网接口地址,不再探测开发机
- release 默认地址固定为 publicBaseUrl(39.162.50.99:8081)
- release 启动跳过环回/局域网探测,避免合并 develop 后请求到开发机 192.168 地址
- debug 行为不变,仍按环回/开发机探测并支持 dart-define 覆盖
2026-10-27 20:10:06 +08:00
Vicky d5d13549f5 chore(merge): 合并推荐频道页与沉浸式首页到 main
- 新增推荐(tab1)接口分类频道页:分类轮播切换、选中频道自动定位、下拉刷新与上拉分页
- 精选频道 banner 轮播 + 接口 tag 上新横滑 + 双列短剧网格,卡片标题统一白色
- 恢复首页(tab0)沉浸式全屏信息流
2026-10-27 20:02:53 +08:00
Vicky c027acc91f feat(recommend): 新增推荐频道页并恢复首页沉浸式信息流
- tab1 推荐页改为接口分类频道:频道导航可横滑,选中频道自动滚动到可视区,内容区左右滑动切换分类
- 精选频道:顶部固定高度 banner 轮播图 + 接口 tag 筛选的上新短剧横滑 + 其余短剧双列网格;其他分类三列网格
- 分类内容支持懒加载、下拉刷新与上拉分页加载
- 卡片角标文案与背景色取自接口 tag/tagColor,短剧标题统一白色
- 恢复 tab0 为沉浸式全屏视频首页及其三 inner-tab 顶导(搜索/礼物入口)
- l10n 新增原创出品、立即观看、上新、编辑精选、全N集等多语言文案
2026-10-27 19:57:42 +08:00
Vicky a3f3481f4f feat: phase1 UI prep — 设备ID系统传递 + 国家本地化展示 + 继续观看直进播放页
设备标识: Android SSAID/ iOS IDFV 原生通道 → Dart DeviceIdProvider
国家解析: 注册/登录从后端 IP → 国家/语言/时区/币种 自动落库
账号资料: 全部本地化展示 (account_display.dart)
我的页: 继续观看卡片点击直接进播放页
2026-10-27 15:45:20 +08:00
Vicky 1b19513efb feat(core): 设备号改用系统标识,重装不再变成新游客
- Android 读 SSAID、iOS 读 IDFV,均免权限,由原生通道提供,不引插件
- 取不到时回退本地 UUIDv4,替代原来 32 位随机 + 时间戳的拼接
2026-10-27 14:15:50 +08:00
Vicky 935de13343 refactor(core): 平台上报收敛为单个请求头
去掉 device_info_plus 依赖与机型/系统版本,只保留 X-Client-Platform。
2026-10-27 14:00:19 +08:00
Vicky 01a3b0101e chore(merge): 合并客户端设备画像上报 2026-10-27 13:54:29 +08:00
Vicky d6df5fbe5f feat(core): 请求头统一上报设备系统与机型
- 新增 DeviceProfileReader,首次读取后缓存,插件不可用时安全降级
- 拦截器为所有请求补 X-Client-Platform / Os / Model,匿名请求同样携带
2026-10-27 13:54:28 +08:00
Vicky 929b7f72f8 chore(merge): 合并右侧操作栏顺序统一 2026-10-27 13:35:41 +08:00
Vicky e028ca40b1 fix(ui): 统一播放页右侧操作栏顺序为收藏-点赞-评论-分享
与推荐页操作栏保持一致,同步更新布局断言。
2026-10-27 13:35:41 +08:00
Zhou Weidong d206465ee1 fix(recommend): 首屏不再兜出重试空态 2026-10-27 11:24:21 +08:00
Zhou Weidong 9117bf58b8 fix(ui): 拆分媒体骨架底色,恢复可见度 2026-10-27 11:16:24 +08:00
Zhou Weidong bd826a9236 fix(ui): 骨架屏扫光收窄压淡 2026-10-27 11:12:31 +08:00
Zhou Weidong a5dbae7fff fix(ui): 骨架屏改为逐卡片扫光 2026-10-27 11:08:43 +08:00
Zhou Weidong 00405d2e3b fix(ui): 收敛骨架屏亮度 2026-10-27 10:49:30 +08:00
Zhou Weidong 72dcb92aca fix(following): 收紧取消追剧确认弹窗 2026-10-27 10:34:07 +08:00
Zhou Weidong 8d511933df fix(mine): 支持未登录展示互动计数 2026-10-27 10:26:11 +08:00
Zhou Weidong 06a2f6d7c0 fix(following): 支持未登录追剧与历史 2026-10-27 10:13:27 +08:00
Zhou Weidong 0d785bf1f8 feat(library): 支持设备追剧与观看历史 2026-10-27 09:54:51 +08:00
Zhou Weidong 4c3acb047c fix(player): 收紧推荐页互动栏间距 2026-10-27 09:37:00 +08:00
Zhou Weidong d3dbc9f8dc fix(favorite): 统一收藏状态与互动图标 2026-10-27 09:31:48 +08:00
Zhou Weidong 4b97f89c0b fix(recommend): 延后推荐数据刷新 2026-10-27 09:19:18 +08:00
Zhou Weidong 6be024f86f test(flutter): 收敛异步配置与分页测试 2026-10-26 22:49:27 +08:00
Zhou Weidong 6512808506 test(ui): 更新主题导航与布局断言 2026-10-26 22:49:23 +08:00
Zhou Weidong 2d65cd3006 test(auth): 更新登录失败提示断言 2026-10-26 22:49:21 +08:00
Zhou Weidong 391b01e9d0 fix(theater): 修复新剧卡片与榜单溢出 2026-10-26 22:49:13 +08:00
Zhou Weidong d4ce3a5d8b fix(home): 修复目录错误态被占位层遮挡 2026-10-26 22:49:10 +08:00
Zhou Weidong bf47c065c9 fix(ui): 修复继续观看卡片纵向溢出 2026-10-26 22:49:07 +08:00
Zhou Weidong c6b3ca9311 fix(auth): 禁止刷新接口递归重试 2026-10-26 22:49:04 +08:00
Zhou Weidong a3d50eb935 feat(interaction): 支持游客点赞收藏评论 2026-10-26 22:33:14 +08:00
Zhou Weidong 188811fde6 feat(player): 切集刷新互动计数统计 2026-10-26 21:40:39 +08:00
Zhou Weidong 37353dac15 fix(player): 观看全集进入后自动播放 2026-10-26 21:25:38 +08:00
Zhou Weidong 350d16db75 fix(player): 修正缓冲态与首帧时间闪现 2026-10-26 21:13:55 +08:00
Zhou Weidong 76429628ec chore(merge): 合并播放器切集与双击点赞优化到 main 2026-10-26 19:31:47 +08:00
Zhou Weidong 0f27daf664 chore(merge): 合并播放器切集与双击点赞优化 2026-10-26 19:24:49 +08:00
Zhou Weidong afdc4af2f2 chore(player): 移除飘心毫秒调试文字 2026-10-26 19:21:24 +08:00
Zhou Weidong 1b50a73bfc fix(player): 修复首次双击点赞状态刷新 2026-10-26 19:17:14 +08:00
Zhou Weidong 978c309cd7 fix(player): 改用墙钟驱动飘心动画 2026-10-26 19:07:56 +08:00
Zhou Weidong c0f65042e6 fix(player): 修正飘心Overlay生命周期 2026-10-26 19:00:37 +08:00
Zhou Weidong a7d01e0306 test(player): 增加飘心像素定位回归 2026-10-26 18:57:04 +08:00
Zhou Weidong ed2cf4c18c fix(player): 使用根Overlay承载飘心 2026-10-26 18:54:05 +08:00
Zhou Weidong db3e153409 fix(player): 使用根Overlay承载飘心 2026-10-26 18:49:36 +08:00
Zhou Weidong 810ca5bf9d fix(player): 延长飘心并显示毫秒计时 2026-10-26 18:48:12 +08:00
Zhou Weidong 84b24775d6 fix(player): 恢复develop飘心实现 2026-10-26 18:38:59 +08:00
Zhou Weidong 9039b27c7f fix(player): 使用根Overlay渲染飘心 2026-10-26 18:35:30 +08:00
Zhou Weidong 30b43878ab fix(player): 使用根Overlay渲染飘心 2026-10-26 18:29:48 +08:00
Zhou Weidong e7afd316f8 fix(player): 放慢随机飘心并验证完整时长 2026-10-26 18:24:19 +08:00
Zhou Weidong f3dd4a9b5c fix(player): 恢复随机飘心粒子模型 2026-10-26 18:19:39 +08:00
Zhou Weidong 94b37ef00f fix(player): 优化双击飘心轨迹 2026-10-26 18:16:06 +08:00
Zhou Weidong bea50ab32f fix(player): 调整双击飘心动画 2026-10-26 18:11:01 +08:00
Zhou Weidong 63296d2a92 fix(player): 恢复独立播放页双击点赞 2026-10-26 18:06:55 +08:00
Zhou Weidong b291044acc fix(player): 收敛播放页入口加载态 2026-10-26 17:56:40 +08:00
Zhou Weidong ee4e573f4f fix(player): 播放页改为非阻塞加载 2026-10-26 17:43:57 +08:00
Zhou Weidong e8f192ccf8 fix(player): 顶层抓帧淡出揭幕 2026-10-26 17:31:59 +08:00
Zhou Weidong c8ec481fc9 fix(player): 预解码观看全集首帧 2026-10-26 17:27:43 +08:00
Zhou Weidong 1fc8c4924e fix(player): 调整观看全集淡入时长 2026-10-26 17:21:52 +08:00
Zhou Weidong 55fc2796a9 fix(player): 观看全集复用抓帧首屏 2026-10-26 17:20:24 +08:00
Zhou Weidong 4d3d067f77 fix(player): 规范预热回收日志并抓帧过渡 2026-10-26 17:13:56 +08:00
Zhou Weidong bb2c729a7e fix(player): 隔离播放资源所有权并修复黑屏 2026-10-26 17:03:19 +08:00
Zhou Weidong 54eb5a60a8 fix(player): 修复返回首页黑屏并恢复预热 2026-10-26 16:45:00 +08:00
Zhou Weidong 6667330ce0 fix(player): 分离首页与播放页播放上下文 2026-10-26 16:37:37 +08:00
Zhou Weidong 440188f261 fix(player): 修复切集返回推荐页黑屏 2026-10-26 16:20:31 +08:00
Zhou Weidong 9d2d3b97a1 fix(player): 独立全屏路由复用播放会话 2026-10-26 16:08:15 +08:00
Zhou Weidong 23e80dd637 fix(player): 复用播放会话进入全屏 2026-10-26 15:55:46 +08:00
Zhou Weidong ab4c246675 fix(player): 保持推荐页返回时播放状态 2026-10-26 15:44:28 +08:00
Zhou Weidong 2a32dec183 fix(player): 持久化竖滑播放画面层 2026-10-26 15:34:24 +08:00
Zhou Weidong 5dafc68775 test(player): 覆盖 feed 高清首帧解析 2026-10-26 15:20:45 +08:00
Zhou Weidong 80c962a95c fix(player): 收紧图片与快速切集资源占用 2026-10-26 15:10:02 +08:00
Zhou Weidong 2fef7470e0 fix(player): 使用高清首帧并稳定切集占位 2026-10-26 14:58:00 +08:00
Zhou Weidong 0cb0ab0613 fix(player): 重构单层过渡并阻止锁定集串播 2026-10-26 14:41:18 +08:00
Zhou Weidong 70d8e0f982 fix(player): 使用雪碧图预热首帧兜底 2026-10-26 14:21:52 +08:00
Zhou Weidong 48b4e67d34 fix(player): 预热直出并与视频统一封面布局 2026-10-26 14:12:42 +08:00
Zhou Weidong a3a79f7068 fix(player): 修正封面比例与首帧切换闪烁 2026-10-26 14:07:36 +08:00
Zhou Weidong 04f034817c fix(player): 优化封面过渡与换集起播 2026-10-26 14:01:42 +08:00
Zhou Weidong 516593499c fix(player): 修复竖滑上一集不自动播放 2026-10-26 13:43:43 +08:00
Zhou Weidong df36890b48 chore(analyze): 清理静态检查告警 2026-10-26 13:43:38 +08:00
Zhou Weidong 222bacdeeb fix(player): 优化上下滑切集黑屏 2026-10-26 13:15:56 +08:00
Zhou Weidong 43f3593218 chore(merge): 合并 iOS 无线数据选择框触发到 main 2026-10-26 09:35:29 +08:00
Zhou Weidong b83b5799e3 chore(merge): 合并 iOS 无线数据选择框触发 2026-10-26 09:35:29 +08:00
Zhou Weidong d4ae8f427f fix(ios): 用系统网络请求唤起无线数据选择
Flutter 的接口请求不会触发系统选择框,进入前台后补一次 URLSession 请求。
2026-10-26 09:35:29 +08:00
Zhou Weidong 0eca7ecc31 chore(merge): 合并 iOS 无线数据询问到 main 2026-10-25 21:23:26 +08:00
Zhou Weidong 98d7debfb5 chore(merge): 合并 iOS 无线数据询问 2026-10-25 21:23:26 +08:00
Zhou Weidong b5e9deb4bd feat(ios): 首次启动询问无线数据权限
iOS 在首个接口请求前等待系统无线数据选择,避免未授权时请求被静默拒绝。
2026-10-25 21:23:25 +08:00
Zhou Weidong af5d8f9d80 chore(merge): 合并客户端多语言筛选到 main 2026-10-25 19:52:30 +08:00
Zhou Weidong 47df002d8e chore(merge): 合并客户端多语言筛选与注销原因修正 2026-10-24 17:22:57 +08:00
Zhou Weidong 4f1feeadbd fix(app): 注销原因对齐到输入框顶部 2026-10-24 17:20:24 +08:00
Zhou Weidong 8b50b5bd06 feat(app): 客户端展示多语言并支持筛选分页 2026-10-24 17:20:24 +08:00
Zhou Weidong b84a5368d6 chore(merge): 将 release/v1.0.0 同步到 main 2026-10-23 13:07:33 +08:00
Zhou Weidong 67e178c89d chore(merge): 将 develop 同步到 release/v1.0.0 2026-10-23 13:07:33 +08:00
Zhou Weidong 8481611372 chore(merge): 合并错误码三语文案 2026-10-23 13:05:29 +08:00
Zhou Weidong b1e95b370c feat(app): 按错误码展示中英印尼文案 2026-10-23 13:05:29 +08:00
Zhou Weidong 0ef0d46919 chore(merge): 合并未使用注销原因清理 2026-10-23 12:45:30 +08:00
Zhou Weidong b4d38f8e10 refactor(app): 删除未使用的注销原因组件 2026-10-23 12:45:30 +08:00
Zhou Weidong c034627fdb chore(merge): 合并播放协议搜索与空状态 2026-10-23 12:38:47 +08:00
Zhou Weidong ef29fc5f15 feat(app): 完善播放协议搜索与空状态 2026-10-23 12:38:47 +08:00
Zhou Weidong 671e0ce143 merge: 将远程 main 同步到 develop 2026-10-23 08:09:24 +08:00
Zhou Weidong 0f1f64a09f merge: 将 release/v1.0.0 同步到 main 2026-10-23 03:22:26 +08:00
Zhou Weidong d29ae20491 merge: 将客户端调整同步到 release/v1.0.0 2026-10-23 03:21:53 +08:00
Zhou Weidong 12e08a89a4 fix(player): 提高解锁金币标签对比度 2026-10-23 03:18:24 +08:00
Zhou Weidong e0ba54f23b fix(cover): 封面占位改为品牌标识 2026-10-23 03:18:24 +08:00
Zhou Weidong 5043d6c25b fix(l10n): 缩短印尼语全部短剧文案 2026-10-23 03:18:24 +08:00
Zhou Weidong ab6800aba2 fix(search): 避免键盘顶起搜索页 2026-10-23 03:18:24 +08:00
Zhou Weidong f8500bbaca fix(player): 完善进度预览清屏与下拉刷新 2026-10-23 03:18:24 +08:00
Zhou Weidong 9b1afbdb36 feat(recommend): 剧单更多进入两列详情页 2026-10-23 03:18:24 +08:00
Zhou Weidong f4cf7bc2dd fix(home): 调整榜单版式并去掉二级分类 2026-10-23 03:18:24 +08:00
Zhou Weidong 60489d6dca fix(ios): 修复逐帧请求头编译失败 2026-10-23 03:18:23 +08:00
Zhou Weidong 44d3bcba18 style(empty): 放大空状态图标并降低亮度 2026-10-23 01:10:59 +08:00
Zhou Weidong f206977ad8 fix(config): 开发服务地址改为当前局域网 2026-10-23 01:10:59 +08:00
Zhou Weidong f3d64f6fb5 fix(auth): 登录页靠上排列并支持外部失焦 2026-10-23 01:10:59 +08:00
Zhou Weidong 6318ca24ec feat(splash): 缩短开屏停留并统一开屏图 2026-10-23 01:06:07 +08:00
Zhou Weidong b513ac0a9c merge: 调整品牌开屏与纯黑原生启动 2026-10-22 23:15:36 +08:00
Zhou Weidong 25d90e1383 feat: 调整品牌开屏与纯黑原生启动 2026-10-22 23:15:27 +08:00
Zhou Weidong 7804809d83 merge: 开屏后直接展示首页骨架 2026-10-22 23:11:13 +08:00
Zhou Weidong 5f278a3510 feat: 开屏后直接展示首页骨架 2026-10-22 23:11:03 +08:00
Zhou Weidong 56d7abc6b1 merge: 保留系统开屏并更新品牌素材 2026-10-22 23:04:31 +08:00
Zhou Weidong 345cc2ad28 feat: 保留系统开屏并更新品牌素材 2026-10-22 23:04:23 +08:00
Zhou Weidong 41bd4683c3 merge: 更新 App 图标与开屏素材 2026-10-22 22:59:14 +08:00
Zhou Weidong d868ce9336 feat: 更新 App 图标与开屏素材 2026-10-22 22:59:07 +08:00
Zhou Weidong 928ac1de19 merge: 增加搜索结果下拉刷新 2026-10-22 22:53:01 +08:00
Zhou Weidong 6b3d870c93 feat: 增加搜索结果下拉刷新 2026-10-22 22:52:50 +08:00
Zhou Weidong 281f13a810 merge: 调整搜索结果两列布局 2026-10-22 22:50:55 +08:00
Zhou Weidong 8637f5da21 style: 调整搜索结果两列布局 2026-10-22 22:50:47 +08:00
Zhou Weidong 0319f8a6a8 merge: 统一首页与推荐搜索入口 2026-10-22 22:48:29 +08:00
Zhou Weidong 9aa797504b feat: 统一首页与推荐搜索入口 2026-10-22 22:48:21 +08:00
Zhou Weidong 933333b0fe merge: 使用点击序号防止双击误暂停 2026-10-22 22:39:30 +08:00
Zhou Weidong bbc759473c fix: 使用点击序号防止双击误暂停 2026-10-22 22:39:21 +08:00
Zhou Weidong 9ddd7fc833 merge: 修复播放器重复暂停手势 2026-10-22 22:34:26 +08:00
Zhou Weidong 5794dd4e4d fix: 修复播放器重复暂停手势 2026-10-22 22:34:18 +08:00
Zhou Weidong 76c4b528d3 merge: 修正双击点赞与心形联动 2026-10-22 22:30:11 +08:00
Zhou Weidong 68ccfa21c0 fix: 修正双击点赞与心形联动 2026-10-22 22:30:01 +08:00
Zhou Weidong 78d0166eb7 merge: 增加播放器双击点赞与飘心 2026-10-22 22:25:22 +08:00
Zhou Weidong 4140c4eb50 feat: 增加播放器双击点赞与飘心 2026-10-22 22:25:14 +08:00
Zhou Weidong e2cc409e5a merge: 重做首页热播榜布局 2026-10-22 22:20:01 +08:00
Zhou Weidong 9b83283689 feat: 重做首页热播榜布局 2026-10-22 22:19:55 +08:00
Zhou Weidong db8433ace3 merge: 统一下拉与加载指示器 2026-10-22 22:07:21 +08:00
Zhou Weidong 6f1da5aa39 style: 统一下拉与加载指示器 2026-10-22 22:07:13 +08:00
Zhou Weidong 397483d339 merge: 统一全站深色视觉 2026-10-22 22:01:45 +08:00
Zhou Weidong 37e35f4b47 style: 统一全站深色视觉 2026-10-22 22:01:36 +08:00
Zhou Weidong 86aa7e0f4f merge: 增加推荐剧单渐变背景 2026-10-22 21:52:20 +08:00
Zhou Weidong 604ab60b63 style: 增加推荐剧单渐变背景 2026-10-22 21:52:13 +08:00
Zhou Weidong 0b3f362093 merge: 修正我的 UID 行高度 2026-10-22 21:49:54 +08:00
Zhou Weidong 19acbb2278 fix: 修正我的 UID 行高度 2026-10-22 21:49:47 +08:00
Zhou Weidong ce3ecc4d21 merge: 收紧我的用户区信息间距 2026-10-22 21:46:57 +08:00
Zhou Weidong c604cc1333 style: 收紧我的用户区信息间距 2026-10-22 21:46:49 +08:00
Zhou Weidong e7367e99be merge: 补充我的页内容区块 2026-10-22 21:44:36 +08:00
Zhou Weidong 9953c955e3 feat: 补充我的页内容区块 2026-10-22 21:44:03 +08:00
Zhou Weidong 7971ac18fc merge: 增强我的页渐变与图标配色 2026-10-22 21:38:55 +08:00
Zhou Weidong a81bec4d47 style: 增强我的页渐变与图标配色 2026-10-22 21:38:49 +08:00
Zhou Weidong 647f6afd77 merge: 改造我的页渐变与图标网格 2026-10-22 21:35:20 +08:00
Zhou Weidong 9785a1baf3 feat: 改造我的页渐变与图标网格 2026-10-22 21:35:14 +08:00
Zhou Weidong e70ca03c03 merge: 调整继续观看按钮样式 2026-10-22 21:28:41 +08:00
Zhou Weidong 95fb2ff882 style: 调整继续观看按钮样式 2026-10-22 21:28:36 +08:00
Zhou Weidong b6e5f808d6 merge: 优化追剧页切换与编辑按钮 2026-10-22 21:26:01 +08:00
Zhou Weidong 3f3dc9263c fix: 优化追剧页切换与编辑按钮 2026-10-22 21:25:55 +08:00
Zhou Weidong f67b8bd514 merge: 调整追剧加号颜色 2026-10-22 21:21:58 +08:00
Zhou Weidong 4d304cb549 style: 调整追剧加号颜色 2026-10-22 21:21:52 +08:00
Zhou Weidong 201d58e8f4 merge: 调整追剧加号卡片顺序 2026-10-22 21:20:12 +08:00
Zhou Weidong 091ea358bd fix: 调整追剧加号卡片顺序 2026-10-22 21:20:06 +08:00
Zhou Weidong af828d2c46 merge: 播放历史单列列表 2026-10-22 21:18:08 +08:00
Zhou Weidong c14d89ffce feat: 调整播放历史为单列列表 2026-10-22 21:18:02 +08:00
Zhou Weidong b185200e8c merge: 追剧页双列表与三列卡片 2026-10-22 21:14:31 +08:00
Zhou Weidong 2fac46f248 feat: 改造追剧页双列表与三列卡片 2026-10-22 21:14:23 +08:00
Zhou Weidong cffb68809c merge: 更正筛选按钮所属页面 2026-10-22 21:06:00 +08:00
Zhou Weidong 13d70fcef2 fix(recommend): 更正筛选按钮所属页面 2026-10-22 21:05:51 +08:00
Zhou Weidong bf20e44b85 merge: 移除二级标签筛选按钮 2026-10-22 21:02:40 +08:00
Zhou Weidong 9cf1efc316 fix(home): 移除二级标签筛选按钮 2026-10-22 21:02:29 +08:00
Zhou Weidong 3655d94869 merge: 修正窄筛选行横向居中 2026-10-22 20:59:14 +08:00
Zhou Weidong 196ce69a12 fix(recommend): 修正窄筛选行横向居中 2026-10-22 20:59:02 +08:00
Zhou Weidong c7a0e277f2 merge: 统一全部短剧筛选左对齐 2026-10-22 20:56:53 +08:00
Zhou Weidong 57c9e6b477 fix(recommend): 统一全部短剧筛选左对齐 2026-10-22 20:56:45 +08:00
Zhou Weidong 64bc1997ba merge: 修正筛选左起始与横向滑动 2026-10-22 20:53:16 +08:00
Zhou Weidong 21bb716af4 fix(recommend): 修正筛选左起始与横向滑动 2026-10-22 20:53:07 +08:00
Zhou Weidong a40adbb99a merge: 按截图重做全部短剧筛选区 2026-10-22 20:50:03 +08:00
Zhou Weidong d79e200650 style(recommend): 按截图重做全部短剧筛选区 2026-10-22 20:49:54 +08:00
Zhou Weidong 3b9ff8a306 merge: 对齐全部短剧筛选行 2026-10-22 20:46:21 +08:00
Zhou Weidong af4d918938 fix(recommend): 对齐全部短剧筛选行 2026-10-22 20:46:13 +08:00
Zhou Weidong 3289012f64 merge: 固定全部短剧筛选区并统一间距 2026-10-22 20:43:22 +08:00
Zhou Weidong e147002e00 fix(recommend): 固定全部短剧筛选区并统一间距 2026-10-22 20:43:15 +08:00
Zhou Weidong 099d05064e merge: 重排全部短剧筛选与网格 2026-10-22 20:39:09 +08:00
Zhou Weidong 4eb411ef28 style(recommend): 重排全部短剧筛选与网格 2026-10-22 20:39:00 +08:00
Zhou Weidong 14885d9efa merge: 支持横向切换三个内容页 2026-10-22 20:35:06 +08:00
Zhou Weidong 17faa749b2 feat(recommend): 支持横向切换三个内容页 2026-10-22 20:34:58 +08:00
Zhou Weidong 5fce65ac57 merge: 修正标题与观看全集跳转 2026-10-22 20:31:48 +08:00
Zhou Weidong 357492acb2 fix(recommend): 修正标题与观看全集跳转 2026-10-22 20:31:41 +08:00
Zhou Weidong 23799353b5 merge: 修复进度条拖动树稳定性 2026-10-22 20:27:07 +08:00
Zhou Weidong cf6d12b7c8 fix(player): 修复进度条拖动树稳定性 2026-10-22 20:26:58 +08:00
Zhou Weidong 5af6caea6e merge: 修正进度条按下与拖动状态 2026-10-22 20:23:32 +08:00
Zhou Weidong d66ff13d0f fix(player): 修正进度条按下与拖动状态 2026-10-22 20:23:24 +08:00
Zhou Weidong 7599da1d40 merge: 收窄拖动清屏范围并提升灵敏度 2026-10-22 20:19:29 +08:00
Zhou Weidong 04f1f5a73f fix(recommend): 收窄拖动清屏范围并提升灵敏度 2026-10-22 20:19:21 +08:00
Zhou Weidong f5721592f7 merge: 收窄观看全集按钮 2026-10-22 20:16:22 +08:00
Zhou Weidong 5abee5f69a style(recommend): 收窄观看全集按钮 2026-10-22 20:16:13 +08:00
Zhou Weidong 3690fb1bc4 merge: 修正进度拖动与底栏联动 2026-10-22 20:15:14 +08:00
Zhou Weidong 2765343340 fix(recommend): 修正进度拖动与底栏联动 2026-10-22 20:15:07 +08:00
Vicky a1c0af3f00 merge: 将 release/v1.0.0 同步到 main 2026-10-21 20:07:35 +08:00
Vicky b5bfc1d7b2 merge: 将 develop 同步到 release/v1.0.0 2026-10-21 20:07:30 +08:00
Vicky 1d2ba93e48 merge: 同步 release 剔除 x86_64 到 main 2026-10-21 19:13:33 +08:00
Vicky c08df9af40 merge: 同步 release 剔除 x86_64 到 release/v1.0.0 2026-10-21 19:13:28 +08:00
Vicky be166f5856 merge: 同步生产包 ABI 约束到 main 2026-10-21 19:10:11 +08:00
Vicky e531c78997 merge: 同步生产包 ABI 约束到 release/v1.0.0 2026-10-21 19:10:10 +08:00
Vicky 8ed6cd9fd6 merge: 同步生产打包单包说明到 main 2026-10-21 19:07:03 +08:00
Vicky c1d55b91a2 merge: 同步生产打包单包说明到 release/v1.0.0 2026-10-21 19:06:57 +08:00
Vicky 3dcfa02372 merge: 同步 README 生产打包说明到 main 2026-10-21 19:03:06 +08:00
Vicky b6826f7483 merge: 同步 README 生产打包说明到 release/v1.0.0 2026-10-21 19:03:01 +08:00
Vicky cd3d84cf9a merge: 将 release/v1.0.0 同步到 main 2026-10-21 18:58:26 +08:00
Vicky 010ce326ea merge: 将 develop 同步到 release/v1.0.0 2026-10-21 18:58:12 +08:00
Zhou Weidong 2577797772 merge: 将 C3 埋点同步到 main 2026-10-21 09:09:34 +08:00
Zhou Weidong 05e2952815 merge: 将 C3 埋点同步到 release/v1.0.0 2026-10-21 09:07:42 +08:00
Zhou Weidong 6ae9e8e043 merge: 将 release/v1.0.0 同步到 main 2026-10-20 22:26:48 +08:00
Zhou Weidong 182b7e3ac2 merge: 将 develop 同步到 release/v1.0.0 2026-10-20 22:23:32 +08:00
Zhou Weidong 8bb365db2a merge: 将 release/v1.0.0 合入 main 2026-10-20 20:38:58 +08:00
Zhou Weidong 0cb57d084d merge: 将 develop 合入 release/v1.0.0
# Conflicts:
#	lib/core/config/app_config.dart
#	lib/main.dart
#	test/config/server_endpoint_test.dart
2026-10-20 20:36:43 +08:00
jianghaifeng 5c174b007c Merge pull request 'Release/v1.0.0' (#1) from release/v1.0.0 into main
Reviewed-on: #1
2026-10-19 13:42:16 +00:00
Zhou Weidong 35364c949a chore(release): 合并 develop 到 release/v1.0.0 2026-10-19 21:39:21 +08:00
Zhou Weidong 814b2c0b7b chore(config): 默认服务地址改为公网 39.162.50.99:8081 2026-10-19 21:12:16 +08:00
Zhou Weidong 3d0e0804ca fix(app): 修复视频播放明文HTTP与双网络访问切换 2026-10-19 18:37:38 +08:00
420 changed files with 33682 additions and 8133 deletions

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
# Author: fruit.com.cn
# ReelShort 客户端 CI:静态分析 + 测试门禁
name: flutter-ci
on:
push:
branches: [develop, main]
pull_request:
branches: [develop, main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: 依赖
run: flutter pub get
- name: 静态分析(零告警门禁)
run: dart analyze --fatal-infos
- name: 单元测试(全绿门禁)
run: flutter test -r expanded
+3
View File
@@ -65,3 +65,6 @@ app.*.map.json
.env
.env.*
!.env.example
# IDE 的 Flutter Widget Preview 生成目录。
.widget_preview/
+93 -57
View File
@@ -1,18 +1,22 @@
# FruitShorts(ReelShort)客户端
FruitShorts 是面向印尼市场的短剧 Flutter 客户端。当前版本已连接
`FruitServer` 的 `/app/**` 接口,支持沉浸播放、找剧、账号、观看记录、收藏、
下载授权、评论互动、站内通知和中英印尼三语界面。
FruitShorts 是面向印尼市场的短剧 Flutter 客户端,已连接 `FruitServer` 的
`/app/**` 接口。功能覆盖:四 tab 主页(推荐视频流 / 找剧 / 追剧 / 我的)、
沉浸式播放与全屏剧集播放器、清晰度切换、剧单与排行榜、新剧页、搜索、观看记录、
收藏短剧、评论与点赞、站内通知、钱包与商品、下载落盘与离线播放、中英印尼三语,
以及 Android / iOS 双端画中画(退到后台自动进小窗)。
## 技术栈
- Flutter 3.47.7 / Dart 3.13.5
- Flutter 3.47.7 / Dart 3.13.5(`environment.sdk: ^3.12.2`)
- Provider 状态管理与依赖注入
- dio 网络请求
- video_player 播放
- shared_preferences 与 `SharedPreferencesAsync` 本地配置
- path_provider + dart:io 下载落盘(先写 `.part`,完成后原子改名)
- flutter_localizations,支持 `en`、`zh`、`id`
- Android 系统画中画
- 画中画:Android 用 `floating` + `permission_handler`(需悬浮窗权限);
iOS 用原生 `AVPictureInPictureController` + 影子播放器(`ios/Runner/AppDelegate.swift`)
## 目录结构
@@ -22,7 +26,7 @@ lib/
config/ 地址、语言和运行时配置
data/ models、remote API、repository、controller
formatting/ 文案与日期格式化
platform/ 触觉等平台能力
platform/ 平台能力:画中画通道、设备号、触觉
theme/ 颜色与主题
widgets/ 跨页面复用组件
l10n/ 三语 ARB 与生成代码
@@ -36,20 +40,21 @@ assets/ 图标、图片和本地媒体文件
## 已接接口
以下接口均在 `lib/core/data/remote/` 中有实际调用,共 26 个不同路径、
31 个 HTTP 方法级调用。
以下接口均在 `lib/core/data/remote/` 中有实际调用,共 47 个不同路径。
| 分组 | 契约 | 接口 |
| --- | --- | --- |
| 账号 | §1.1 | `POST /app/auth/register`、`/login`、`/refresh`、`/logout` |
| 内容 | §1.3、§1.4 | `GET /app/home/feed`、`/app/discover/feed`、`/app/categories`、`/app/dramas/{id}`、`/app/episodes/{id}/play` |
| 观看记录 | §1.5 | `POST/GET /app/watch/progress`、`GET /app/watch/recent`、`DELETE /app/watch/progress/{dramaId}`、`DELETE /app/watch/progress` |
| 收藏 | §1.5 | `POST /app/favorites/toggle`、`GET /app/favorites`、`DELETE /app/favorites/{dramaId}` |
| 下载授权 | §1.6 | `GET /app/downloads/policy`、`PUT /app/downloads/settings`、`POST/GET /app/downloads`、`GET /app/downloads/{episodeId}/url`、`POST /app/downloads/{episodeId}/progress`、`DELETE /app/downloads/{episodeId}`、`DELETE /app/downloads` |
| 互动 | §1.7 | `GET/POST /app/comments`、`DELETE /app/comments/{id}`、`POST /app/likes/toggle`、`POST /app/reports` |
| 公告 | §1.9.2 | `GET /app/notices` |
| 分组 | 接口 |
| --- | --- |
| 账号 | `POST /app/auth/register`、`/login`、`/refresh`、`/logout`、`/otp`;`GET /app/me`、`/app/me/devices`、`/app/me/export`;`POST /app/me/deactivate`、`/app/me/deactivate/cancel` |
| 内容 | `GET /app/home/feed`、`/app/feed`、`/app/discover/feed`、`/app/categories`、`/app/categories/{id}/dramas`、`/app/drama-categories`、`/app/dramas/page`、`/app/dramas/{id}`、`/app/tags`、`/app/search`、`/app/playlists`、`/app/playlists/{id}` |
| 播放 | `GET /app/episodes/{id}/play`、`/app/episodes/{id}/stats`;`POST /app/episodes/{id}/unlock` |
| 观看记录 | `POST/GET /app/watch/progress`、`GET /app/watch/recent`、`DELETE /app/watch/progress/{dramaId}`、`DELETE /app/watch/progress` |
| 收藏 | `POST /app/favorites/toggle`、`GET /app/favorites`、`DELETE /app/favorites/{dramaId}`、`POST /app/favorites/remove` |
| 下载 | `GET /app/downloads/policy`、`PUT /app/downloads/settings`、`POST/GET /app/downloads`、`GET /app/downloads/{id}/url`、`POST /app/downloads/{id}/progress`、`DELETE /app/downloads/{id}`、`DELETE /app/downloads` |
| 互动 | `GET/POST /app/comments`、`DELETE /app/comments/{id}`、`GET /app/comments/count`、`POST /app/likes/toggle`、`POST /app/reports` |
| 商业化 | `GET /app/wallet`、`/app/products`、`/app/orders` |
| 公告 | `GET /app/notices` |
客户端没有调用 `/app/config` 或创作者入驻接口。
客户端没有调用 `/app/config` 和创作者入驻接口。
## 运行
@@ -66,39 +71,60 @@ flutter pub get
```bash
adb devices
adb reverse tcp:8081 tcp:8081
flutter run -d <device> \
--dart-define=API_BASE_URL=http://127.0.0.1:8081
flutter run -d <device>
```
`adb reverse` 将手机的 `127.0.0.1:8081` 转发到电脑;USB 断开或重新连接后需要
重新执行。
重新执行。此时用调试条把地址改成 `http://127.0.0.1:8081`(见下节)。
Android 模拟器访问宿主机时使用:
```bash
flutter run --dart-define=API_BASE_URL=http://10.0.2.2:8081
```
Android 模拟器访问宿主机时,同样在调试条里填 `http://10.0.2.2:8081`。
### iOS
手机与 Mac 需在同一网络,首次启动允许“本地网络”权限:
iOS 模拟器直接访问 Mac 本机服务,默认地址为 `http://127.0.0.1:8081`:
```bash
flutter run -d <udid> \
--dart-define=API_BASE_URL=http://<Mac局域网IP>:8081
flutter run -d <simulator-udid>
```
### Debug 运行时地址
iPhone 真机不能用 `127.0.0.1` 访问 Mac;真机联调时需让手机与 Mac 位于同一网络,
并通过调试入口临时填写 Mac 的局域网地址。
debug 版本可在「我的 → 设置 → 服务器地址」修改后端地址,保存后重启 App 生效。
地址优先级:
### 服务地址配置
```text
本地运行时设置 > --dart-define(API_BASE_URL) > 平台默认地址
地址是代码里的一个开关,**不做任何网络探测**,也不用传构建参数。两套环境各占
一个文件:
| 文件 | 用途 | 默认值 |
| --- | --- | --- |
| `lib/core/config/dev_config.dart` | 开发 / 联调 | `http://127.0.0.1:8081` |
| `lib/core/config/prod_config.dart` | 生产 | `http://39.162.50.99:8081` |
切换环境只改 `lib/core/config/app_config.dart` 里的一个布尔值:
```dart
static const bool useDevConfig = true; // false 即用生产地址
```
因此不带 `--dart-define` 构建的 debug APK 也可在安装后改成当前电脑 IP。
release 版本不显示入口,也不会读取本地覆盖。
真机或 Android 模拟器联调时,通过调试入口覆盖地址,不修改默认开发配置。打生产包前把
`useDevConfig` 改成 `false`;release 构建若仍为 `true` 会在启动时直接报错,
避免线上包连到开发机。
debug 包在找剧页加载失败时会显示调试条,点「修改服务器地址」可临时改成当前
电脑 IP,保存后立即重载、不需要重新打包,该覆盖保存在本地偏好里(仅 debug
生效,release 不读取)。
## 画中画
| 平台 | 行为 |
| --- | --- |
| Android | 首次点播放页小窗按钮时申请悬浮窗权限;授权后退出 App 自动进入系统小窗。沉浸流与独立播放页共用一份引用计数,任一处活跃都算「在播」,避免互相顶掉 |
| iOS | 原生影子播放器承载 `AVPictureInPictureController`,只有播放页处于活跃状态时退到后台才自动进小窗;停在剧单等页面退后台不会触发 |
- 小窗内切集直接换源,不走页面翻页,可连续自动播放
- iOS 从系统小窗还原时用原生过渡层盖住纹理黑帧,等首帧就绪后再淡出
- 播放页「更多」面板里有「退出自动小窗」开关(仅支持自动小窗的平台显示),关掉后
退到后台不再进入小窗
## 环境注意
@@ -131,46 +157,56 @@ xcodebuild -resolvePackageDependencies \
```bash
adb uninstall com.stormg.lumadrama
flutter run -d <device> \
--dart-define=API_BASE_URL=http://127.0.0.1:8081
flutter run -d <device>
```
## 生产打包(Android)
生产包只包含以下两个 ABI,**打成一个 APK**,不做 split:
两个渠道出两种产物,源码同一套:
| ABI | 适用设备 |
| --- | --- |
| `arm64-v8a` | 现代手机(64 位) |
| `armeabi-v7a` | 老 32 位机 |
```bash
flutter build apk --release --target-platform android-arm64,android-arm
# 产出单个:build/app/outputs/flutter-apk/app-release.apk(约 37MB)
```
| 渠道 | 产物 | 命令 | 体积 |
| --- | --- | --- | --- |
| Google Play | AAB(按设备下发) | `flutter build appbundle --release` | 上传 28MB,用户下载约 8MB |
| 国内各大市场 | 通用 APK(arm64 + v7) | `flutter build apk --release` | 约 13MB |
说明:
- `android/app/build.gradle.kts` 的 `release` 已配置 `abiFilters`,只保留 `arm64-v8a` 与 `armeabi-v7a`,插件也不会再带入 `x86_64` 原生库。
- `x86_64` 只用于模拟器,不进入生产包。
- 不要直接运行 `flutter build apk --release`:默认会编译三套原生库,包体约 57MB。
- 只有需要进一步压缩单机下载体积时,才考虑 `--split-per-abi` 出分架构包(arm64 约 21MB、armv7 约 19MB),默认不用。
- `android/gradle.properties` 里固定了 `split-debug-info=build/symbols` 与 `dart-obfuscation=true`,**IDE 里点 Build APK / Build App Bundle 也会生效**:`libapp.so` 从 ~8MB/ABI 降到 ~1.1MB/ABI。
- `useLegacyPackaging = true`:原生库以压缩形式存储,这是国内 APK 从 40MB 降到 13MB 的主要原因;代价是安装时解压。
- **每次发版都要归档 `build/symbols`**,线上崩溃栈需要它还原。
- release 仍在用 debug 签名(`build.gradle.kts` 的 TODO),上架前必须换成正式 keystore。
- 不要用 `--split-per-abi`:与 `abiFilters` 冲突;Play 的 AAB 已经按设备拆好。
## 生产打包(iOS)
```bash
# 正式签名(需要 iOS Distribution 证书 + App Store 描述文件)
flutter build ipa --release
# 只有 Apple Development 证书时:出开发签名 IPA,只能装已注册设备
flutter build ipa --release --export-method development
```
产物在 `build/ios/ipa/*.ipa`。画中画依赖 `UIBackgroundModes` 里的 `audio` 与
`AVPictureInPictureController`,改动 `ios/Runner/Info.plist` 或 `AppDelegate.swift`
后要重新构建,热重载不会生效。
## 门禁
```bash
dart analyze lib test
dart analyze
flutter test
flutter build apk --debug
```
测试文件按模块放在 `test/` 下,用例名使用
当前基线:`dart analyze` 仅 1 条既存 info(`intl` 未在 `pubspec.yaml` 声明);
`flutter test` 全量 775 例通过。测试文件按模块放在 `test/` 下,用例名使用
`should_<期望>_when_<条件>`。真实后端联调测试在服务未启动时会跳过。
## 当前边界
- 下载仅管理服务端授权,不落盘、不续传、不支持离线播放。
- 没有独立搜索接口,搜索能力尚未形成完整闭环。
- 下载会落盘并支持离线播放,但不支持断点续传:中途失败会丢弃 `.part` 重下。
- 支付与金币:客户端已有钱包、商品、下单接口与页面,商店票据校验依赖服务端配置凭据。
- 站内通知没有已读/未读和红点状态。
- 支付、金币和会员权益尚未形成客户端闭环。
- Android 支持系统画中画;iOS 画中画尚未接入。
- 播放清晰度切换会保留旧画面 500ms 掩盖闪屏,切换瞬间的进度以相对位置续播。
+1
View File
@@ -1,4 +1,5 @@
/.gradle
/build/
/captures/
/local.properties
GeneratedPluginRegistrant.java
+13 -1
View File
@@ -8,7 +8,9 @@ plugins {
android {
namespace = "com.stormg.lumadrama"
compileSdk = flutter.compileSdkVersion
// permission_handler_android 14 的 AAR 元数据要求依赖方 compileSdk >= 37,
// 固定为 37(比 Flutter 默认的 36 高一档,只影响编译期 API 可见性)。
compileSdk = 37
ndkVersion = flutter.ndkVersion
compileOptions {
@@ -33,6 +35,13 @@ android {
ndk {
abiFilters += listOf("arm64-v8a", "armeabi-v7a")
}
// R8 裁剪未使用的 Java/Kotlin 代码与资源,减小 dex 与 res。
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.getByName("debug")
@@ -50,6 +59,9 @@ kotlin {
androidComponents {
onVariants(selector().withBuildType("release")) { variant ->
variant.packaging.jniLibs.excludes.add("lib/x86_64/**")
// 原生库随 APK 压缩存储:下载体积明显小于解压后的体积,代价是安装时解压。
// 本包 90% 体积是 so,这一项对国内商店的 APK 分发影响最大。
variant.packaging.jniLibs.useLegacyPackaging = true
}
}
+11
View File
@@ -0,0 +1,11 @@
# Author: fruit.com.cn
#
# R8 保号规则:Flutter 引擎与插件自带的 consumer rules 已覆盖大部分场景,
# 这里只补本项目原生层通过反射/通道访问、裁剪后容易失效的入口。
# 画中画与权限通道由 MainActivity 直接注册,保留应用包名下的入口类。
-keep class com.stormg.lumadrama.** { *; }
# Flutter 引擎在 release 下通过 JNI 回调这些类,禁止改名。
-keep class io.flutter.** { *; }
-dontwarn io.flutter.embedding.**
+13 -9
View File
@@ -1,9 +1,12 @@
<!-- Author: fruit.com.cn -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission
android:name="android.permission.INTERNET"/>
<!-- 画中画自动触发依赖的「显示在其他应用上层」权限(部分 ROM 用它管控 PiP) -->
<uses-permission
android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application
android:label="FruitShorts"
android:label="ymb"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true">
@@ -23,9 +26,8 @@
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
@@ -35,7 +37,7 @@
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
android:value="2"/>
</application>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility and
@@ -44,8 +46,10 @@
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
<action
android:name="android.intent.action.PROCESS_TEXT"/>
<data
android:mimeType="text/plain"/>
</intent>
</queries>
</manifest>
@@ -4,6 +4,7 @@ package com.stormg.lumadrama
import android.content.Intent
import android.app.PictureInPictureParams
import android.content.Context
import android.content.res.Configuration
import android.graphics.Bitmap
import android.media.MediaMetadataRetriever
@@ -12,6 +13,8 @@ import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.provider.Settings
import android.telephony.TelephonyManager
import android.util.Rational
import android.content.pm.PackageManager
import android.view.WindowManager
@@ -21,6 +24,7 @@ import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import java.io.ByteArrayOutputStream
import java.util.Locale
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.concurrent.atomic.AtomicBoolean
@@ -36,6 +40,9 @@ class MainActivity : FlutterActivity() {
private var imeInset = 0
override fun onCreate(savedInstanceState: Bundle?) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
splashScreen.setOnExitAnimationListener { screen -> screen.remove() }
}
super.onCreate(savedInstanceState)
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
}
@@ -62,6 +69,23 @@ class MainActivity : FlutterActivity() {
result.success(false)
}
}
// 设备标识:SSAID 免权限,卸载重装不变,避免客户端自己生成的 id 每次重装都变
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.stormg.lumadrama/device")
.setMethodCallHandler { call, result ->
when (call.method) {
"ssaid" -> {
val value = try {
Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
} catch (_: Exception) {
null
}
result.success(value)
}
// 设备区域:注册时作为服务端 IP 解析失败后的兜底
"region" -> result.success(currentRegion())
else -> result.notImplemented()
}
}
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.stormg.lumadrama/share")
.setMethodCallHandler { call, result ->
if (call.method != "shareText") {
@@ -153,6 +177,28 @@ class MainActivity : FlutterActivity() {
?.bottom
?: 0
/** 网络运营商国家优先,其次 SIM 卡,最后系统语言;都拿不到返回空串。 */
private fun currentRegion(): String {
return try {
val telephony = getSystemService(Context.TELEPHONY_SERVICE) as? TelephonyManager
val localeCountry = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
resources.configuration.locales.get(0).country
} else {
@Suppress("DEPRECATION")
resources.configuration.locale.country
}
val candidates = listOfNotNull(
telephony?.networkCountryIso,
telephony?.simCountryIso,
localeCountry
)
candidates.firstOrNull { it.isNotBlank() }?.uppercase(Locale.ROOT) ?: ""
} catch (_: Exception) {
// 个别 ROM 读运营商信息会抛 SecurityException,别让注册流程卡住
""
}
}
private fun emitImeInset(value: Int) {
if (value == imeInset) return
imeInset = value
@@ -238,6 +284,7 @@ class MainActivity : FlutterActivity() {
}
companion object {
private const val TAG = "FruitPip"
private const val thumbnailMaxWidth = 240
private const val thumbnailJpegQuality = 70
private const val thumbnailTimeoutMs = 1500L
Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

@@ -1,4 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Author: fruit.com.cn -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/splash_background" />
<item>
<shape android:shape="rectangle">
<gradient
android:type="radial"
android:centerX="0"
android:centerY="0"
android:gradientRadius="350dp"
android:startColor="#FF6B011A"
android:centerColor="#616B011A"
android:endColor="#006B011A" />
</shape>
</item>
<item>
<bitmap
android:gravity="center"
android:src="@drawable/splash_screen" />
</item>
</layer-list>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

@@ -1,4 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Author: fruit.com.cn -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/splash_background" />
<item>
<shape android:shape="rectangle">
<gradient
android:type="radial"
android:centerX="0"
android:centerY="0"
android:gradientRadius="350dp"
android:startColor="#FF6B011A"
android:centerColor="#616B011A"
android:endColor="#006B011A" />
</shape>
</item>
<item>
<bitmap
android:gravity="center"
android:src="@drawable/splash_screen" />
</item>
</layer-list>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 B

After

Width:  |  Height:  |  Size: 69 B

@@ -1,9 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Author: fruit.com.cn -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/splash_background" />
<item>
<bitmap android:gravity="fill" android:src="@drawable/background"/>
<shape android:shape="rectangle">
<gradient
android:type="radial"
android:centerX="0"
android:centerY="0"
android:gradientRadius="350dp"
android:startColor="#FF6B011A"
android:centerColor="#616B011A"
android:endColor="#006B011A" />
</shape>
</item>
<item>
<bitmap android:gravity="center" android:src="@drawable/splash"/>
<bitmap
android:gravity="center"
android:src="@drawable/splash_screen" />
</item>
</layer-list>
@@ -1,6 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Author: fruit.com.cn -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/splash_background" />
<item>
<shape android:shape="rectangle">
<gradient
android:type="radial"
android:centerX="0"
android:centerY="0"
android:gradientRadius="350dp"
android:startColor="#FF6B011A"
android:centerColor="#616B011A"
android:endColor="#006B011A" />
</shape>
</item>
<item>
<bitmap
android:gravity="center"
android:src="@drawable/splash_screen" />
</item>
</layer-list>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 B

After

Width:  |  Height:  |  Size: 69 B

@@ -1,9 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Author: fruit.com.cn -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/splash_background" />
<item>
<bitmap android:gravity="fill" android:src="@drawable/background"/>
<shape android:shape="rectangle">
<gradient
android:type="radial"
android:centerX="0"
android:centerY="0"
android:gradientRadius="350dp"
android:startColor="#FF6B011A"
android:centerColor="#616B011A"
android:endColor="#006B011A" />
</shape>
</item>
<item>
<bitmap android:gravity="center" android:src="@drawable/splash"/>
<bitmap
android:gravity="center"
android:src="@drawable/splash_screen" />
</item>
</layer-list>
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<background android:drawable="@color/ic_launcher_background"/>
<foreground>
<inset
android:drawable="@drawable/ic_launcher_foreground"
android:inset="16%" />
</foreground>
</adaptive-icon>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 762 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

@@ -1,11 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Author: fruit.com.cn -->
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowSplashScreenBackground">@color/splash_background</item>
<item name="android:forceDarkAllowed">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
<item name="android:windowSplashScreenBackground">#000000</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/android12splash</item>
<item name="android:windowSplashScreenAnimationDuration">0</item>
</style>
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@color/splash_background</item>
@@ -1,11 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Author: fruit.com.cn -->
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowSplashScreenBackground">@color/splash_background</item>
<item name="android:forceDarkAllowed">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
<item name="android:windowSplashScreenBackground">#000000</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/android12splash</item>
<item name="android:windowSplashScreenAnimationDuration">0</item>
</style>
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">@color/splash_background</item>
+2 -1
View File
@@ -2,5 +2,6 @@
<!-- Author: fruit.com.cn -->
<resources>
<color name="splash_background">#1F1B16</color>
<color name="splash_background">#000000</color>
<color name="ic_launcher_background">#E9142E</color>
</resources>
+5
View File
@@ -6,3 +6,8 @@ android.useAndroidX=true
android.newDsl=false
# This builtInKotlin flag was added by the Flutter template
android.builtInKotlin=false
# release 包默认剥离 Dart 调试符号并混淆:libapp.so 由 ~8MB 降到 ~1MB/ABI。
# 符号表输出到 build/symbols,崩溃分析时用它还原堆栈,发布前务必归档。
split-debug-info=build/symbols
dart-obfuscation=true
Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

+135 -2
View File
@@ -1183,6 +1183,139 @@ $ flutter test
- 按最新反馈移除整行榜单与热度胶囊,信息顺序收敛为标题、剧名、标签、简介、观看全集。
- 剧名 19/w600,箭头 20 白色并紧邻剧名;标签行改为 13/w600 亮灰内联布局。
- 简介「展开/收起」沿用现有三语文案;进度条热区恢复 24 并接入拖动自动清屏与预览卡片。
- 拖动期间隐藏操作栏、文字及根底栏,顶部导航常驻;松手后持续清屏直到点击画面。
- 进度条固定中心并动画到 6 高,时间气泡限制在左右 12;松手恢复拖动前浮层状态。
- 拖动仅控制视频浮层内容,顶部导航与根底栏保持常驻。
- 进度条固定中心并动画到 6 高,命中高度 32,时间气泡限制在左右 12;end/cancel/pointer 兜底均恢复拖动前状态。
- 修复 `scrubCancelRequest` 误置于 `initState` 的编译错误,并清理推荐页未使用变量;`flutter analyze` 无问题。
- 观看全集按钮相对进度条上移 8,间距调整为 20;按钮改为屏幕宽度 70% 左对齐,`flutter analyze` 无问题。
## 2026-10-22 进度条按下与拖动彻底修复
- Slider 不再在 `onChangeStart` 清屏;首次真实移动后才进入 scrub,轨道 2/6、thumb 6/8。
- 推荐流拖动使用独立 opaque 手势与 pointer 兜底,end/cancel 同时恢复浮层和轨道。
- 推荐浮层改为 AnimatedOpacity + IgnorePointer,进度条节点始终留在树中;scrub setState 均加 mounted 守卫。
- `flutter test test/player/seek_scrub_visibility_test.dart`:6 项测试全部通过。
## 2026-10-22 推荐页播放跳转修正
- 标题、剧名行和观看全集统一通过 `playDramaFromCatalog` 打开非 `homeMode` 逐集播放页。
- 仅含集数的剧集标题不再显示在标题上方,集数只保留下方进度文案。
- `flutter analyze`:No issues found。
## 2026-10-22 推荐页横向切换
- 推荐、剧单、全部短剧改为共享 PageController 的横向 PageView,点击与滑动均驱动同一选中态。
- 三页使用 AutomaticKeepAliveClientMixin 保留视频、滚动位置和筛选状态;顶部导航固定在外层。
- `flutter analyze`:No issues found。
## 2026-10-22 全部短剧布局重排
- 四行筛选统一 28 高、8 行距、24 项目间距;选中 chip 改为 `#4A1E1E`、白字 13/w600、圆角 14。
- 最热/最新改为纯文字选中态,三横线筛选固定在右端;网格改为左右 12、列距 6、行距 12。
- 第三行筛选完整展示,卡片继续复用首页组件;`flutter analyze`:No issues found。
- 筛选项字号提升到 15、圆角 15;筛选区移出滚动容器并固定吸顶,下拉刷新仅作用于网格。
- 四行首项文字统一到同一 x;行高 30、行距 6、项目距 12,第 4 行保持弹性空白后固定筛选图标。
- 按最新截图改为 16sp、32 高、10 行距、16 项距;选中态为 `#21090E` 底配 `#FF4D6A` 粉字。
- 第 4 行复用选中胶囊样式,右侧改为 44×44 圆形深灰按钮和 22 三横线图标;`flutter analyze` 无问题。
- 筛选行距收紧到 6、项距 10,chip 左右 padding 12;四行均可横向回弹滑动。
- 第 4 行仅最热/最新在滚动区内,44 圆形筛选按钮固定在滚动区外;`flutter analyze` 无问题。
- 四行统一复用 `_filterRow` 构建,筛选区仅保留一层左右 12 padding。
- 新增量化测试断言四行首项 x 均为 12、相邻 chip 间距均为 10;`flutter analyze` 无问题。
- 修复横向 viewport 对短内容居中:滚动内容最小宽度撑满视口后由 Row.start 排列。
- `flutter test test/recommend/all_dramas_filter_alignment_test.dart`:1 项测试通过。
## 2026-10-22 首页二级标签移除筛选按钮
- 首页二级标签行改为纯横向滑动,右侧三横线按钮不渲染也不占位。
- 删除不再使用的筛选回调、尺寸 token、颜色和 CustomPainter;全部短剧页筛选按钮保持不变。
- `flutter analyze`:No issues found。
- 按后续更正恢复首页透明三横线按钮(26、无背景、`#7A7A7E`),删除全部短剧第 4 行圆形按钮及回调链路。
## 2026-10-22 追剧页三列改造
- 追剧页移除预约 tab,改为追剧/播放历史双页横向切换,并保留各自滚动位置。
- 追剧与历史统一三列卡片,新增固定加号卡片,历史进度与编辑删除能力保留。
- 按最新口径调整列距 6、行距 12、封面圆角 6;`flutter analyze`:No issues found。
## 2026-10-22 播放历史单列列表
- 追剧保持三列网格,播放历史改为左封面右信息的单列列表,行距 16。
- 历史卡片补充 96×128 封面、观看进度、已看百分比、继续观看和编辑删除。
- 追剧加号卡片移到全部追剧卡片之后,空列表时仍在左上角。
- 加号改为 `#8E8E93`、28 尺寸、1.5 描边,卡片底色与圆角不变。
- 刷新、分页与各页独立滚动位置保持;`flutter analyze`:No issues found。
## 2026-10-22 追剧页切换与编辑按钮修正
- 追剧与历史页增加 keep-alive,tab 与编辑态改用局部 ValueNotifier 更新,切换不再重建整个页面。
- 编辑图标调整为 20、`#B0B0B0`,热区 40×40,保持右侧 14 边距和垂直居中。
- 列表刷新期间保留已有数据与各页滚动位置;`flutter analyze`:No issues found。
## 2026-10-22 播放历史继续观看按钮微调
- 继续观看改为无边框、无底色的纯文字按钮,默认 `#B0B0B0`、12/w500,按压态使用品牌色。
- 保持 28 高点击热区和右侧零间距;未执行测试或 analyze。
## 2026-10-22 我的页渐变与图标网格
- 页面背景改为暖黑三段纵向渐变,用户区与 VIP 卡布局保持不变。
- 行式入口替换为 4 列图标网格,7 个原入口按顺序保留,第 8 格为空占位。
- 网格使用 14 边距、半透明深灰底、圆角 12 和仅内部 1px 分隔线;`flutter analyze`:No issues found。
- 渐变增强为 `#3A1B0E`/`#1A0C07`/黑色并叠加顶部品牌橙径向光晕,同时移除页面级「我的」标题栏。
- 7 个宫格图标分别使用金币金、天蓝、薄荷绿、粉红、紫色、青色和冷灰;`flutter analyze`:No issues found。
## 2026-10-22 我的页补充内容
- VIP 与宫格之间新增继续观看横向列表、追剧/观看记录/金币统计面板,继续观看最多 10 条。
- 宫格后新增常见问题与关于我们入口;关于页版本暂用与 pubspec 同步的常量占位。
- 继续观看全部入口可切到追剧页播放历史 tab;`flutter analyze`:No issues found。
- 用户区昵称与 UID 收紧为 4 间距,昵称列相对头像垂直居中;UID 12、复制图标 14。
- UID 行改用 GestureDetector 并锁定 16 高,昵称与 UID 间距 2、昵称行高 1.15,避免 Material 热区撑高;`flutter analyze`:No issues found。
## 2026-10-22 推荐剧单渐变背景
- 仅为推荐页「剧单」子页增加暖黑三段渐变和品牌橙径向光晕,推荐视频与全部短剧背景不变。
- 渐变复用「我的」页色值,光晕使用 `#26FF6B2C`;分区与卡片样式保持原样;`flutter analyze`:No issues found。
## 2026-10-22 全站深色视觉统一
- 全局 token 改为纯黑页面、`#16161A` 卡片、`#1C1C1E` 描边/分割线与 B0/8E 文本层级,旧深蓝页面渐变替换为暖黑渐变。
- 普通二级页标题栏改为透明、白色标题与返回图标;统一卡片 12 圆角、1px 描边和无阴影策略。
- 覆盖新剧、筛选、榜单、预约、收藏、观看历史、下载、设置、钱包、VIP、通知、详情、登录、关于;播放器沉浸区保持纯黑。
- `flutter analyze`:No issues found。
## 2026-10-22 统一下拉与加载指示器
- 下拉刷新统一为 40×40、60% 黑底圆角指示器内嵌 20 白色加载圈,不再显示任何状态文字。
- 网络分页与本地分页 footer 统一仅显示白色加载圈,无更多状态完全隐藏;通知页补触底自动加载。
- 移除不再使用的刷新提示与无更多文案;`flutter analyze`:No issues found。
## 2026-10-22 首页热播榜重做
- 首页榜单 tab 改为独立领奖台 + 单列排行布局,不再复用三列网格。
- 前三名按 2/1/3 排列,冠军放大并上移;第 4 名起使用大号描边名次与横向信息行。
- 榜单沿用现有播放热度排序、分页和播放逻辑;`flutter analyze`:No issues found。
## 2026-10-22 播放器双击点赞与飘心
- 沉浸式播放器改用 onTapUp + 280ms Timer 判定双击,双击取消单击,长按左右倍速与中间更多保持不变。
- 双击和右侧心形共用点赞方法,成功后控制器通知并点亮红色实心心形,失败由 controller 回滚并使用 Toast。
- 飘心层使用独立 IgnorePointer Stack,动画完成后自动移除;`flutter analyze`:No issues found。
- `flutter test test/player/double_tap_like_test.dart`:2 项测试全部通过。
- 移除视频表面点击识别器,双击后增加 300ms 暂停防护;飘心收敛为 3~4 颗、20~26、±18、90~120dp、600~700ms。
- 双击窗口延长至 320ms,单击 Timer 使用点击序号校验,双击后保留 350ms 播放切换保护。
- `double_tap_like_test.dart` 覆盖 120/250/300ms 双击与 500ms 单击恢复:2 项测试全部通过。
## 2026-10-22 统一二级搜索页
- 首页与推荐/剧单/全部短剧搜索入口统一 push SearchPage,不再切换推荐 tab 聚焦。
- 搜索页提供返回、自动聚焦输入框与取消,复用 `/app/search` 逻辑和首页三列卡片。
- 清理旧的 searchRequest/focusSearch/syncSearch 参数;`flutter analyze`:No issues found。
- 搜索页结果改为独立两列卡片,左右 14、列距 12、行距 16,并移除 HomeFeedCard 复用。
- 搜索结果支持下拉刷新:保留旧结果按当前关键词重取第一页,空关键词直接回弹且不改变焦点。
## 2026-10-22 App 图标与开屏更新
- Launcher/Android 12 启动背景统一纯黑,自适应图标背景改为品牌橙。
- Android/iOS 图标与启动资源已重新生成;应用内开屏固定 splash_logo,宽 200 等比居中。
- `flutter analyze`:No issues found。
- 移除 Flutter 内 `_startupSplash` 与 `startup-splash`,只保留系统原生开屏;最新斜体字标素材已重新生成。
+4
View File
@@ -11,6 +11,7 @@
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
8C4E1A022F9A4B1000C636F3 /* WirelessDataPrompt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C4E1A012F9A4B1000C636F3 /* WirelessDataPrompt.swift */; };
7884E8682EC3CC0700C636F2 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */; };
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
@@ -49,6 +50,7 @@
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
8C4E1A012F9A4B1000C636F3 /* WirelessDataPrompt.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WirelessDataPrompt.swift; sourceTree = "<group>"; };
7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
@@ -122,6 +124,7 @@
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
8C4E1A012F9A4B1000C636F3 /* WirelessDataPrompt.swift */,
7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */,
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
);
@@ -282,6 +285,7 @@
buildActionMask = 2147483647;
files = (
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
8C4E1A022F9A4B1000C636F3 /* WirelessDataPrompt.swift in Sources */,
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
7884E8682EC3CC0700C636F2 /* SceneDelegate.swift in Sources */,
);
+504 -8
View File
@@ -1,6 +1,9 @@
import Flutter
import UIKit
import AVFoundation
import AVKit
private let thumbnailHTTPHeaderFieldsKey = "AVURLAssetHTTPHeaderFieldsKey"
private final class ThumbnailResponseGate {
private let lock = NSLock()
@@ -29,12 +32,325 @@ final class RunnerFlutterViewController: FlutterViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor(red: 16.0 / 255.0, green: 12.0 / 255.0, blue: 10.0 / 255.0, alpha: 1)
view.backgroundColor = .black
}
}
/// iOS 影子播放器:独立 AVPlayer + AVPlayerLayer 专供画中画窗口。
/// Flutter 的 video_player 走纹理渲染,没有 AVPlayerLayer,无法直接创建
/// AVPictureInPictureController;小窗的画面与声音由影子接管,退出时把
/// 影子进度回传给 Dart,由 Flutter 播放器 seek 对齐后继续。
final class PipShadowCoordinator: NSObject, AVPictureInPictureControllerDelegate {
static let shared = PipShadowCoordinator()
private var player: AVPlayer?
private var playerLayer: AVPlayerLayer?
private var controller: AVPictureInPictureController?
private var endObserver: NSObjectProtocol?
private var possibleObservation: NSKeyValueObservation?
/// 画中画还原过渡层:原生窗口级红晕渐变,在系统还原动画开始时立即盖上,
/// 避免回前台瞬间 Flutter 表面未恢复显示黑帧;视频出帧后由 Dart 通知淡出。
private var restoreOverlay: UIView?
/// 系统要求 playerLayer 位于真实的 view 层级中才会判定画中画可用,
/// 因此用 1x1 透明宿主 view 承载,而不是直接挂在 window.layer 上。
private var hostView: UIView?
/// 影子图层就绪稍晚于创建,置位后由 KVO 自动拉起画中画。
private var pendingStart = false
private var startRetryWorkItems: [DispatchWorkItem] = []
weak var channel: FlutterMethodChannel?
/// active 变化回调;停止时把影子最终进度(毫秒)一并提供。
var onPipChanged: ((Bool, Int64) -> Void)?
/// 影子在画中画里播完当前集。
var onPlaybackEnded: (() -> Void)?
static var isSupported: Bool {
AVPictureInPictureController.isPictureInPictureSupported()
}
private var keyWindow: UIWindow? {
UIApplication.shared.connectedScenes
.compactMap { $0 as? UIWindowScene }
.flatMap { $0.windows }
.first { $0.isKeyWindow }
}
/// 首次创建影子:1x1 图层挂在 keyWindow 的宿主 view 里(肉眼不可见),静音待命。
/// [autoEnter] 为 true 时退后台由系统自动拉起画中画(需影子在播,见 armAutoEnter)。
func prepare(urlString: String, positionMs: Int64, autoEnter: Bool) {
teardown()
log("prepare begin supported=\(PipShadowCoordinator.isSupported) autoEnter=\(autoEnter)")
guard Self.isSupported else { return }
guard let url = URL(string: urlString) else {
log("prepare failed bad url \(urlString)")
return
}
guard let window = keyWindow else {
log("prepare failed no key window")
return
}
let item = AVPlayerItem(url: url)
let p = AVPlayer(playerItem: item)
p.isMuted = true
p.actionAtItemEnd = .pause
let layer = AVPlayerLayer()
layer.player = p
let host = UIView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
host.isUserInteractionEnabled = false
host.backgroundColor = .clear
window.addSubview(host)
layer.frame = host.bounds
host.layer.addSublayer(layer)
hostView = host
guard let c = AVPictureInPictureController(playerLayer: layer) else {
p.pause()
log("prepare failed no pip controller")
return
}
c.canStartPictureInPictureAutomaticallyFromInline = autoEnter
c.delegate = self
player = p
playerLayer = layer
controller = c
// 静音起播让 item 完成首帧解码,isPictureInPicturePossible 才会变 true。
p.play()
possibleObservation = c.observe(
\.isPictureInPicturePossible,
options: [.new, .initial]
) { [weak self] controller, change in
let value = change.newValue ?? controller.isPictureInPicturePossible
self?.log("possible changed to \(value)")
guard let self, self.pendingStart, controller.isPictureInPicturePossible else { return }
self.pendingStart = false
// 刚翻 true 的同一 runloop 里调用会被系统静默拒绝,推到下一拍再进。
DispatchQueue.main.async {
guard self.controller === controller, controller.isPictureInPicturePossible else {
self.log("start via kvo aborted (shadow replaced)")
return
}
self.log("start via kvo")
controller.startPictureInPicture()
}
}
log("shadow ready, seeking to \(positionMs)ms")
if positionMs > 0 {
p.seek(
to: CMTime(value: positionMs, timescale: 1000),
toleranceBefore: .zero,
toleranceAfter: .zero
)
}
registerEndObserver(for: item)
activateAudioSession()
}
/// 退出 App 前(inactive)把影子对齐到当前进度并静音起播:
/// auto PiP 只在「player 正在播放 + 图层离屏」时由系统触发。
func armAutoEnter(positionMs: Int64) {
guard let player, let controller else {
log("arm failed, shadow missing")
return
}
guard controller.canStartPictureInPictureAutomaticallyFromInline else {
log("arm failed, autoEnter disabled on shadow")
return
}
log("arm auto enter at \(positionMs)ms")
if positionMs > 0 {
player.seek(
to: CMTime(value: positionMs, timescale: 1000),
toleranceBefore: CMTime(value: 800, timescale: 1000),
toleranceAfter: CMTime(value: 800, timescale: 1000)
)
}
player.play()
}
/// 回前台后取消待命:影子暂停回静音,等待下一次退后台。
func disarmAutoEnter() {
guard let player else { return }
log("disarm auto enter")
player.pause()
player.isMuted = true
}
/// 进入画中画:图层就绪则立即进入,否则 KVO/延时重试在就绪后自动进入。
/// 仅当影子从未创建成功(prepare 失败)时返回 false。
func start() -> Bool {
guard let controller else {
log("start failed, shadow not created")
return false
}
log("start requested possible=\(controller.isPictureInPicturePossible)")
pendingStart = true
if controller.isPictureInPicturePossible {
pendingStart = false
controller.startPictureInPicture()
}
scheduleStartRetries()
return true
}
/// KVO 偶发不触发或流加载较慢时兜底:就绪后再试两次。
private func scheduleStartRetries() {
startRetryWorkItems.forEach { $0.cancel() }
startRetryWorkItems.removeAll()
for delay in [1.0, 2.5] {
let item = DispatchWorkItem { [weak self] in
guard
let self,
self.pendingStart,
let controller = self.controller,
controller.isPictureInPicturePossible
else { return }
self.log("start via retry after \(delay)s")
self.pendingStart = false
controller.startPictureInPicture()
}
startRetryWorkItems.append(item)
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: item)
}
}
/// 画中画内换集:只换 AVPlayerItem,不动 player/layer,窗口不中断。
func replaceItem(urlString: String, positionMs: Int64) {
guard let player, let url = URL(string: urlString) else { return }
let item = AVPlayerItem(url: url)
player.replaceCurrentItem(with: item)
registerEndObserver(for: item)
if positionMs > 0 {
player.seek(
to: CMTime(value: positionMs, timescale: 1000),
toleranceBefore: .zero,
toleranceAfter: .zero
)
}
}
/// 进入画中画后解除静音并起播(此时 Flutter 播放器已被暂停)。
func unmuteAndPlay() {
player?.isMuted = false
player?.play()
}
func positionMs() -> Int64 {
Int64(max(0, player?.currentTime().seconds ?? 0) * 1000)
}
func stopPip() {
controller?.stopPictureInPicture()
}
func teardown() {
startRetryWorkItems.forEach { $0.cancel() }
startRetryWorkItems.removeAll()
possibleObservation?.invalidate()
possibleObservation = nil
pendingStart = false
if let endObserver {
NotificationCenter.default.removeObserver(endObserver)
}
endObserver = nil
player?.pause()
player?.replaceCurrentItem(with: nil)
playerLayer?.removeFromSuperlayer()
playerLayer = nil
hostView?.removeFromSuperview()
hostView = nil
controller?.delegate = nil
controller = nil
player = nil
}
/// 诊断日志:NSLog 之外同步转发到 Dart,便于在 flutter run 控制台观察。
private func log(_ message: String) {
NSLog("pip: %@", message)
channel?.invokeMethod("pipDebug", arguments: message)
}
private func registerEndObserver(for item: AVPlayerItem) {
if let endObserver {
NotificationCenter.default.removeObserver(endObserver)
}
endObserver = NotificationCenter.default.addObserver(
forName: .AVPlayerItemDidPlayToEndTime,
object: item,
queue: .main
) { [weak self] _ in
self?.log("item did play to end")
self?.onPlaybackEnded?()
}
}
/// 画中画的声音走影子播放器,需要 playback 类别的音频会话保活。
private func activateAudioSession() {
do {
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .moviePlayback)
try AVAudioSession.sharedInstance().setActive(true)
} catch {
// 会话激活失败只影响后台出声,不阻断画中画。
}
}
func pictureInPictureControllerWillStartPictureInPicture(
_ pictureInPictureController: AVPictureInPictureController
) {
log("will start")
pendingStart = false
onPipChanged?(true, 0)
}
func pictureInPictureControllerWillStopPictureInPicture(
_ pictureInPictureController: AVPictureInPictureController
) {
log("will stop, showing restore overlay")
showRestoreOverlay()
}
func pictureInPictureControllerDidStopPictureInPicture(
_ pictureInPictureController: AVPictureInPictureController
) {
log("did stop")
showRestoreOverlay()
onPipChanged?(false, positionMs())
}
/// 盖原生过渡层(幂等):主题红晕渐变,不依赖 Flutter 渲染。
func showRestoreOverlay() {
guard let window = keyWindow else { return }
restoreOverlay?.removeFromSuperview()
let overlay = UIView(frame: window.bounds)
overlay.autoresizingMask = [.flexibleWidth, .flexibleHeight]
let gradient = CAGradientLayer()
gradient.frame = overlay.bounds
gradient.colors = [
UIColor(red: 0.298, green: 0.086, blue: 0.102, alpha: 1).cgColor,
UIColor(red: 0.118, green: 0.043, blue: 0.047, alpha: 1).cgColor,
UIColor(red: 0.063, green: 0.063, blue: 0.071, alpha: 1).cgColor,
]
gradient.locations = [0, 0.22, 0.62]
gradient.startPoint = CGPoint(x: 0.5, y: 0)
gradient.endPoint = CGPoint(x: 0.5, y: 1)
overlay.layer.addSublayer(gradient)
window.addSubview(overlay)
restoreOverlay = overlay
}
/// 淡出并移除过渡层(视频首帧已确认后由 Dart 调用)。
func hideRestoreOverlay() {
guard let overlay = restoreOverlay else { return }
restoreOverlay = nil
UIView.animate(
withDuration: 0.25,
animations: { overlay.alpha = 0 }
) { _ in overlay.removeFromSuperview() }
}
}
@main
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
private let wirelessDataPrompt = WirelessDataPrompt()
private let thumbnailQueue = DispatchQueue(
label: "com.stormg.lumadrama.thumbnail",
qos: .userInitiated
@@ -48,8 +364,20 @@ final class RunnerFlutterViewController: FlutterViewController {
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func applicationDidBecomeActive(_ application: UIApplication) {
super.applicationDidBecomeActive(application)
requestWirelessDataPrompt()
}
func requestWirelessDataPrompt() {
wirelessDataPrompt.requestSystemPrompt()
}
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
registerWirelessDataChannel(engineBridge)
registerDeviceIdChannel(engineBridge)
registerPipChannel(engineBridge)
let channel = FlutterMethodChannel(
name: "com.stormg.lumadrama/share",
binaryMessenger: engineBridge.applicationRegistrar.messenger()
@@ -58,15 +386,29 @@ final class RunnerFlutterViewController: FlutterViewController {
guard call.method == "shareText",
let arguments = call.arguments as? [String: Any],
let text = arguments["text"] as? String,
!text.isEmpty,
let controller = self?.window?.rootViewController else {
!text.isEmpty else {
result(FlutterError(code: "share_unavailable", message: "Share sheet is unavailable", details: nil))
return
}
let activity = UIActivityViewController(activityItems: [text], applicationActivities: nil)
activity.popoverPresentationController?.sourceView = controller.view
activity.completionWithItemsHandler = { _, _, _, _ in result(nil) }
controller.present(activity, animated: true)
DispatchQueue.main.async {
guard let controller = self?.sharePresenter() else {
result(FlutterError(code: "share_unavailable", message: "Share sheet is unavailable", details: nil))
return
}
let activity = UIActivityViewController(activityItems: [text], applicationActivities: nil)
if let popover = activity.popoverPresentationController {
popover.sourceView = controller.view
popover.sourceRect = CGRect(
x: controller.view.bounds.midX,
y: controller.view.bounds.midY,
width: 0,
height: 0
)
popover.permittedArrowDirections = []
}
activity.completionWithItemsHandler = { _, _, _, _ in result(nil) }
controller.present(activity, animated: true)
}
}
let thumbnailChannel = FlutterMethodChannel(
@@ -104,7 +446,7 @@ final class RunnerFlutterViewController: FlutterViewController {
let options: [String: Any]? = headers.isEmpty
? nil
: [AVURLAssetHTTPHeaderFieldsKey: headers]
: [thumbnailHTTPHeaderFieldsKey: headers]
let asset = AVURLAsset(url: assetUrl, options: options)
let generator = AVAssetImageGenerator(asset: asset)
generator.appliesPreferredTrackTransform = true
@@ -130,4 +472,158 @@ final class RunnerFlutterViewController: FlutterViewController {
}
}
}
/// 当前前台 Scene 的根控制器之上,最适合展示系统分享面板的控制器。
private func sharePresenter() -> UIViewController? {
let keyWindow = UIApplication.shared.connectedScenes
.compactMap { $0 as? UIWindowScene }
.first { $0.activationState == .foregroundActive }?
.windows.first { $0.isKeyWindow }
guard let rootController = keyWindow?.rootViewController else { return nil }
let presenter = topPresentedController(from: rootController)
guard presenter.viewIfLoaded?.window != nil else { return nil }
return presenter
}
/// 解析已展示页面、导航栈和标签页中的当前可见控制器。
private func topPresentedController(from controller: UIViewController) -> UIViewController {
if let presented = controller.presentedViewController {
return topPresentedController(from: presented)
}
if let navigation = controller as? UINavigationController,
let visible = navigation.visibleViewController {
return topPresentedController(from: visible)
}
if let tabs = controller as? UITabBarController,
let selected = tabs.selectedViewController {
return topPresentedController(from: selected)
}
return controller
}
/// iOS 画中画:影子播放器通道,与 Android 共用同一 channel 名。
private func registerPipChannel(_ engineBridge: FlutterImplicitEngineBridge) {
let channel = FlutterMethodChannel(
name: "com.stormg.lumadrama/pip",
binaryMessenger: engineBridge.applicationRegistrar.messenger()
)
let pip = PipShadowCoordinator.shared
pip.channel = channel
channel.setMethodCallHandler { call, result in
switch call.method {
case "isAvailable":
result(PipShadowCoordinator.isSupported)
case "enter":
guard let args = call.arguments as? [String: Any],
let url = args["url"] as? String else {
result(false)
return
}
let positionMs = (args["positionMs"] as? NSNumber)?.int64Value ?? 0
pip.prepare(urlString: url, positionMs: positionMs, autoEnter: false)
// 等一拍让 AVPlayerLayer 完成挂载再请求进入画中画。
DispatchQueue.main.async {
result(pip.start())
}
case "prepareShadow":
guard let args = call.arguments as? [String: Any],
let url = args["url"] as? String else {
result(nil)
return
}
pip.prepare(
urlString: url,
positionMs: (args["positionMs"] as? NSNumber)?.int64Value ?? 0,
autoEnter: (args["autoEnter"] as? NSNumber)?.boolValue ?? false
)
result(nil)
case "armAutoEnter":
pip.armAutoEnter(
positionMs: (call.arguments as? [String: Any])?["positionMs"] as? Int64 ?? 0
)
result(nil)
case "showRestoreOverlay":
pip.showRestoreOverlay()
result(nil)
case "hideRestoreOverlay":
pip.hideRestoreOverlay()
result(nil)
case "disarmAutoEnter":
pip.disarmAutoEnter()
result(nil)
case "unmute":
pip.unmuteAndPlay()
result(nil)
case "replaceItem":
guard let args = call.arguments as? [String: Any],
let url = args["url"] as? String else {
result(nil)
return
}
pip.replaceItem(
urlString: url,
positionMs: (args["positionMs"] as? NSNumber)?.int64Value ?? 0
)
result(nil)
case "stop":
pip.stopPip()
result(nil)
case "teardown":
pip.teardown()
result(nil)
default:
result(FlutterMethodNotImplemented)
}
}
pip.onPipChanged = { active, positionMs in
channel.invokeMethod(
"onPipChanged",
arguments: ["active": active, "positionMs": positionMs]
)
}
pip.onPlaybackEnded = {
channel.invokeMethod("onPipPlaybackEnded", arguments: nil)
}
}
/// 设备标识:IDFV 免权限,卸载本 App 不变,避免客户端自生成的 id 每次重装都变。
/// 同通道顺带提供设备区域(ISO-2),注册时作为服务端 IP 解析失败后的兜底。
private func registerDeviceIdChannel(_ engineBridge: FlutterImplicitEngineBridge) {
let channel = FlutterMethodChannel(
name: "com.stormg.lumadrama/device",
binaryMessenger: engineBridge.applicationRegistrar.messenger()
)
channel.setMethodCallHandler { call, result in
switch call.method {
case "idfv":
result(UIDevice.current.identifierForVendor?.uuidString)
case "region":
if #available(iOS 16.0, *) {
result(Locale.current.region?.identifier)
} else {
result(Locale.current.regionCode)
}
default:
result(FlutterMethodNotImplemented)
}
}
}
private func registerWirelessDataChannel(_ engineBridge: FlutterImplicitEngineBridge) {
let channel = FlutterMethodChannel(
name: WirelessDataPrompt.channelName,
binaryMessenger: engineBridge.applicationRegistrar.messenger()
)
channel.setMethodCallHandler { [weak self] call, result in
guard call.method == WirelessDataPrompt.awaitDecisionMethod else {
result(FlutterMethodNotImplemented)
return
}
guard let self else {
result(nil)
return
}
self.wirelessDataPrompt.awaitDecision(result)
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 734 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 866 B

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 B

After

Width:  |  Height:  |  Size: 69 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 364 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 655 KiB

@@ -16,18 +16,13 @@
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" image="LaunchBackground" translatesAutoresizingMaskIntoConstraints="NO" id="tWc-Dq-wcI"/>
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4"></imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4"/>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" red="0" green="0" blue="0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="3T2-ad-Qdv"/>
<constraint firstItem="tWc-Dq-wcI" firstAttribute="bottom" secondItem="Ze5-6b-2t3" secondAttribute="bottom" id="RPx-PI-7Xg"/>
<constraint firstItem="tWc-Dq-wcI" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="SdS-ul-q2q"/>
<constraint firstAttribute="trailing" secondItem="tWc-Dq-wcI" secondAttribute="trailing" id="Swv-Gf-Rwn"/>
<constraint firstAttribute="trailing" secondItem="YRO-k0-Ey4" secondAttribute="trailing" id="TQA-XW-tRk"/>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="bottom" secondItem="Ze5-6b-2t3" secondAttribute="bottom" id="duK-uY-Gun"/>
<constraint firstItem="tWc-Dq-wcI" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="kV7-tw-vXt"/>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="xPn-NY-SIU"/>
</constraints>
</view>
@@ -38,7 +33,6 @@
</scene>
</scenes>
<resources>
<image name="LaunchImage" width="1152" height="1152"/>
<image name="LaunchBackground" width="1" height="1"/>
<image name="LaunchImage" width="390" height="844"/>
</resources>
</document>
+16 -10
View File
@@ -7,7 +7,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>FruitShorts</string>
<string>ymb</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
@@ -15,7 +15,7 @@
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>FruitShorts</string>
<string>ymb</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
@@ -41,14 +41,7 @@
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>192.168.31.187</key>
<key>192.168.31.243</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
@@ -62,6 +55,13 @@
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
<key>NSLocalNetworkUsageDescription</key>
@@ -89,10 +89,16 @@
</dict>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIStatusBarHidden</key>
<false/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
+6 -1
View File
@@ -1,6 +1,11 @@
// Author: fruit.com.cn
import Flutter
import UIKit
class SceneDelegate: FlutterSceneDelegate {
override func sceneDidBecomeActive(_ scene: UIScene) {
super.sceneDidBecomeActive(scene)
(UIApplication.shared.delegate as? AppDelegate)?.requestWirelessDataPrompt()
}
}
+68
View File
@@ -0,0 +1,68 @@
// Author: fruit.com.cn
import CoreTelephony
import Flutter
import Foundation
/// 监听系统无线数据选择,并用 URLSession 唤起系统选择框。
final class WirelessDataPrompt {
static let channelName = "com.stormg.lumadrama/wireless-data"
static let awaitDecisionMethod = "awaitDecision"
/// 系统选择框由 URLSession 触发,Dart 的 Socket 请求不会弹出。
private static let promptURL = URL(string: "https://captive.apple.com/hotspot-detect.html")
private let cellularData = CTCellularData()
private let lock = NSLock()
private var pending: [FlutterResult] = []
private var decided = false
private var didRequestPrompt = false
init() {
cellularData.cellularDataRestrictionDidUpdateNotifier = { [weak self] state in
DispatchQueue.main.async {
self?.completeIfDecided(state)
}
}
}
/// 应用进入前台后请求一次,促使系统弹出无线数据选择。
func requestSystemPrompt() {
guard !didRequestPrompt, let promptURL = Self.promptURL else {
return
}
didRequestPrompt = true
_ = cellularData.restrictedState
URLSession.shared.dataTask(with: promptURL) { _, _, _ in }.resume()
}
/// 未允许前先挂起;用户允许无线数据后再放行。
func awaitDecision(_ result: @escaping FlutterResult) {
lock.lock()
if decided {
lock.unlock()
DispatchQueue.main.async {
result(nil)
}
return
}
pending.append(result)
lock.unlock()
}
private func completeIfDecided(_ state: CTCellularDataRestrictedState) {
if state != .notRestricted {
return
}
lock.lock()
if decided {
lock.unlock()
return
}
decided = true
let waiters = pending
pending.removeAll()
lock.unlock()
waiters.forEach { $0(nil) }
}
}
+59 -15
View File
@@ -14,6 +14,8 @@ import 'core/data/remote/catalog_api.dart';
import 'core/data/remote/category_api.dart';
import 'core/data/remote/comment_api.dart';
import 'core/data/remote/commerce_api.dart';
import 'core/data/remote/config_api.dart';
import 'core/data/remote/device_profile.dart';
import 'core/data/remote/download_api.dart';
import 'core/data/remote/interaction_api.dart';
import 'core/data/remote/library_api.dart';
@@ -30,9 +32,11 @@ import 'core/data/repositories/favorite_repository.dart';
import 'core/data/repositories/interaction_repository.dart';
import 'core/data/repositories/notice_repository.dart';
import 'core/data/repositories/playback_repository.dart';
import 'core/data/repositories/playlist_repository.dart';
import 'core/data/repositories/search_repository.dart';
import 'core/data/repositories/store_repository.dart';
import 'core/data/repositories/watch_history_repository.dart';
import 'core/data/services/app_config_controller.dart';
import 'core/data/services/auth_controller.dart';
import 'core/data/services/auth_session_store.dart';
import 'core/data/services/catalog_controller.dart';
@@ -41,9 +45,11 @@ import 'core/data/services/download_controller.dart';
import 'core/data/services/favorite_controller.dart';
import 'core/data/services/interaction_controller.dart';
import 'core/data/services/locale_controller.dart';
import 'core/data/services/playlist_controller.dart';
import 'core/data/services/event_tracker.dart';
import 'core/data/services/playback_position_cache.dart';
import 'core/data/services/playback_session.dart';
import 'core/data/services/unlocked_episode_registry.dart';
import 'core/data/services/video_player_port.dart';
import 'core/data/services/wallet_controller.dart';
import 'core/navigation/app_route_observer.dart';
@@ -83,6 +89,7 @@ class LumaDramaApp extends StatefulWidget {
this.commerceRepository,
this.storeRepository,
this.searchRepository,
this.playlistRepository,
this.haptics = const FlutterHaptics(),
});
@@ -103,6 +110,7 @@ class LumaDramaApp extends StatefulWidget {
final CommerceRepository? commerceRepository;
final StoreRepository? storeRepository;
final SearchRepository? searchRepository;
final PlaylistRepository? playlistRepository;
final Haptics haptics;
@override
@@ -113,12 +121,13 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
late final AuthSessionStore _sessionStore = AuthSessionStore();
/// 全 App 共用一个 ApiClient:这样目录、账号、后续的互动/进度请求
/// 都自动带 `Authorization` 与 `X-Device-Id`,401 的刷新重试也只有一处实现。
/// 都自动带 `Authorization`、`X-Device-Id` 与平台头,401 的刷新重试也只有一处实现。
late final ApiClient _apiClient = ApiClient(
accessTokenReader: () => _auth.accessToken,
tokenRefresher: () => _auth.refresh(),
onUnauthorized: () => _auth.clear(),
deviceIdReader: _sessionStore.deviceId,
platformReader: clientPlatform,
);
late final AuthController _auth = AuthController(
@@ -126,8 +135,10 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
_sessionStore,
);
late final CatalogApi _catalogApi = CatalogApi(_apiClient);
late final CatalogRepository _catalogRepository =
widget.catalogRepository ?? HttpCatalogRepository(CatalogApi(_apiClient));
widget.catalogRepository ?? HttpCatalogRepository(_catalogApi);
late final CategoryRepository _categoryRepository =
widget.categoryRepository ??
@@ -135,17 +146,11 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
late final WatchHistoryRepository _watchHistory =
widget.watchHistoryRepository ??
HttpWatchHistoryRepository(
WatchApi(_apiClient),
isSignedIn: () => _auth.isSignedIn,
);
HttpWatchHistoryRepository(WatchApi(_apiClient));
late final FavoriteRepository _favorites =
widget.favoriteRepository ??
HttpFavoriteRepository(
LibraryApi(_apiClient),
isSignedIn: () => _auth.isSignedIn,
);
HttpFavoriteRepository(LibraryApi(_apiClient));
late final PlaybackRepository _playback =
widget.playbackRepository ??
@@ -177,6 +182,13 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
late final SearchRepository _searchRepository =
widget.searchRepository ?? HttpSearchRepository(CatalogApi(_apiClient));
/// 测试注入了目录仓库时不打剧单接口,剧单页继续用本地分区。
late final PlaylistRepository? _playlistRepository =
widget.playlistRepository ??
(widget.catalogRepository == null
? HttpPlaylistRepository(CatalogApi(_apiClient))
: null);
late final StoreRepository _storeRepository =
widget.storeRepository ?? HttpStoreRepository(CommerceApi(_apiClient));
@@ -198,15 +210,25 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
late final LocaleController _localeController = LocaleController();
/// 后台下发的启动配置(登录页背景等);拉不到就用本地默认。
late final AppConfigController _appConfigController = AppConfigController(
ConfigApi(_apiClient),
);
/// 登录期内共享的「已解锁收费集」:播放页进出、feed 与全屏切换都要沿用。
late final UnlockedEpisodeRegistry _unlockedEpisodes =
UnlockedEpisodeRegistry();
@override
void initState() {
super.initState();
// 恢复本地令牌与设备号;未登录也能正常浏览,不阻塞首屏
_auth.load();
unawaited(_localeController.load());
unawaited(_appConfigController.load());
// 登录/登出时同步收藏状态:收藏属于账号,不能跨账号串联
_auth.addListener(_onAuthChanged);
if (_auth.isSignedIn) unawaited(_favoriteController.load());
unawaited(_favoriteController.load());
if (_auth.isSignedIn) unawaited(_walletController.load());
unawaited(_downloadController.restore());
}
@@ -217,11 +239,14 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
if (_auth.isSignedIn == _wasSignedIn) return;
_wasSignedIn = _auth.isSignedIn;
_interactionController.clear();
// 解锁结论属于账号:换人登录后不能沿用上一个人的可播判断。
_unlockedEpisodes.clear();
if (_auth.isSignedIn) {
unawaited(_favoriteController.load());
unawaited(_walletController.load());
} else {
_favoriteController.clear();
unawaited(_favoriteController.load());
_downloadController.reset();
_walletController.reset();
}
@@ -235,20 +260,34 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
_walletController.dispose();
_interactionController.dispose();
_localeController.dispose();
_appConfigController.dispose();
_apiClient.close();
super.dispose();
}
CategoryController _createCategories() {
final controller = CategoryController(_categoryRepository);
if (widget.catalogRepository == null) {
controller.dramaPageLoader = CategoryApi(_apiClient).dramas;
}
controller.load();
return controller;
}
@override
Widget build(BuildContext context) {
final playlists = _playlistRepository;
return MultiProvider(
providers: [
Provider(create: (_) => PlaybackCoordinator()),
Provider<EventTracker>(create: (_) => EventTracker(_apiClient)),
Provider<PlayerFactory>(create: (_) => widget.playerFactory),
Provider<CatalogRepository>.value(value: _catalogRepository),
if (widget.catalogRepository == null)
Provider<CatalogApi>.value(value: _catalogApi),
Provider<PlaybackRepository>.value(value: _playback),
Provider<PlaybackPositionCache>.value(value: _playbackPositionCache),
Provider<UnlockedEpisodeRegistry>.value(value: _unlockedEpisodes),
Provider<WatchHistoryRepository>.value(value: _watchHistory),
Provider<FavoriteRepository>.value(value: _favorites),
Provider<CommentRepository>.value(value: _commentRepository),
@@ -260,16 +299,21 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
Provider<SearchRepository>.value(value: _searchRepository),
Provider<Haptics>.value(value: widget.haptics),
ChangeNotifierProvider(
create: (_) => CatalogController(_catalogRepository)..load(),
),
ChangeNotifierProvider(
create: (_) => CategoryController(_categoryRepository)..load(),
create: (_) {
final catalog = CatalogController(_catalogRepository);
if (widget.catalogRepository != null) catalog.load();
return catalog;
},
),
ChangeNotifierProvider(create: (_) => _createCategories()),
if (playlists != null)
ChangeNotifierProvider(create: (_) => PlaylistController(playlists)),
ChangeNotifierProvider.value(value: _favoriteController),
ChangeNotifierProvider.value(value: _downloadController),
ChangeNotifierProvider.value(value: _walletController),
ChangeNotifierProvider.value(value: _interactionController),
ChangeNotifierProvider.value(value: _localeController),
ChangeNotifierProvider.value(value: _appConfigController),
ChangeNotifierProvider.value(value: _auth),
],
child: Consumer<LocaleController>(
+24 -145
View File
@@ -1,165 +1,51 @@
// Author: fruit.com.cn
import 'dart:io';
import 'package:flutter/foundation.dart';
/// 客户端与后端约定的运行时配置。
import 'dev_config.dart';
import 'prod_config.dart';
/// 客户端运行时配置。
///
/// 接口地址优先级:运行时设置 > `--dart-define=API_BASE_URL=...` > 平台默认值。
/// 开发机的局域网地址会随网络变化,换网络后改 [devHostBaseUrl] 即可。
class AppConfig {
const AppConfig._();
/// 两套环境各一个文件:
/// - `dev_config.dart`:[DevConfig](本机联调)
/// - `prod_config.dart`:[ProdConfig](生产)
///
/// Debug 使用开发环境,Release 自动使用生产环境,不做网络探测。
abstract final class AppConfig {
/// **环境开关**:Debug 使用开发环境,Release 使用生产环境。
static const bool useDevConfig = !kReleaseMode;
/// 开发调试默认服务地址,当前指向本机局域网 IP。
///
/// 换网络时只改这一行,地址不要带结尾斜杠。
static const String devHostBaseUrl = 'http://192.168.31.187:8081';
/// 本机后端地址:通过 `adb reverse tcp:8081 tcp:8081` 映射到开发机,
/// 探测可达时 App 直连本机服务;不可达时回落到公网地址。
static const String lanBaseUrl = 'http://127.0.0.1:8081';
/// 公网地址(远程/移动网络访问时使用)。
static const String publicBaseUrl = 'http://39.162.50.99:8081';
static const String _overrideBaseUrl = String.fromEnvironment('API_BASE_URL');
/// 当前选中的环境地址。
static String get baseUrl =>
useDevConfig ? DevConfig.baseUrl : ProdConfig.baseUrl;
/// 调试面板手改的地址(见 `ServerEndpoint`);为空表示用上面的环境地址。
static String _runtimeBaseUrl = '';
/// 启动期异步准备(iOS 无线数据权限弹窗),目录请求前等待它。
static Future<void>? _ready;
/// 启动地址探测完成信号;默认已完成,避免影响既有测试与调用方。
/// 启动准备完成信号;默认已完成,避免影响既有测试与调用方。
static Future<void> get ready => _ready ?? Future<void>.value();
static set ready(Future<void> value) => _ready = value;
static const Duration _probeTimeout = Duration(seconds: 2);
static const List<String> _probeCandidates = [
lanBaseUrl,
devHostBaseUrl,
if (devHostBaseUrl != publicBaseUrl) publicBaseUrl,
];
static const Duration requestTimeout = Duration(seconds: 8);
/// Build-time server URL supplied through `--dart-define=API_BASE_URL`.
static String get compiledBaseUrl => _overrideBaseUrl;
/// 实际使用的服务地址:运行时手改优先,否则用环境开关选中的地址。
static String get apiBaseUrl =>
_runtimeBaseUrl.isNotEmpty ? _runtimeBaseUrl : baseUrl;
/// Existing platform-aware fallback used when no runtime or build override exists.
static String get defaultBaseUrl => _defaultBaseUrl;
/// Effective server URL, including the debug-only runtime override.
static String get apiBaseUrl => _runtimeBaseUrl.isNotEmpty
? _runtimeBaseUrl
: (compiledBaseUrl.isNotEmpty ? compiledBaseUrl : defaultBaseUrl);
static final String _defaultBaseUrl = _runsOnDevMachine
? lanBaseUrl
: devHostBaseUrl;
/// 模拟器、桌面端与开发机同机,环回地址可用;iOS 真机不满足。
/// Android 没有等价的探测方式,统一按真机处理(模拟器用
/// `--dart-define=API_BASE_URL=http://10.0.2.2:8081` 覆盖)。
static final bool _runsOnDevMachine =
kIsWeb ||
defaultTargetPlatform == TargetPlatform.macOS ||
defaultTargetPlatform == TargetPlatform.windows ||
defaultTargetPlatform == TargetPlatform.linux ||
(defaultTargetPlatform == TargetPlatform.iOS &&
Platform.environment.containsKey('SIMULATOR_DEVICE_NAME'));
/// Applies an already normalized runtime URL. Passing null clears it.
/// 应用一个已经规范化的运行时地址;传 null 表示清除。
static void applyRuntimeBaseUrl(String? value) {
_runtimeBaseUrl = value ?? '';
}
/// Clears the in-memory runtime override, mainly for tests and restarts.
/// 清除运行时地址,主要给测试与重启流程用。
static void clearRuntimeBaseUrl() {
_runtimeBaseUrl = '';
}
static const Duration requestTimeout = Duration(seconds: 8);
/// 按环回、开发机、公网顺序探测,写入首个返回 200 的地址。
///
/// 全部不可达时使用平台默认地址,真机保留开发机地址,避免退回公网。
static Future<void> probeAndApplyBaseUrl({
Future<bool> Function(String baseUrl)? probe,
String? fallbackBaseUrl,
/// 编译期地址测试注入;未传时读取 `API_BASE_URL`。
String? compiledOverride,
}) async {
final compiled = compiledOverride ?? compiledBaseUrl;
if (compiled.isNotEmpty) {
if (_runtimeBaseUrl.isEmpty) applyRuntimeBaseUrl(compiled);
return;
}
final candidates = <String>[
if (_runtimeBaseUrl.isNotEmpty) _runtimeBaseUrl,
for (final candidate in _probeCandidates)
if (candidate != _runtimeBaseUrl) candidate,
];
final results = await Future.wait([
for (final candidate in candidates)
probe == null
? _probeBaseUrl(candidate)
: _runInjectedProbe(candidate, probe),
]);
for (var index = 0; index < candidates.length; index++) {
final candidate = candidates[index];
final result = results[index];
if (kDebugMode) {
final status = result.ok
? 'ok'
: 'fail(${result.reason ?? 'request failed'})';
debugPrint('[probe] $candidate -> $status');
}
if (result.ok) {
applyRuntimeBaseUrl(candidate);
return;
}
}
applyRuntimeBaseUrl(fallbackBaseUrl ?? defaultBaseUrl);
}
static Future<_ProbeResult> _runInjectedProbe(
String baseUrl,
Future<bool> Function(String baseUrl) probe,
) async {
try {
return _ProbeResult(ok: await probe(baseUrl));
} catch (error) {
return _ProbeResult(ok: false, reason: error.toString());
}
}
static Future<_ProbeResult> _probeBaseUrl(String baseUrl) async {
final client = HttpClient()..connectionTimeout = _probeTimeout;
try {
return await _requestCategories(
client,
Uri.parse('$baseUrl/app/categories'),
).timeout(_probeTimeout);
} catch (error) {
return _ProbeResult(ok: false, reason: error.toString());
} finally {
client.close(force: true);
}
}
static Future<_ProbeResult> _requestCategories(
HttpClient client,
Uri uri,
) async {
final request = await client.getUrl(uri);
final response = await request.close();
await response.drain<void>();
final ok = response.statusCode == 200;
return _ProbeResult(
ok: ok,
reason: ok ? null : 'HTTP ${response.statusCode}',
);
}
/// 后端返回的是相对路径(/files/...),这里补上服务地址。
static String mediaUrl(String path) {
if (path.isEmpty) return '';
@@ -167,10 +53,3 @@ class AppConfig {
return '$apiBaseUrl$path';
}
}
class _ProbeResult {
const _ProbeResult({required this.ok, this.reason});
final bool ok;
final String? reason;
}
+10
View File
@@ -0,0 +1,10 @@
// Author: fruit.com.cn
/// 开发环境配置。
///
/// 本机联调用:模拟器与桌面端可直接用回环地址,但 iOS/Android 真机必须用
/// 开发机的局域网 IP(真机上的 127.0.0.1 指向手机自己)。地址不要带结尾斜杠。
abstract final class DevConfig {
/// 开发机后端地址(Mac 当前 Wi-Fi 地址,换网络后需要同步修改)。
static const String baseUrl = 'http://192.168.31.243:8081';
}
+9
View File
@@ -0,0 +1,9 @@
// Author: fruit.com.cn
/// 生产环境配置。
///
/// 发版前确认这里的 [baseUrl],地址不要带结尾斜杠。
abstract final class ProdConfig {
/// 生产后端地址。
static const String baseUrl = 'http://39.162.50.99:8081';
}
+4 -15
View File
@@ -22,16 +22,9 @@ abstract final class ServerEndpoint {
return value.replaceFirst(RegExp(r'/+$'), '');
}
/// Resolves runtime > dart-define > default using normalized valid values.
static String resolve({
required String? stored,
required String compiled,
required String fallback,
}) {
return normalize(stored) ??
normalize(compiled) ??
normalize(fallback) ??
fallback;
/// 运行时手改优先,其次构建期默认地址;两者都必须先通过规范校验。
static String resolve({required String? stored, required String fallback}) {
return normalize(stored) ?? normalize(fallback) ?? fallback;
}
/// Loads the persisted override before the app creates its ApiClient.
@@ -46,11 +39,7 @@ abstract final class ServerEndpoint {
final prefs = preferences ?? SharedPreferencesAsync();
final stored = await prefs.getString(preferenceKey);
AppConfig.applyRuntimeBaseUrl(
resolve(
stored: stored,
compiled: AppConfig.compiledBaseUrl,
fallback: AppConfig.defaultBaseUrl,
),
resolve(stored: stored, fallback: AppConfig.baseUrl),
);
} catch (_) {
AppConfig.clearRuntimeBaseUrl();
+18 -5
View File
@@ -1,17 +1,30 @@
// Author: fruit.com.cn
import 'locale_text.dart';
/// 服务端内容分类。id 按契约保持字符串,避免雪花 ID 精度丢失。
class ContentCategory {
const ContentCategory({required this.id, required this.name});
const ContentCategory({
required this.id,
required this.name,
this.locales = const {},
});
final String id;
/// 中文名称,与 locales 里的 zh 相同。
final String name;
final Map<String, String> locales;
/// 解析 `GET /app/categories` 的单项。
factory ContentCategory.fromJson(Map<String, dynamic> json) {
return ContentCategory(
id: (json['id'] ?? '').toString(),
name: json['name'] as String? ?? '',
);
final locales = localeMap(json['locales']);
final name = json['name'] as String? ?? locales['zh'] ?? '';
return ContentCategory(id: (json['id'] ?? '').toString(), name: name, locales: locales);
}
/// 按界面语言取名称。缺对应语言时回落到中文。
String localizedName(String languageCode) {
return localizedText(languageCode, name, locales);
}
}
+190 -9
View File
@@ -1,6 +1,9 @@
// Author: fruit.com.cn
import 'dart:ui';
import 'json_numbers.dart';
import 'locale_text.dart';
/// 短剧与剧集,字段与后端 `/app/**` 的下发结构对应。
///
@@ -18,6 +21,7 @@ class Episode {
this.likeCount,
this.commentCount,
this.thumbnailsUrl,
this.posterUrl,
});
final String id;
@@ -34,12 +38,14 @@ class Episode {
final int? likeCount;
final int? commentCount;
final String? thumbnailsUrl;
final String? posterUrl;
Episode withVideoUrl(
String url, {
int? likeCount,
int? commentCount,
String? thumbnailsUrl,
String? posterUrl,
}) => Episode(
id: id,
number: number,
@@ -51,6 +57,21 @@ class Episode {
likeCount: likeCount ?? this.likeCount,
commentCount: commentCount ?? this.commentCount,
thumbnailsUrl: thumbnailsUrl ?? this.thumbnailsUrl,
posterUrl: posterUrl ?? this.posterUrl,
);
Episode withStats({int? likeCount, int? commentCount}) => Episode(
id: id,
number: number,
title: title,
isFree: isFree,
videoUrl: videoUrl,
durationSec: durationSec,
locked: locked,
likeCount: likeCount ?? this.likeCount,
commentCount: commentCount ?? this.commentCount,
thumbnailsUrl: thumbnailsUrl,
posterUrl: posterUrl,
);
factory Episode.fromJson(Map<String, dynamic> json) {
@@ -65,6 +86,7 @@ class Episode {
likeCount: _optionalInt(json['likeCount']),
commentCount: _optionalInt(json['commentCount']),
thumbnailsUrl: _optionalString(json['thumbnailsUrl']),
posterUrl: _optionalString(json['posterUrl']),
);
}
}
@@ -75,8 +97,17 @@ class Drama {
required this.title,
required this.synopsis,
required this.posterUrl,
this.coverLandscape = '',
this.episodes = const [],
this.titleLocales = const {},
this.synopsisLocales = const {},
this.tag = '',
this.tagLocales = const {},
this.tagCode = '',
this.tagColor = '',
this.category = '',
this.categoryLocales = const {},
this.types = const [],
this.genre = '',
this.totalEpisodes = 0,
this.freeEpisodes = 0,
@@ -94,9 +125,22 @@ class Drama {
final String id;
final String title;
final String synopsis;
final Map<String, String> titleLocales;
final Map<String, String> synopsisLocales;
final String tag;
final Map<String, String> tagLocales;
/// 标签语义码(如 `NEW_ARRIVAL`)。文案会随语言变,语义判断只认这个码。
final String tagCode;
final String tagColor;
final String posterUrl;
/// 横版封面,用于继续观看横幅等横向展示位;为空时回退竖版 `posterUrl`。
final String coverLandscape;
final List<Episode> episodes;
final String category;
final Map<String, String> categoryLocales;
final List<Map<String, String>> types;
final String genre;
final int totalEpisodes;
final int freeEpisodes;
@@ -127,19 +171,28 @@ class Drama {
/// 列表卡片:带一集可播预览(首页直接起播),完整剧集进详情再取。
factory Drama.fromCardJson(Map<String, dynamic> json) {
final preview = json['preview'];
final text = _DramaText.fromJson(json);
return Drama(
id: (json['id'] ?? '').toString(),
title: json['title'] as String? ?? '',
synopsis: json['synopsis'] as String? ?? '',
title: text.title,
synopsis: text.synopsis,
titleLocales: text.titleLocales,
synopsisLocales: text.synopsisLocales,
tag: text.tag,
tagLocales: text.tagLocales,
tagCode: (json['tagCode'] as String? ?? '').trim(),
tagColor: json['tagColor'] as String? ?? '',
posterUrl: json['cover'] as String? ?? '',
coverLandscape: json['coverLandscape'] as String? ?? '',
episodes: preview is Map<String, dynamic>
? [Episode.fromJson(preview)]
: const [],
category: json['category'] as String? ?? '',
genre: json['genre'] as String? ?? '',
category: text.category,
categoryLocales: text.categoryLocales,
types: text.types,
genre: text.genre,
totalEpisodes: (json['totalEpisodes'] as num?)?.toInt() ?? 0,
isHot: json['isHot'] == true,
// viewCount 后端是 Long,按字符串下发(见 json_numbers.dart)
viewCount: jsonToInt(json['viewCount']),
likeCount: _optionalInt(json['likeCount']),
favoriteCount: _optionalInt(json['favoriteCount']),
@@ -152,13 +205,23 @@ class Drama {
/// 详情:带剧集列表。
factory Drama.fromDetailJson(Map<String, dynamic> json) {
final text = _DramaText.fromJson(json);
return Drama(
id: (json['id'] ?? '').toString(),
title: json['title'] as String? ?? '',
synopsis: json['synopsis'] as String? ?? '',
title: text.title,
synopsis: text.synopsis,
titleLocales: text.titleLocales,
synopsisLocales: text.synopsisLocales,
tag: text.tag,
tagLocales: text.tagLocales,
tagCode: (json['tagCode'] as String? ?? '').trim(),
tagColor: json['tagColor'] as String? ?? '',
posterUrl: json['cover'] as String? ?? '',
category: json['category'] as String? ?? '',
genre: json['genre'] as String? ?? '',
coverLandscape: json['coverLandscape'] as String? ?? '',
category: text.category,
categoryLocales: text.categoryLocales,
types: text.types,
genre: text.genre,
totalEpisodes: (json['totalEpisodes'] as num?)?.toInt() ?? 0,
freeEpisodes: (json['freeEpisodes'] as num?)?.toInt() ?? 0,
isHot: json['isHot'] == true,
@@ -176,6 +239,37 @@ class Drama {
.toList(),
);
}
String localizedTitle(String languageCode) {
return localizedText(languageCode, title, titleLocales);
}
String localizedSynopsis(String languageCode) {
return localizedText(languageCode, synopsis, synopsisLocales);
}
String localizedTag(String languageCode) {
return localizedText(languageCode, tag, tagLocales);
}
/// 标签角标背景色。接口没给合法色值时用 fallback。
Color tagRibbonColor(Color fallback) {
final parsed = _colorFromHex(tagColor);
return parsed ?? fallback;
}
/// 按当前语言取类型名称。接口没带语言表时返回空,调用方继续用中文 genre。
List<String> localizedTypeLabels(String languageCode) {
final labels = <String>[];
for (final item in types) {
final label = localizedText(languageCode, item['zh'] ?? '', item);
if (label.isNotEmpty && !labels.contains(label)) labels.add(label);
}
if (labels.isNotEmpty) return labels;
final primary = localizedText(languageCode, '', categoryLocales);
if (primary.isNotEmpty) return [primary];
return const [];
}
}
int? _optionalInt(dynamic value) => value == null ? null : jsonToInt(value);
@@ -184,3 +278,90 @@ String? _optionalString(dynamic value) {
final text = value is String ? value.trim() : '';
return text.isEmpty ? null : text;
}
Color? _colorFromHex(String raw) {
final text = raw.trim();
if (text.length != 7 || !text.startsWith('#')) return null;
final value = int.tryParse(text.substring(1), radix: 16);
if (value == null) return null;
return Color(0xFF000000 | value);
}
List<Map<String, String>> _typeLocales(Object? raw) {
if (raw is! List) return const [];
return raw.whereType<Map>().map(localeMap).toList(growable: false);
}
/// 从语言表还原中文展示字段。列表接口不再单独下发 title / synopsis / tag。
class _DramaText {
const _DramaText({
required this.title,
required this.synopsis,
required this.titleLocales,
required this.synopsisLocales,
required this.tag,
required this.tagLocales,
required this.category,
required this.categoryLocales,
required this.types,
required this.genre,
});
final String title;
final String synopsis;
final Map<String, String> titleLocales;
final Map<String, String> synopsisLocales;
final String tag;
final Map<String, String> tagLocales;
final String category;
final Map<String, String> categoryLocales;
final List<Map<String, String>> types;
final String genre;
factory _DramaText.fromJson(Map<String, dynamic> json) {
final titleLocales = localeMap(json['titleLocales']);
final synopsisLocales = localeMap(json['synopsisLocales']);
final tagLocales = localeMap(json['tagLocales']);
final categoryLocales = localeMap(json['categoryLocales']);
final types = _typeLocales(json['types']);
final category = _firstText(categoryLocales, json['category'], types);
return _DramaText(
title: _firstText(titleLocales, json['title']),
synopsis: _firstText(
synopsisLocales,
json['synopsis'] ?? json['description'],
),
titleLocales: titleLocales,
synopsisLocales: synopsisLocales,
tag: _firstText(tagLocales, json['tag']),
tagLocales: tagLocales,
category: category,
categoryLocales: categoryLocales,
types: types,
genre: _genreText(types, json['genre']),
);
}
}
String _firstText(
Map<String, String> locales,
Object? fallback, [
List<Map<String, String>>? types,
]) {
final chinese = locales['zh'] ?? '';
if (chinese.isNotEmpty) return chinese;
if (types != null && types.isNotEmpty) {
final label = types.first['zh'] ?? '';
if (label.isNotEmpty) return label;
}
return fallback is String ? fallback : '';
}
String _genreText(List<Map<String, String>> types, Object? fallback) {
final names = types
.map((item) => item['zh'] ?? '')
.where((value) => value.isNotEmpty);
final joined = names.join(' / ');
if (joined.isNotEmpty) return joined;
return fallback is String ? fallback : '';
}
Loaded 100 of 420 files, more files were not shown because too many files have changed in this diff. Show more