Skip to content

Commit

Permalink
refactor: SpiderImpl -> ISpider
Browse files Browse the repository at this point in the history
  • Loading branch information
d1y committed Jun 23, 2023
1 parent a2b27f4 commit 5879321
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions lib/app/modules/home/controllers/home_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -196,15 +196,15 @@ class HomeController extends GetxController with WidgetsBindingObserver {
_mirrorIndex = index;
}

SpiderImpl get currentMirrorItem {
ISpider get currentMirrorItem {
return mirrorList[mirrorIndex];
}

bool get mirrorListIsEmpty {
return mirrorList.isEmpty;
}

List<SpiderImpl> get mirrorList {
List<ISpider> get mirrorList {
if (isNsfw) return SpiderManage.data;
return SpiderManage.data.where((e) => !e.isNsfw).toList();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/app/modules/home/views/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class HomeView extends GetView<HomeController> {
? const Color.fromRGBO(0, 0, 0, .63)
: const Color.fromRGBO(255, 255, 255, .63);

List<SpiderImpl> get mirror => home.mirrorList;
List<ISpider> get mirror => home.mirrorList;

int get mirrorIndex => home.mirrorIndex;

Expand Down
4 changes: 2 additions & 2 deletions lib/app/modules/home/views/mirror_check.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MirrorCheckView extends StatefulWidget {
required this.list,
}) : super(key: key);

final List<SpiderImpl> list;
final List<ISpider> list;

@override
State<MirrorCheckView> createState() => _MirrorCheckViewState();
Expand All @@ -53,7 +53,7 @@ class _MirrorCheckViewState extends State<MirrorCheckView> {

bool running = false;

List<SpiderImpl> get listStack => widget.list;
List<ISpider> get listStack => widget.list;

int get listStackLen => listStack.length;

Expand Down
8 changes: 4 additions & 4 deletions lib/app/modules/home/views/mirrortable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ class MirrorTableView extends StatefulWidget {
class _MirrorTableViewState extends State<MirrorTableView> {
final HomeController home = Get.find<HomeController>();

List<SpiderImpl> get _mirrorList {
List<ISpider> get _mirrorList {
return home.mirrorList;
}

List<SpiderImpl> mirrorList = [];
List<ISpider> mirrorList = [];

ScrollController scrollController = ScrollController(
initialScrollOffset: 0,
Expand Down Expand Up @@ -338,7 +338,7 @@ class MirrorCard extends StatelessWidget {

final double maxHeight;

final SpiderImpl item;
final ISpider item;

final bool current;

Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/app/modules/play/controllers/play_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class PlayController extends GetxController {

HomeController home = Get.find<HomeController>();

SpiderImpl get currentMovieInstance {
ISpider get currentMovieInstance {
var itemAs = home.currentMirrorItem;
return itemAs;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/app/shared/mirror_status_stack.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MirrorStatusStack {

Map<String, bool> get getStacks => _stacks;

final List<SpiderImpl> _datas = SpiderManage.extend;
final List<ISpider> _datas = SpiderManage.extend;

bool? getStack(String stack) {
return _stacks[stack];
Expand Down
2 changes: 1 addition & 1 deletion lib/spider/abstract/spider_movie.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SpiderQueryCategory {
}
}

abstract class SpiderImpl {
abstract class ISpider {
/// 是否为R18资源
/// **Not Safe For Work**
bool get isNsfw;
Expand Down
2 changes: 1 addition & 1 deletion lib/spider/impl/mac_cms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enum ResponseCustomType {
unknow
}

class MacCMSSpider extends SpiderImpl {
class MacCMSSpider extends ISpider {
final bool nsfw;
final String jiexiUrl;
final String name;
Expand Down
10 changes: 5 additions & 5 deletions lib/spider/shared/manage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class SpiderManage {
SpiderManage._internal();

/// 扩展的源
static List<SpiderImpl> extend = [];
static List<ISpider> extend = [];

/// 内建支持的源
/// 一般是需要自己去实现的源
static List<SpiderImpl> builtin = [];
static List<ISpider> builtin = [];

/// 合并之后的数据
static List<SpiderImpl> get data {
static List<ISpider> get data {
return [...extend, ...builtin];
}

Expand All @@ -47,7 +47,7 @@ class SpiderManage {
}

/// 删除单个源
static removeItem(SpiderImpl item) {
static removeItem(ISpider item) {
debugPrint("删除该源: $item");
extend.remove(item);
saveToCache(extend);
Expand Down Expand Up @@ -141,7 +141,7 @@ class SpiderManage {
/// 保存缓存
/// [该方法只可用来保存第三方源]
/// 只适用于 [MacCMSSpider]
static saveToCache(List<SpiderImpl> saves) {
static saveToCache(List<ISpider> saves) {
List<SourceJsonData> _to = saves
.map(
(e) => SourceJsonData(
Expand Down

0 comments on commit 5879321

Please sign in to comment.