LighthouseApp/lib/singbox/model/singbox_outbound.dart
speakeloudest 75d4c48e41
Some checks failed
Build Windows / build (push) Has been cancelled
feat: 源码提交
2025-10-19 23:30:54 -07:00

41 lines
1.4 KiB
Dart
Executable File

import 'package:dartx/dartx.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:kaer_with_panels/singbox/model/singbox_proxy_type.dart';
part 'singbox_outbound.freezed.dart';
part 'singbox_outbound.g.dart';
@freezed
class SingboxOutboundGroup with _$SingboxOutboundGroup {
@JsonSerializable(fieldRename: FieldRename.kebab)
const factory SingboxOutboundGroup({
required String tag,
@JsonKey(fromJson: _typeFromJson) required ProxyType type,
required String selected,
@Default([]) List<SingboxOutboundGroupItem> items,
}) = _SingboxOutboundGroup;
factory SingboxOutboundGroup.fromJson(Map<String, dynamic> json) =>
_$SingboxOutboundGroupFromJson(json);
}
@freezed
class SingboxOutboundGroupItem with _$SingboxOutboundGroupItem {
const SingboxOutboundGroupItem._();
@JsonSerializable(fieldRename: FieldRename.kebab)
const factory SingboxOutboundGroupItem({
required String tag,
@JsonKey(fromJson: _typeFromJson) required ProxyType type,
required int urlTestDelay,
}) = _SingboxOutboundGroupItem;
factory SingboxOutboundGroupItem.fromJson(Map<String, dynamic> json) =>
_$SingboxOutboundGroupItemFromJson(json);
}
final Map<String, ProxyType> _keyMap =
Map.fromEntries(ProxyType.values.map((e) => MapEntry(e.key, e)));
ProxyType _typeFromJson(dynamic type) => ProxyType.fromJson(type);