Optimize dashboard performance

Fix some issues
This commit is contained in:
chen08209
2025-03-09 01:58:46 +08:00
parent 2aae00cf68
commit de9c5ba9cc
19 changed files with 631 additions and 176 deletions

View File

@@ -273,6 +273,17 @@ class GeoXUrl with _$GeoXUrl {
}
}
@freezed
class ClashConfigSnippet with _$ClashConfigSnippet {
const factory ClashConfigSnippet({
@Default([]) @JsonKey(name: "proxy-groups") List<ProxyGroup> proxyGroups,
@Default([]) List<String> rule,
}) = _ClashConfigSnippet;
factory ClashConfigSnippet.fromJson(Map<String, Object?> json) =>
_$ClashConfigSnippetFromJson(json);
}
@freezed
class ClashConfig with _$ClashConfig {
const factory ClashConfig({
@@ -301,7 +312,7 @@ class ClashConfig with _$ClashConfig {
@JsonKey(name: "geodata-loader")
GeodataLoader geodataLoader,
@Default([]) @JsonKey(name: "proxy-groups") List<ProxyGroup> proxyGroups,
@Default([]) List<String> rules,
@Default([]) List<String> rule,
@JsonKey(name: "global-ua") String? globalUa,
@Default(ExternalControllerStatus.close)
@JsonKey(name: "external-controller")

View File

@@ -1834,6 +1834,202 @@ abstract class _GeoXUrl implements GeoXUrl {
throw _privateConstructorUsedError;
}
ClashConfigSnippet _$ClashConfigSnippetFromJson(Map<String, dynamic> json) {
return _ClashConfigSnippet.fromJson(json);
}
/// @nodoc
mixin _$ClashConfigSnippet {
@JsonKey(name: "proxy-groups")
List<ProxyGroup> get proxyGroups => throw _privateConstructorUsedError;
List<String> get rule => throw _privateConstructorUsedError;
/// Serializes this ClashConfigSnippet to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of ClashConfigSnippet
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ClashConfigSnippetCopyWith<ClashConfigSnippet> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ClashConfigSnippetCopyWith<$Res> {
factory $ClashConfigSnippetCopyWith(
ClashConfigSnippet value, $Res Function(ClashConfigSnippet) then) =
_$ClashConfigSnippetCopyWithImpl<$Res, ClashConfigSnippet>;
@useResult
$Res call(
{@JsonKey(name: "proxy-groups") List<ProxyGroup> proxyGroups,
List<String> rule});
}
/// @nodoc
class _$ClashConfigSnippetCopyWithImpl<$Res, $Val extends ClashConfigSnippet>
implements $ClashConfigSnippetCopyWith<$Res> {
_$ClashConfigSnippetCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ClashConfigSnippet
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? proxyGroups = null,
Object? rule = null,
}) {
return _then(_value.copyWith(
proxyGroups: null == proxyGroups
? _value.proxyGroups
: proxyGroups // ignore: cast_nullable_to_non_nullable
as List<ProxyGroup>,
rule: null == rule
? _value.rule
: rule // ignore: cast_nullable_to_non_nullable
as List<String>,
) as $Val);
}
}
/// @nodoc
abstract class _$$ClashConfigSnippetImplCopyWith<$Res>
implements $ClashConfigSnippetCopyWith<$Res> {
factory _$$ClashConfigSnippetImplCopyWith(_$ClashConfigSnippetImpl value,
$Res Function(_$ClashConfigSnippetImpl) then) =
__$$ClashConfigSnippetImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{@JsonKey(name: "proxy-groups") List<ProxyGroup> proxyGroups,
List<String> rule});
}
/// @nodoc
class __$$ClashConfigSnippetImplCopyWithImpl<$Res>
extends _$ClashConfigSnippetCopyWithImpl<$Res, _$ClashConfigSnippetImpl>
implements _$$ClashConfigSnippetImplCopyWith<$Res> {
__$$ClashConfigSnippetImplCopyWithImpl(_$ClashConfigSnippetImpl _value,
$Res Function(_$ClashConfigSnippetImpl) _then)
: super(_value, _then);
/// Create a copy of ClashConfigSnippet
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? proxyGroups = null,
Object? rule = null,
}) {
return _then(_$ClashConfigSnippetImpl(
proxyGroups: null == proxyGroups
? _value._proxyGroups
: proxyGroups // ignore: cast_nullable_to_non_nullable
as List<ProxyGroup>,
rule: null == rule
? _value._rule
: rule // ignore: cast_nullable_to_non_nullable
as List<String>,
));
}
}
/// @nodoc
@JsonSerializable()
class _$ClashConfigSnippetImpl implements _ClashConfigSnippet {
const _$ClashConfigSnippetImpl(
{@JsonKey(name: "proxy-groups")
final List<ProxyGroup> proxyGroups = const [],
final List<String> rule = const []})
: _proxyGroups = proxyGroups,
_rule = rule;
factory _$ClashConfigSnippetImpl.fromJson(Map<String, dynamic> json) =>
_$$ClashConfigSnippetImplFromJson(json);
final List<ProxyGroup> _proxyGroups;
@override
@JsonKey(name: "proxy-groups")
List<ProxyGroup> get proxyGroups {
if (_proxyGroups is EqualUnmodifiableListView) return _proxyGroups;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_proxyGroups);
}
final List<String> _rule;
@override
@JsonKey()
List<String> get rule {
if (_rule is EqualUnmodifiableListView) return _rule;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_rule);
}
@override
String toString() {
return 'ClashConfigSnippet(proxyGroups: $proxyGroups, rule: $rule)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ClashConfigSnippetImpl &&
const DeepCollectionEquality()
.equals(other._proxyGroups, _proxyGroups) &&
const DeepCollectionEquality().equals(other._rule, _rule));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType,
const DeepCollectionEquality().hash(_proxyGroups),
const DeepCollectionEquality().hash(_rule));
/// Create a copy of ClashConfigSnippet
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ClashConfigSnippetImplCopyWith<_$ClashConfigSnippetImpl> get copyWith =>
__$$ClashConfigSnippetImplCopyWithImpl<_$ClashConfigSnippetImpl>(
this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$ClashConfigSnippetImplToJson(
this,
);
}
}
abstract class _ClashConfigSnippet implements ClashConfigSnippet {
const factory _ClashConfigSnippet(
{@JsonKey(name: "proxy-groups") final List<ProxyGroup> proxyGroups,
final List<String> rule}) = _$ClashConfigSnippetImpl;
factory _ClashConfigSnippet.fromJson(Map<String, dynamic> json) =
_$ClashConfigSnippetImpl.fromJson;
@override
@JsonKey(name: "proxy-groups")
List<ProxyGroup> get proxyGroups;
@override
List<String> get rule;
/// Create a copy of ClashConfigSnippet
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ClashConfigSnippetImplCopyWith<_$ClashConfigSnippetImpl> get copyWith =>
throw _privateConstructorUsedError;
}
ClashConfig _$ClashConfigFromJson(Map<String, dynamic> json) {
return _ClashConfig.fromJson(json);
}
@@ -1866,7 +2062,7 @@ mixin _$ClashConfig {
GeodataLoader get geodataLoader => throw _privateConstructorUsedError;
@JsonKey(name: "proxy-groups")
List<ProxyGroup> get proxyGroups => throw _privateConstructorUsedError;
List<String> get rules => throw _privateConstructorUsedError;
List<String> get rule => throw _privateConstructorUsedError;
@JsonKey(name: "global-ua")
String? get globalUa => throw _privateConstructorUsedError;
@JsonKey(name: "external-controller")
@@ -1907,7 +2103,7 @@ abstract class $ClashConfigCopyWith<$Res> {
GeoXUrl geoXUrl,
@JsonKey(name: "geodata-loader") GeodataLoader geodataLoader,
@JsonKey(name: "proxy-groups") List<ProxyGroup> proxyGroups,
List<String> rules,
List<String> rule,
@JsonKey(name: "global-ua") String? globalUa,
@JsonKey(name: "external-controller")
ExternalControllerStatus externalController,
@@ -1947,7 +2143,7 @@ class _$ClashConfigCopyWithImpl<$Res, $Val extends ClashConfig>
Object? geoXUrl = null,
Object? geodataLoader = null,
Object? proxyGroups = null,
Object? rules = null,
Object? rule = null,
Object? globalUa = freezed,
Object? externalController = null,
Object? hosts = null,
@@ -2009,9 +2205,9 @@ class _$ClashConfigCopyWithImpl<$Res, $Val extends ClashConfig>
? _value.proxyGroups
: proxyGroups // ignore: cast_nullable_to_non_nullable
as List<ProxyGroup>,
rules: null == rules
? _value.rules
: rules // ignore: cast_nullable_to_non_nullable
rule: null == rule
? _value.rule
: rule // ignore: cast_nullable_to_non_nullable
as List<String>,
globalUa: freezed == globalUa
? _value.globalUa
@@ -2084,7 +2280,7 @@ abstract class _$$ClashConfigImplCopyWith<$Res>
GeoXUrl geoXUrl,
@JsonKey(name: "geodata-loader") GeodataLoader geodataLoader,
@JsonKey(name: "proxy-groups") List<ProxyGroup> proxyGroups,
List<String> rules,
List<String> rule,
@JsonKey(name: "global-ua") String? globalUa,
@JsonKey(name: "external-controller")
ExternalControllerStatus externalController,
@@ -2125,7 +2321,7 @@ class __$$ClashConfigImplCopyWithImpl<$Res>
Object? geoXUrl = null,
Object? geodataLoader = null,
Object? proxyGroups = null,
Object? rules = null,
Object? rule = null,
Object? globalUa = freezed,
Object? externalController = null,
Object? hosts = null,
@@ -2187,9 +2383,9 @@ class __$$ClashConfigImplCopyWithImpl<$Res>
? _value._proxyGroups
: proxyGroups // ignore: cast_nullable_to_non_nullable
as List<ProxyGroup>,
rules: null == rules
? _value._rules
: rules // ignore: cast_nullable_to_non_nullable
rule: null == rule
? _value._rule
: rule // ignore: cast_nullable_to_non_nullable
as List<String>,
globalUa: freezed == globalUa
? _value.globalUa
@@ -2230,13 +2426,13 @@ class _$ClashConfigImpl implements _ClashConfig {
this.geodataLoader = GeodataLoader.memconservative,
@JsonKey(name: "proxy-groups")
final List<ProxyGroup> proxyGroups = const [],
final List<String> rules = const [],
final List<String> rule = const [],
@JsonKey(name: "global-ua") this.globalUa,
@JsonKey(name: "external-controller")
this.externalController = ExternalControllerStatus.close,
final Map<String, String> hosts = const {}})
: _proxyGroups = proxyGroups,
_rules = rules,
_rule = rule,
_hosts = hosts;
factory _$ClashConfigImpl.fromJson(Map<String, dynamic> json) =>
@@ -2290,13 +2486,13 @@ class _$ClashConfigImpl implements _ClashConfig {
return EqualUnmodifiableListView(_proxyGroups);
}
final List<String> _rules;
final List<String> _rule;
@override
@JsonKey()
List<String> get rules {
if (_rules is EqualUnmodifiableListView) return _rules;
List<String> get rule {
if (_rule is EqualUnmodifiableListView) return _rule;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_rules);
return EqualUnmodifiableListView(_rule);
}
@override
@@ -2316,7 +2512,7 @@ class _$ClashConfigImpl implements _ClashConfig {
@override
String toString() {
return 'ClashConfig(mixedPort: $mixedPort, mode: $mode, allowLan: $allowLan, logLevel: $logLevel, ipv6: $ipv6, findProcessMode: $findProcessMode, keepAliveInterval: $keepAliveInterval, unifiedDelay: $unifiedDelay, tcpConcurrent: $tcpConcurrent, tun: $tun, dns: $dns, geoXUrl: $geoXUrl, geodataLoader: $geodataLoader, proxyGroups: $proxyGroups, rules: $rules, globalUa: $globalUa, externalController: $externalController, hosts: $hosts)';
return 'ClashConfig(mixedPort: $mixedPort, mode: $mode, allowLan: $allowLan, logLevel: $logLevel, ipv6: $ipv6, findProcessMode: $findProcessMode, keepAliveInterval: $keepAliveInterval, unifiedDelay: $unifiedDelay, tcpConcurrent: $tcpConcurrent, tun: $tun, dns: $dns, geoXUrl: $geoXUrl, geodataLoader: $geodataLoader, proxyGroups: $proxyGroups, rule: $rule, globalUa: $globalUa, externalController: $externalController, hosts: $hosts)';
}
@override
@@ -2347,7 +2543,7 @@ class _$ClashConfigImpl implements _ClashConfig {
other.geodataLoader == geodataLoader) &&
const DeepCollectionEquality()
.equals(other._proxyGroups, _proxyGroups) &&
const DeepCollectionEquality().equals(other._rules, _rules) &&
const DeepCollectionEquality().equals(other._rule, _rule) &&
(identical(other.globalUa, globalUa) ||
other.globalUa == globalUa) &&
(identical(other.externalController, externalController) ||
@@ -2373,7 +2569,7 @@ class _$ClashConfigImpl implements _ClashConfig {
geoXUrl,
geodataLoader,
const DeepCollectionEquality().hash(_proxyGroups),
const DeepCollectionEquality().hash(_rules),
const DeepCollectionEquality().hash(_rule),
globalUa,
externalController,
const DeepCollectionEquality().hash(_hosts));
@@ -2412,7 +2608,7 @@ abstract class _ClashConfig implements ClashConfig {
final GeoXUrl geoXUrl,
@JsonKey(name: "geodata-loader") final GeodataLoader geodataLoader,
@JsonKey(name: "proxy-groups") final List<ProxyGroup> proxyGroups,
final List<String> rules,
final List<String> rule,
@JsonKey(name: "global-ua") final String? globalUa,
@JsonKey(name: "external-controller")
final ExternalControllerStatus externalController,
@@ -2462,7 +2658,7 @@ abstract class _ClashConfig implements ClashConfig {
@JsonKey(name: "proxy-groups")
List<ProxyGroup> get proxyGroups;
@override
List<String> get rules;
List<String> get rule;
@override
@JsonKey(name: "global-ua")
String? get globalUa;

View File

@@ -206,6 +206,25 @@ Map<String, dynamic> _$$GeoXUrlImplToJson(_$GeoXUrlImpl instance) =>
'geosite': instance.geosite,
};
_$ClashConfigSnippetImpl _$$ClashConfigSnippetImplFromJson(
Map<String, dynamic> json) =>
_$ClashConfigSnippetImpl(
proxyGroups: (json['proxy-groups'] as List<dynamic>?)
?.map((e) => ProxyGroup.fromJson(e as Map<String, dynamic>))
.toList() ??
const [],
rule:
(json['rule'] as List<dynamic>?)?.map((e) => e as String).toList() ??
const [],
);
Map<String, dynamic> _$$ClashConfigSnippetImplToJson(
_$ClashConfigSnippetImpl instance) =>
<String, dynamic>{
'proxy-groups': instance.proxyGroups,
'rule': instance.rule,
};
_$ClashConfigImpl _$$ClashConfigImplFromJson(Map<String, dynamic> json) =>
_$ClashConfigImpl(
mixedPort: (json['mixed-port'] as num?)?.toInt() ?? defaultMixedPort,
@@ -238,8 +257,8 @@ _$ClashConfigImpl _$$ClashConfigImplFromJson(Map<String, dynamic> json) =>
?.map((e) => ProxyGroup.fromJson(e as Map<String, dynamic>))
.toList() ??
const [],
rules:
(json['rules'] as List<dynamic>?)?.map((e) => e as String).toList() ??
rule:
(json['rule'] as List<dynamic>?)?.map((e) => e as String).toList() ??
const [],
globalUa: json['global-ua'] as String?,
externalController: $enumDecodeNullable(
@@ -267,7 +286,7 @@ Map<String, dynamic> _$$ClashConfigImplToJson(_$ClashConfigImpl instance) =>
'geox-url': instance.geoXUrl,
'geodata-loader': _$GeodataLoaderEnumMap[instance.geodataLoader]!,
'proxy-groups': instance.proxyGroups,
'rules': instance.rules,
'rule': instance.rule,
'global-ua': instance.globalUa,
'external-controller':
_$ExternalControllerStatusEnumMap[instance.externalController]!,

View File

@@ -14,6 +14,153 @@ T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
/// @nodoc
mixin _$VM2<A, B> {
A get a => throw _privateConstructorUsedError;
B get b => throw _privateConstructorUsedError;
/// Create a copy of VM2
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$VM2CopyWith<A, B, VM2<A, B>> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $VM2CopyWith<A, B, $Res> {
factory $VM2CopyWith(VM2<A, B> value, $Res Function(VM2<A, B>) then) =
_$VM2CopyWithImpl<A, B, $Res, VM2<A, B>>;
@useResult
$Res call({A a, B b});
}
/// @nodoc
class _$VM2CopyWithImpl<A, B, $Res, $Val extends VM2<A, B>>
implements $VM2CopyWith<A, B, $Res> {
_$VM2CopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of VM2
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? a = freezed,
Object? b = freezed,
}) {
return _then(_value.copyWith(
a: freezed == a
? _value.a
: a // ignore: cast_nullable_to_non_nullable
as A,
b: freezed == b
? _value.b
: b // ignore: cast_nullable_to_non_nullable
as B,
) as $Val);
}
}
/// @nodoc
abstract class _$$VM2ImplCopyWith<A, B, $Res>
implements $VM2CopyWith<A, B, $Res> {
factory _$$VM2ImplCopyWith(
_$VM2Impl<A, B> value, $Res Function(_$VM2Impl<A, B>) then) =
__$$VM2ImplCopyWithImpl<A, B, $Res>;
@override
@useResult
$Res call({A a, B b});
}
/// @nodoc
class __$$VM2ImplCopyWithImpl<A, B, $Res>
extends _$VM2CopyWithImpl<A, B, $Res, _$VM2Impl<A, B>>
implements _$$VM2ImplCopyWith<A, B, $Res> {
__$$VM2ImplCopyWithImpl(
_$VM2Impl<A, B> _value, $Res Function(_$VM2Impl<A, B>) _then)
: super(_value, _then);
/// Create a copy of VM2
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? a = freezed,
Object? b = freezed,
}) {
return _then(_$VM2Impl<A, B>(
a: freezed == a
? _value.a
: a // ignore: cast_nullable_to_non_nullable
as A,
b: freezed == b
? _value.b
: b // ignore: cast_nullable_to_non_nullable
as B,
));
}
}
/// @nodoc
class _$VM2Impl<A, B> implements _VM2<A, B> {
const _$VM2Impl({required this.a, required this.b});
@override
final A a;
@override
final B b;
@override
String toString() {
return 'VM2<$A, $B>(a: $a, b: $b)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$VM2Impl<A, B> &&
const DeepCollectionEquality().equals(other.a, a) &&
const DeepCollectionEquality().equals(other.b, b));
}
@override
int get hashCode => Object.hash(
runtimeType,
const DeepCollectionEquality().hash(a),
const DeepCollectionEquality().hash(b));
/// Create a copy of VM2
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$VM2ImplCopyWith<A, B, _$VM2Impl<A, B>> get copyWith =>
__$$VM2ImplCopyWithImpl<A, B, _$VM2Impl<A, B>>(this, _$identity);
}
abstract class _VM2<A, B> implements VM2<A, B> {
const factory _VM2({required final A a, required final B b}) =
_$VM2Impl<A, B>;
@override
A get a;
@override
B get b;
/// Create a copy of VM2
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$VM2ImplCopyWith<A, B, _$VM2Impl<A, B>> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$StartButtonSelectorState {
bool get isInit => throw _privateConstructorUsedError;

View File

@@ -7,6 +7,15 @@ import 'package:freezed_annotation/freezed_annotation.dart';
part 'generated/selector.freezed.dart';
@freezed
class VM2<A, B> with _$VM2<A, B> {
const factory VM2({
required A a,
required B b,
}) = _VM2;
}
@freezed
class StartButtonSelectorState with _$StartButtonSelectorState {
const factory StartButtonSelectorState({
@@ -134,18 +143,19 @@ extension PackageListSelectorStateExt on PackageListSelectorState {
return packages
.where((item) => isFilterSystemApp ? item.isSystem == false : true)
.sorted(
(a, b) {
(a, b) {
return switch (sort) {
AccessSortType.none => 0,
AccessSortType.name => other.sortByChar(
other.getPinyin(a.label),
other.getPinyin(b.label),
),
AccessSortType.name =>
other.sortByChar(
other.getPinyin(a.label),
other.getPinyin(b.label),
),
AccessSortType.time => b.lastUpdateTime.compareTo(a.lastUpdateTime),
};
},
).sorted(
(a, b) {
(a, b) {
final isSelectA = selectedList.contains(a.packageName);
final isSelectB = selectedList.contains(b.packageName);
if (isSelectA && isSelectB) return 0;