From 587932134bdd2034f565988cda52649164996982 Mon Sep 17 00:00:00 2001 From: d1y Date: Fri, 23 Jun 2023 12:31:31 +0800 Subject: [PATCH] refactor: SpiderImpl -> ISpider --- lib/app/modules/home/controllers/home_controller.dart | 6 +++--- lib/app/modules/home/views/home_view.dart | 2 +- lib/app/modules/home/views/mirror_check.dart | 4 ++-- lib/app/modules/home/views/mirrortable.dart | 8 ++++---- lib/app/modules/play/controllers/play_controller.dart | 2 +- lib/app/shared/mirror_status_stack.dart | 2 +- lib/spider/abstract/spider_movie.dart | 2 +- lib/spider/impl/mac_cms.dart | 2 +- lib/spider/shared/manage.dart | 10 +++++----- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/app/modules/home/controllers/home_controller.dart b/lib/app/modules/home/controllers/home_controller.dart index 8f7cf34..900c0ef 100644 --- a/lib/app/modules/home/controllers/home_controller.dart +++ b/lib/app/modules/home/controllers/home_controller.dart @@ -179,7 +179,7 @@ class HomeController extends GetxController with WidgetsBindingObserver { /// 如果是在源之前的, 则 [index] = [mirrorIndex] - 1 /// /// 如果是在源之后, 则 [index] = [mirrorIndex] - removeMirrorItemSync(SpiderImpl item) { + removeMirrorItemSync(ISpider item) { var _index = mirrorList.indexOf(item); if (_index == -1) return; var _oldIndex = mirrorIndex; @@ -196,7 +196,7 @@ class HomeController extends GetxController with WidgetsBindingObserver { _mirrorIndex = index; } - SpiderImpl get currentMirrorItem { + ISpider get currentMirrorItem { return mirrorList[mirrorIndex]; } @@ -204,7 +204,7 @@ class HomeController extends GetxController with WidgetsBindingObserver { return mirrorList.isEmpty; } - List get mirrorList { + List get mirrorList { if (isNsfw) return SpiderManage.data; return SpiderManage.data.where((e) => !e.isNsfw).toList(); } diff --git a/lib/app/modules/home/views/home_view.dart b/lib/app/modules/home/views/home_view.dart index f891201..d672c01 100644 --- a/lib/app/modules/home/views/home_view.dart +++ b/lib/app/modules/home/views/home_view.dart @@ -51,7 +51,7 @@ class HomeView extends GetView { ? const Color.fromRGBO(0, 0, 0, .63) : const Color.fromRGBO(255, 255, 255, .63); - List get mirror => home.mirrorList; + List get mirror => home.mirrorList; int get mirrorIndex => home.mirrorIndex; diff --git a/lib/app/modules/home/views/mirror_check.dart b/lib/app/modules/home/views/mirror_check.dart index cb18bb4..4ec37f8 100644 --- a/lib/app/modules/home/views/mirror_check.dart +++ b/lib/app/modules/home/views/mirror_check.dart @@ -32,7 +32,7 @@ class MirrorCheckView extends StatefulWidget { required this.list, }) : super(key: key); - final List list; + final List list; @override State createState() => _MirrorCheckViewState(); @@ -53,7 +53,7 @@ class _MirrorCheckViewState extends State { bool running = false; - List get listStack => widget.list; + List get listStack => widget.list; int get listStackLen => listStack.length; diff --git a/lib/app/modules/home/views/mirrortable.dart b/lib/app/modules/home/views/mirrortable.dart index cad18b7..5edde03 100644 --- a/lib/app/modules/home/views/mirrortable.dart +++ b/lib/app/modules/home/views/mirrortable.dart @@ -50,11 +50,11 @@ class MirrorTableView extends StatefulWidget { class _MirrorTableViewState extends State { final HomeController home = Get.find(); - List get _mirrorList { + List get _mirrorList { return home.mirrorList; } - List mirrorList = []; + List mirrorList = []; ScrollController scrollController = ScrollController( initialScrollOffset: 0, @@ -338,7 +338,7 @@ class MirrorCard extends StatelessWidget { final double maxHeight; - final SpiderImpl item; + final ISpider item; final bool current; @@ -359,7 +359,7 @@ class MirrorCard extends StatelessWidget { return !current && !isBuiltin; } - /// 如果是 [SpiderImpl.isNsfw] => [Colors.red] + /// 如果是 [ISpider.isNsfw] => [Colors.red] /// 如果是 [current] => [Colors.blue] (优先级高一点) Color get _color { if (current) return Colors.blue; diff --git a/lib/app/modules/play/controllers/play_controller.dart b/lib/app/modules/play/controllers/play_controller.dart index 3171116..127aba7 100644 --- a/lib/app/modules/play/controllers/play_controller.dart +++ b/lib/app/modules/play/controllers/play_controller.dart @@ -98,7 +98,7 @@ class PlayController extends GetxController { HomeController home = Get.find(); - SpiderImpl get currentMovieInstance { + ISpider get currentMovieInstance { var itemAs = home.currentMirrorItem; return itemAs; } diff --git a/lib/app/shared/mirror_status_stack.dart b/lib/app/shared/mirror_status_stack.dart index 93359a1..f3b5056 100644 --- a/lib/app/shared/mirror_status_stack.dart +++ b/lib/app/shared/mirror_status_stack.dart @@ -12,7 +12,7 @@ class MirrorStatusStack { Map get getStacks => _stacks; - final List _datas = SpiderManage.extend; + final List _datas = SpiderManage.extend; bool? getStack(String stack) { return _stacks[stack]; diff --git a/lib/spider/abstract/spider_movie.dart b/lib/spider/abstract/spider_movie.dart index 669077e..455c531 100644 --- a/lib/spider/abstract/spider_movie.dart +++ b/lib/spider/abstract/spider_movie.dart @@ -49,7 +49,7 @@ class SpiderQueryCategory { } } -abstract class SpiderImpl { +abstract class ISpider { /// 是否为R18资源 /// **Not Safe For Work** bool get isNsfw; diff --git a/lib/spider/impl/mac_cms.dart b/lib/spider/impl/mac_cms.dart index 154f54e..216bbd5 100644 --- a/lib/spider/impl/mac_cms.dart +++ b/lib/spider/impl/mac_cms.dart @@ -25,7 +25,7 @@ enum ResponseCustomType { unknow } -class MacCMSSpider extends SpiderImpl { +class MacCMSSpider extends ISpider { final bool nsfw; final String jiexiUrl; final String name; diff --git a/lib/spider/shared/manage.dart b/lib/spider/shared/manage.dart index 4e22e7e..15de076 100644 --- a/lib/spider/shared/manage.dart +++ b/lib/spider/shared/manage.dart @@ -17,14 +17,14 @@ class SpiderManage { SpiderManage._internal(); /// 扩展的源 - static List extend = []; + static List extend = []; /// 内建支持的源 /// 一般是需要自己去实现的源 - static List builtin = []; + static List builtin = []; /// 合并之后的数据 - static List get data { + static List get data { return [...extend, ...builtin]; } @@ -47,7 +47,7 @@ class SpiderManage { } /// 删除单个源 - static removeItem(SpiderImpl item) { + static removeItem(ISpider item) { debugPrint("删除该源: $item"); extend.remove(item); saveToCache(extend); @@ -141,7 +141,7 @@ class SpiderManage { /// 保存缓存 /// [该方法只可用来保存第三方源] /// 只适用于 [MacCMSSpider] - static saveToCache(List saves) { + static saveToCache(List saves) { List _to = saves .map( (e) => SourceJsonData(