2024-04-30 23:38:49 +08:00
|
|
|
import 'dart:io';
|
|
|
|
|
|
2024-06-23 00:26:24 +08:00
|
|
|
import 'package:collection/collection.dart';
|
2024-04-30 23:38:49 +08:00
|
|
|
import 'package:flutter/material.dart';
|
2024-06-03 11:24:41 +08:00
|
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
2024-04-30 23:38:49 +08:00
|
|
|
|
|
|
|
|
import '../enum/enum.dart';
|
|
|
|
|
import '../common/common.dart';
|
|
|
|
|
import 'models.dart';
|
|
|
|
|
|
|
|
|
|
part 'generated/config.g.dart';
|
2024-06-08 22:51:58 +08:00
|
|
|
|
2024-06-03 11:24:41 +08:00
|
|
|
part 'generated/config.freezed.dart';
|
|
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
|
class AccessControl with _$AccessControl {
|
|
|
|
|
const factory AccessControl({
|
|
|
|
|
@Default(AccessControlMode.rejectSelected) AccessControlMode mode,
|
|
|
|
|
@Default([]) List<String> acceptList,
|
|
|
|
|
@Default([]) List<String> rejectList,
|
|
|
|
|
@Default(true) bool isFilterSystemApp,
|
|
|
|
|
}) = _AccessControl;
|
|
|
|
|
|
|
|
|
|
factory AccessControl.fromJson(Map<String, Object?> json) =>
|
|
|
|
|
_$AccessControlFromJson(json);
|
2024-04-30 23:38:49 +08:00
|
|
|
}
|
|
|
|
|
|
2024-06-10 00:47:48 +08:00
|
|
|
@freezed
|
2024-07-26 08:05:22 +08:00
|
|
|
class CoreState with _$CoreState {
|
|
|
|
|
const factory CoreState({
|
2024-06-10 00:47:48 +08:00
|
|
|
AccessControl? accessControl,
|
2024-07-17 17:02:25 +08:00
|
|
|
required bool allowBypass,
|
|
|
|
|
required bool systemProxy,
|
2024-07-26 08:05:22 +08:00
|
|
|
required int mixedPort,
|
|
|
|
|
required bool onlyProxy,
|
|
|
|
|
}) = _CoreState;
|
2024-06-10 00:47:48 +08:00
|
|
|
|
2024-07-26 08:05:22 +08:00
|
|
|
factory CoreState.fromJson(Map<String, Object?> json) => _$CoreStateFromJson(json);
|
2024-06-10 00:47:48 +08:00
|
|
|
}
|
|
|
|
|
|
2024-07-15 22:06:09 +08:00
|
|
|
@freezed
|
|
|
|
|
class WindowProps with _$WindowProps {
|
|
|
|
|
const factory WindowProps({
|
|
|
|
|
@Default(1000) double width,
|
|
|
|
|
@Default(600) double height,
|
|
|
|
|
double? top,
|
|
|
|
|
double? left,
|
|
|
|
|
}) = _WindowProps;
|
|
|
|
|
|
|
|
|
|
factory WindowProps.fromJson(Map<String, Object?>? json) =>
|
|
|
|
|
json == null ? defaultWindowProps : _$WindowPropsFromJson(json);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const defaultWindowProps = WindowProps();
|
|
|
|
|
|
2024-04-30 23:38:49 +08:00
|
|
|
@JsonSerializable()
|
|
|
|
|
class Config extends ChangeNotifier {
|
|
|
|
|
List<Profile> _profiles;
|
2024-05-10 10:11:27 +08:00
|
|
|
bool _isCompatible;
|
2024-04-30 23:38:49 +08:00
|
|
|
String? _currentProfileId;
|
|
|
|
|
bool _autoLaunch;
|
|
|
|
|
bool _silentLaunch;
|
|
|
|
|
bool _autoRun;
|
|
|
|
|
bool _openLog;
|
|
|
|
|
ThemeMode _themeMode;
|
|
|
|
|
String? _locale;
|
|
|
|
|
int? _primaryColor;
|
|
|
|
|
ProxiesSortType _proxiesSortType;
|
|
|
|
|
bool _isMinimizeOnExit;
|
|
|
|
|
bool _isAccessControl;
|
|
|
|
|
AccessControl _accessControl;
|
|
|
|
|
bool _isAnimateToPage;
|
2024-05-20 15:15:09 +08:00
|
|
|
bool _autoCheckUpdate;
|
2024-06-10 00:47:48 +08:00
|
|
|
bool _allowBypass;
|
2024-06-12 19:28:58 +08:00
|
|
|
bool _systemProxy;
|
2024-07-08 17:34:14 +08:00
|
|
|
bool _isExclude;
|
2024-05-20 15:15:09 +08:00
|
|
|
DAV? _dav;
|
2024-07-24 01:27:49 +08:00
|
|
|
bool _isCloseConnections;
|
2024-06-23 00:26:24 +08:00
|
|
|
ProxiesType _proxiesType;
|
|
|
|
|
ProxyCardType _proxyCardType;
|
|
|
|
|
int _proxiesColumns;
|
2024-07-02 08:08:31 +08:00
|
|
|
String _testUrl;
|
2024-07-15 22:06:09 +08:00
|
|
|
WindowProps _windowProps;
|
2024-07-26 08:05:22 +08:00
|
|
|
bool _onlyProxy;
|
2024-08-01 23:51:00 +08:00
|
|
|
bool _prueBlack;
|
2024-04-30 23:38:49 +08:00
|
|
|
|
|
|
|
|
Config()
|
|
|
|
|
: _profiles = [],
|
|
|
|
|
_autoLaunch = false,
|
|
|
|
|
_silentLaunch = false,
|
|
|
|
|
_autoRun = false,
|
2024-07-24 01:27:49 +08:00
|
|
|
_isCloseConnections = false,
|
2024-04-30 23:38:49 +08:00
|
|
|
_themeMode = ThemeMode.system,
|
|
|
|
|
_openLog = false,
|
2024-06-03 18:02:05 +08:00
|
|
|
_isCompatible = true,
|
2024-05-20 15:15:09 +08:00
|
|
|
_primaryColor = defaultPrimaryColor.value,
|
2024-04-30 23:38:49 +08:00
|
|
|
_proxiesSortType = ProxiesSortType.none,
|
|
|
|
|
_isMinimizeOnExit = true,
|
|
|
|
|
_isAccessControl = false,
|
2024-05-20 15:15:09 +08:00
|
|
|
_autoCheckUpdate = true,
|
2024-07-19 02:14:58 +08:00
|
|
|
_systemProxy = false,
|
2024-07-02 08:08:31 +08:00
|
|
|
_testUrl = defaultTestUrl,
|
2024-06-03 11:24:41 +08:00
|
|
|
_accessControl = const AccessControl(),
|
2024-06-10 00:47:48 +08:00
|
|
|
_isAnimateToPage = true,
|
2024-06-23 00:26:24 +08:00
|
|
|
_allowBypass = true,
|
2024-07-08 17:34:14 +08:00
|
|
|
_isExclude = false,
|
2024-06-23 00:26:24 +08:00
|
|
|
_proxyCardType = ProxyCardType.expand,
|
2024-07-15 22:06:09 +08:00
|
|
|
_windowProps = defaultWindowProps,
|
2024-06-23 00:26:24 +08:00
|
|
|
_proxiesType = ProxiesType.tab,
|
2024-07-26 08:05:22 +08:00
|
|
|
_proxiesColumns = 2,
|
2024-08-01 23:51:00 +08:00
|
|
|
_prueBlack = false,
|
2024-07-26 08:05:22 +08:00
|
|
|
_onlyProxy = false;
|
2024-04-30 23:38:49 +08:00
|
|
|
|
|
|
|
|
deleteProfileById(String id) {
|
|
|
|
|
_profiles = profiles.where((element) => element.id != id).toList();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Profile? getCurrentProfileForId(String? value) {
|
|
|
|
|
if (value == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return _profiles.firstWhere((element) => element.id == value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Profile? getCurrentProfile() {
|
|
|
|
|
return getCurrentProfileForId(_currentProfileId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String? _getLabel(String? label, String id) {
|
2024-05-20 15:15:09 +08:00
|
|
|
final realLabel = label ?? id;
|
2024-04-30 23:38:49 +08:00
|
|
|
final hasDup = _profiles.indexWhere(
|
2024-05-20 15:15:09 +08:00
|
|
|
(element) => element.label == realLabel && element.id != id) !=
|
2024-04-30 23:38:49 +08:00
|
|
|
-1;
|
|
|
|
|
if (hasDup) {
|
2024-05-20 15:15:09 +08:00
|
|
|
return _getLabel(other.getOverwriteLabel(realLabel), id);
|
2024-04-30 23:38:49 +08:00
|
|
|
} else {
|
|
|
|
|
return label;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-20 15:15:09 +08:00
|
|
|
_setProfile(Profile profile) {
|
2024-04-30 23:38:49 +08:00
|
|
|
final List<Profile> profilesTemp = List.from(_profiles);
|
|
|
|
|
final index =
|
2024-06-03 14:46:16 +08:00
|
|
|
profilesTemp.indexWhere((element) => element.id == profile.id);
|
2024-04-30 23:38:49 +08:00
|
|
|
final updateProfile = profile.copyWith(
|
|
|
|
|
label: _getLabel(profile.label, profile.id),
|
|
|
|
|
);
|
|
|
|
|
if (index == -1) {
|
|
|
|
|
profilesTemp.add(updateProfile);
|
|
|
|
|
} else {
|
|
|
|
|
profilesTemp[index] = updateProfile;
|
|
|
|
|
}
|
|
|
|
|
_profiles = profilesTemp;
|
2024-05-20 15:15:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setProfile(Profile profile) {
|
|
|
|
|
_setProfile(profile);
|
2024-04-30 23:38:49 +08:00
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonKey(defaultValue: [])
|
|
|
|
|
List<Profile> get profiles => _profiles;
|
|
|
|
|
|
|
|
|
|
set profiles(List<Profile> value) {
|
|
|
|
|
if (_profiles != value) {
|
|
|
|
|
_profiles = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String? get currentProfileId => _currentProfileId;
|
|
|
|
|
|
|
|
|
|
set currentProfileId(String? value) {
|
|
|
|
|
if (_currentProfileId != value) {
|
|
|
|
|
_currentProfileId = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Profile? get currentProfile {
|
2024-06-19 13:13:31 +08:00
|
|
|
final index =
|
|
|
|
|
profiles.indexWhere((profile) => profile.id == _currentProfileId);
|
|
|
|
|
return index == -1 ? null : profiles[index];
|
2024-04-30 23:38:49 +08:00
|
|
|
}
|
|
|
|
|
|
2024-06-13 23:43:42 +08:00
|
|
|
String? get currentGroupName => currentProfile?.currentGroupName;
|
|
|
|
|
|
2024-06-23 00:26:24 +08:00
|
|
|
Set<String> get currentUnfoldSet => currentProfile?.unfoldSet ?? {};
|
|
|
|
|
|
|
|
|
|
updateCurrentUnfoldSet(Set<String> value) {
|
|
|
|
|
if (!const SetEquality<String>().equals(currentUnfoldSet, value)) {
|
|
|
|
|
_setProfile(
|
|
|
|
|
currentProfile!.copyWith(
|
|
|
|
|
unfoldSet: value,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-13 23:43:42 +08:00
|
|
|
updateCurrentGroupName(String groupName) {
|
2024-06-19 13:13:31 +08:00
|
|
|
if (currentProfile != null &&
|
|
|
|
|
currentProfile!.currentGroupName != groupName) {
|
|
|
|
|
_setProfile(
|
|
|
|
|
currentProfile!.copyWith(
|
|
|
|
|
currentGroupName: groupName,
|
|
|
|
|
),
|
|
|
|
|
);
|
2024-06-13 23:43:42 +08:00
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-10 10:11:27 +08:00
|
|
|
SelectedMap get currentSelectedMap {
|
|
|
|
|
return currentProfile?.selectedMap ?? {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateCurrentSelectedMap(String groupName, String proxyName) {
|
2024-06-19 13:13:31 +08:00
|
|
|
if (currentProfile != null &&
|
|
|
|
|
currentProfile!.selectedMap[groupName] != proxyName) {
|
|
|
|
|
final SelectedMap selectedMap = Map.from(
|
|
|
|
|
currentProfile?.selectedMap ?? {},
|
|
|
|
|
)..[groupName] = proxyName;
|
|
|
|
|
_setProfile(
|
|
|
|
|
currentProfile!.copyWith(
|
|
|
|
|
selectedMap: selectedMap,
|
|
|
|
|
),
|
|
|
|
|
);
|
2024-05-07 13:50:00 +08:00
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-30 23:38:49 +08:00
|
|
|
|
|
|
|
|
@JsonKey(defaultValue: false)
|
|
|
|
|
bool get autoLaunch {
|
|
|
|
|
if (!system.isDesktop) return false;
|
|
|
|
|
return _autoLaunch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set autoLaunch(bool value) {
|
|
|
|
|
if (_autoLaunch != value) {
|
|
|
|
|
_autoLaunch = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonKey(defaultValue: false)
|
|
|
|
|
bool get silentLaunch => _silentLaunch;
|
|
|
|
|
|
|
|
|
|
set silentLaunch(bool value) {
|
|
|
|
|
if (_silentLaunch != value) {
|
|
|
|
|
_silentLaunch = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonKey(defaultValue: false)
|
|
|
|
|
bool get autoRun => _autoRun;
|
|
|
|
|
|
|
|
|
|
set autoRun(bool value) {
|
|
|
|
|
if (_autoRun != value) {
|
|
|
|
|
_autoRun = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonKey(defaultValue: ThemeMode.system)
|
|
|
|
|
ThemeMode get themeMode => _themeMode;
|
|
|
|
|
|
|
|
|
|
set themeMode(ThemeMode value) {
|
|
|
|
|
if (_themeMode != value) {
|
|
|
|
|
_themeMode = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonKey(defaultValue: false)
|
|
|
|
|
bool get openLogs => _openLog;
|
|
|
|
|
|
|
|
|
|
set openLogs(bool value) {
|
|
|
|
|
if (_openLog != value) {
|
|
|
|
|
_openLog = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String? get locale => _locale;
|
|
|
|
|
|
|
|
|
|
set locale(String? value) {
|
|
|
|
|
if (_locale != value) {
|
|
|
|
|
_locale = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int? get primaryColor => _primaryColor;
|
|
|
|
|
|
|
|
|
|
set primaryColor(int? value) {
|
|
|
|
|
if (_primaryColor != value) {
|
|
|
|
|
_primaryColor = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonKey(defaultValue: ProxiesSortType.none)
|
|
|
|
|
ProxiesSortType get proxiesSortType => _proxiesSortType;
|
|
|
|
|
|
|
|
|
|
set proxiesSortType(ProxiesSortType value) {
|
|
|
|
|
if (_proxiesSortType != value) {
|
|
|
|
|
_proxiesSortType = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonKey(defaultValue: true)
|
|
|
|
|
bool get isMinimizeOnExit => _isMinimizeOnExit;
|
|
|
|
|
|
|
|
|
|
set isMinimizeOnExit(bool value) {
|
|
|
|
|
if (_isMinimizeOnExit != value) {
|
|
|
|
|
_isMinimizeOnExit = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonKey(defaultValue: false)
|
|
|
|
|
bool get isAccessControl {
|
|
|
|
|
if (!Platform.isAndroid) return false;
|
|
|
|
|
return _isAccessControl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set isAccessControl(bool value) {
|
|
|
|
|
if (_isAccessControl != value) {
|
|
|
|
|
_isAccessControl = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AccessControl get accessControl => _accessControl;
|
|
|
|
|
|
2024-05-20 15:15:09 +08:00
|
|
|
set accessControl(AccessControl value) {
|
2024-04-30 23:38:49 +08:00
|
|
|
if (_accessControl != value) {
|
2024-05-20 15:15:09 +08:00
|
|
|
_accessControl = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DAV? get dav => _dav;
|
|
|
|
|
|
|
|
|
|
set dav(DAV? value) {
|
|
|
|
|
if (_dav != value) {
|
|
|
|
|
_dav = value;
|
2024-04-30 23:38:49 +08:00
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonKey(defaultValue: true)
|
|
|
|
|
bool get isAnimateToPage {
|
|
|
|
|
if (!Platform.isAndroid) return false;
|
|
|
|
|
return _isAnimateToPage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set isAnimateToPage(bool value) {
|
|
|
|
|
if (_isAnimateToPage != value) {
|
|
|
|
|
_isAnimateToPage = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-03 18:02:05 +08:00
|
|
|
@JsonKey(defaultValue: true)
|
2024-05-10 10:11:27 +08:00
|
|
|
bool get isCompatible {
|
|
|
|
|
return _isCompatible;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set isCompatible(bool value) {
|
|
|
|
|
if (_isCompatible != value) {
|
|
|
|
|
_isCompatible = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-20 15:15:09 +08:00
|
|
|
@JsonKey(defaultValue: true)
|
|
|
|
|
bool get autoCheckUpdate {
|
|
|
|
|
return _autoCheckUpdate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set autoCheckUpdate(bool value) {
|
|
|
|
|
if (_autoCheckUpdate != value) {
|
|
|
|
|
_autoCheckUpdate = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-10 00:47:48 +08:00
|
|
|
@JsonKey(defaultValue: true)
|
|
|
|
|
bool get allowBypass {
|
|
|
|
|
return _allowBypass;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set allowBypass(bool value) {
|
|
|
|
|
if (_allowBypass != value) {
|
|
|
|
|
_allowBypass = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-19 02:14:58 +08:00
|
|
|
@JsonKey(defaultValue: false)
|
2024-06-12 19:28:58 +08:00
|
|
|
bool get systemProxy {
|
|
|
|
|
return _systemProxy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set systemProxy(bool value) {
|
|
|
|
|
if (_systemProxy != value) {
|
|
|
|
|
_systemProxy = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-26 08:05:22 +08:00
|
|
|
@JsonKey(defaultValue: false)
|
|
|
|
|
bool get onlyProxy {
|
|
|
|
|
return _onlyProxy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set onlyProxy(bool value) {
|
|
|
|
|
if (_onlyProxy != value) {
|
|
|
|
|
_onlyProxy = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-01 23:51:00 +08:00
|
|
|
@JsonKey(defaultValue: false)
|
|
|
|
|
bool get prueBlack {
|
|
|
|
|
return _prueBlack;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set prueBlack(bool value) {
|
|
|
|
|
if (_prueBlack != value) {
|
|
|
|
|
_prueBlack = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-26 08:05:22 +08:00
|
|
|
|
2024-07-24 01:27:49 +08:00
|
|
|
@JsonKey(defaultValue: false)
|
|
|
|
|
bool get isCloseConnections {
|
|
|
|
|
return _isCloseConnections;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set isCloseConnections(bool value) {
|
|
|
|
|
if (_isCloseConnections != value) {
|
|
|
|
|
_isCloseConnections = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-15 22:06:09 +08:00
|
|
|
@JsonKey(
|
|
|
|
|
defaultValue: ProxiesType.tab,
|
|
|
|
|
unknownEnumValue: ProxiesType.tab,
|
|
|
|
|
)
|
2024-06-23 00:26:24 +08:00
|
|
|
ProxiesType get proxiesType => _proxiesType;
|
|
|
|
|
|
|
|
|
|
set proxiesType(ProxiesType value) {
|
|
|
|
|
if (_proxiesType != value) {
|
|
|
|
|
_proxiesType = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonKey(defaultValue: ProxyCardType.expand)
|
|
|
|
|
ProxyCardType get proxyCardType => _proxyCardType;
|
|
|
|
|
|
|
|
|
|
set proxyCardType(ProxyCardType value) {
|
|
|
|
|
if (_proxyCardType != value) {
|
|
|
|
|
_proxyCardType = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonKey(defaultValue: 2)
|
|
|
|
|
int get proxiesColumns => _proxiesColumns;
|
|
|
|
|
|
|
|
|
|
set proxiesColumns(int value) {
|
|
|
|
|
if (_proxiesColumns != value) {
|
|
|
|
|
_proxiesColumns = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-02 08:08:31 +08:00
|
|
|
@JsonKey(name: "test-url", defaultValue: defaultTestUrl)
|
|
|
|
|
String get testUrl => _testUrl;
|
|
|
|
|
|
|
|
|
|
set testUrl(String value) {
|
|
|
|
|
if (_testUrl != value) {
|
|
|
|
|
_testUrl = value;
|
|
|
|
|
notifyListeners();
|
2024-07-08 17:34:14 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonKey(defaultValue: false)
|
|
|
|
|
bool get isExclude => _isExclude;
|
|
|
|
|
|
|
|
|
|
set isExclude(bool value) {
|
|
|
|
|
if (_isExclude != value) {
|
|
|
|
|
_isExclude = value;
|
|
|
|
|
notifyListeners();
|
2024-07-02 08:08:31 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-15 22:06:09 +08:00
|
|
|
WindowProps get windowProps => _windowProps;
|
|
|
|
|
|
|
|
|
|
set windowProps(WindowProps value) {
|
|
|
|
|
if (_windowProps != value) {
|
|
|
|
|
_windowProps = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-10 00:47:48 +08:00
|
|
|
update([
|
|
|
|
|
Config? config,
|
|
|
|
|
RecoveryOption recoveryOptions = RecoveryOption.all,
|
|
|
|
|
]) {
|
2024-05-20 15:15:09 +08:00
|
|
|
if (config != null) {
|
|
|
|
|
_profiles = config._profiles;
|
|
|
|
|
for (final profile in config._profiles) {
|
|
|
|
|
_setProfile(profile);
|
|
|
|
|
}
|
|
|
|
|
final onlyProfiles = recoveryOptions == RecoveryOption.onlyProfiles;
|
2024-06-03 11:24:41 +08:00
|
|
|
if (_currentProfileId == null && onlyProfiles && profiles.isNotEmpty) {
|
2024-05-20 15:15:09 +08:00
|
|
|
_currentProfileId = _profiles.first.id;
|
|
|
|
|
}
|
2024-06-03 11:24:41 +08:00
|
|
|
if (onlyProfiles) return;
|
2024-05-20 15:15:09 +08:00
|
|
|
_currentProfileId = config._currentProfileId;
|
2024-07-24 01:27:49 +08:00
|
|
|
_isCloseConnections = config._isCloseConnections;
|
2024-05-20 15:15:09 +08:00
|
|
|
_isCompatible = config._isCompatible;
|
|
|
|
|
_autoLaunch = config._autoLaunch;
|
|
|
|
|
_silentLaunch = config._silentLaunch;
|
|
|
|
|
_autoRun = config._autoRun;
|
2024-06-23 00:26:24 +08:00
|
|
|
_proxiesType = config._proxiesType;
|
2024-05-20 15:15:09 +08:00
|
|
|
_openLog = config._openLog;
|
|
|
|
|
_themeMode = config._themeMode;
|
|
|
|
|
_locale = config._locale;
|
2024-06-10 00:47:48 +08:00
|
|
|
_allowBypass = config._allowBypass;
|
2024-05-20 15:15:09 +08:00
|
|
|
_primaryColor = config._primaryColor;
|
|
|
|
|
_proxiesSortType = config._proxiesSortType;
|
|
|
|
|
_isMinimizeOnExit = config._isMinimizeOnExit;
|
|
|
|
|
_isAccessControl = config._isAccessControl;
|
|
|
|
|
_accessControl = config._accessControl;
|
|
|
|
|
_isAnimateToPage = config._isAnimateToPage;
|
|
|
|
|
_autoCheckUpdate = config._autoCheckUpdate;
|
2024-08-01 23:51:00 +08:00
|
|
|
_prueBlack = config._prueBlack;
|
2024-07-15 22:06:09 +08:00
|
|
|
_testUrl = config._testUrl;
|
|
|
|
|
_isExclude = config._isExclude;
|
|
|
|
|
_windowProps = config._windowProps;
|
2024-05-20 15:15:09 +08:00
|
|
|
}
|
2024-04-30 23:38:49 +08:00
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() {
|
|
|
|
|
return _$ConfigToJson(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
factory Config.fromJson(Map<String, dynamic> json) {
|
|
|
|
|
return _$ConfigFromJson(json);
|
|
|
|
|
}
|
|
|
|
|
}
|