chore(client): 归档原型阶段新增文件(配置、主题、模型与测试)
为什么:上一批归档只覆盖了「已跟踪文件的修改」,原型阶段新增的文件(app_config、theme、 home_feed/play_ticket 模型、catalog_api、测试目录等)还是未入库状态 —— 而已入库的代码会 import 它们, 留在工作区会导致 HEAD 处的代码编译不过。一并归档,让 HEAD 自洽。 纯归档,无行为改动。
This commit is contained in:
1 parent
e1b98df509
commit
feecc349a0
19 files changed
+2210
No files matched your search
@@ -0,0 +1,81 @@
|
||||
import 'package:nontonki/core/data/models/drama.dart';
|
||||
import 'package:nontonki/core/data/models/home_feed.dart';
|
||||
import 'package:nontonki/core/data/models/play_ticket.dart';
|
||||
import 'package:nontonki/core/data/repositories/catalog_repository.dart';
|
||||
|
||||
/// 测试用目录数据:三部分区里的短剧,标题与后端演示数据保持一致。
|
||||
class FakeCatalogRepository implements CatalogRepository {
|
||||
FakeCatalogRepository({List<Drama>? dramas}) : dramas = dramas ?? demoDramas;
|
||||
|
||||
final List<Drama> dramas;
|
||||
|
||||
@override
|
||||
Future<HomeFeed> fetchHomeFeed() async => _feed();
|
||||
|
||||
@override
|
||||
Future<HomeFeed> fetchDiscoverFeed() async => _feed();
|
||||
|
||||
@override
|
||||
Future<Drama> fetchDrama(String dramaId) async {
|
||||
return dramas.firstWhere((drama) => drama.id == dramaId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PlayTicket> resolvePlay(String episodeId) async {
|
||||
return PlayTicket(
|
||||
episodeId: episodeId,
|
||||
accessible: true,
|
||||
accessType: PlayTicket.free,
|
||||
playUrl: 'https://example.test/$episodeId.mp4',
|
||||
);
|
||||
}
|
||||
|
||||
HomeFeed _feed() => HomeFeed(
|
||||
sections: [FeedSection(code: 'hot', title: '热门推荐', dramas: dramas)],
|
||||
);
|
||||
}
|
||||
|
||||
final List<Drama> demoDramas = [
|
||||
_drama(
|
||||
'the-signal-demo',
|
||||
'The Signal',
|
||||
'Suspense · Mystery',
|
||||
format: 1,
|
||||
),
|
||||
_drama(
|
||||
'city-lights-demo',
|
||||
'City Lights & Velvet Nights',
|
||||
'Urban Romance',
|
||||
format: 8,
|
||||
),
|
||||
_drama(
|
||||
'vengeance-demo',
|
||||
'Vengeance Rising',
|
||||
'Action · Thriller',
|
||||
format: 15,
|
||||
),
|
||||
];
|
||||
|
||||
Drama _drama(
|
||||
String id,
|
||||
String title,
|
||||
String genre, {
|
||||
required int format,
|
||||
}) => Drama(
|
||||
id: id,
|
||||
title: title,
|
||||
synopsis: '$title synopsis',
|
||||
posterUrl: '/files/$id.png',
|
||||
genre: genre,
|
||||
detailLoaded: true,
|
||||
episodes: [
|
||||
for (var index = 0; index < 7; index++)
|
||||
Episode(
|
||||
id: '$id-${index + 1}',
|
||||
number: index + 1,
|
||||
title: 'Episode ${index + 1}',
|
||||
isFree: true,
|
||||
videoUrl: 'https://example.test/$format-$index.mp4',
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -0,0 +1,44 @@
|
||||
import 'package:nontonki/core/data/repositories/watch_history_repository.dart';
|
||||
|
||||
/// Records every history interaction so tests can assert on the key it used.
|
||||
class FakeWatchHistory implements WatchHistoryRepository {
|
||||
final List<String> reads = [];
|
||||
final List<String> writes = [];
|
||||
|
||||
/// Position returned by [positionFor] when [failReads] is false.
|
||||
Duration? saved;
|
||||
|
||||
/// Last episode returned by [lastEpisodeId].
|
||||
String? lastEpisode;
|
||||
|
||||
bool failReads = false;
|
||||
bool failWrites = false;
|
||||
|
||||
@override
|
||||
Future<Duration?> positionFor(
|
||||
String profileId,
|
||||
String dramaId,
|
||||
String episodeId,
|
||||
) async {
|
||||
reads.add('$profileId|$dramaId|$episodeId');
|
||||
if (failReads) throw StateError('history unavailable');
|
||||
return saved;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> lastEpisodeId(String profileId, String dramaId) async {
|
||||
if (failReads) throw StateError('history unavailable');
|
||||
return lastEpisode;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> save(
|
||||
String profileId,
|
||||
String dramaId,
|
||||
String episodeId,
|
||||
Duration position,
|
||||
) async {
|
||||
if (failWrites) throw StateError('history unavailable');
|
||||
writes.add('$profileId|$dramaId|$episodeId|${position.inMilliseconds}');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user