Optimize commented policy

This commit is contained in:
chen08209
2026-08-15 17:47:08 +08:00
parent 7fb4f4f711
commit e2f678909d
31 changed files with 48 additions and 443 deletions
-5
View File
@@ -19,9 +19,4 @@ extension ArchiveExt on Archive {
}
}
}
// void addTextFile<T>(String name, T raw) {
// final data = json.encode(raw);
// addFile(ArchiveFile.string(name, data));
// }
}
-15
View File
@@ -15,21 +15,6 @@ class BaseNavigator {
context,
).push<T>(CommonRoute(builder: (context) => child));
}
// static Future<T?> modal<T>(BuildContext context, Widget child) async {
// if (globalState.appState.viewMode != ViewMode.mobile) {
// return await globalState.showCommonDialog<T>(
// child: CommonModal(
// child: child,
// ),
// );
// }
// return await Navigator.of(context).push<T>(
// CommonRoute(
// builder: (context) => child,
// ),
// );
// }
}
const commonSharedXPageTransitions = SharedAxisPageTransitionsBuilder(
-48
View File
@@ -114,54 +114,6 @@ class NextClampingScrollPhysics extends ClampingScrollPhysics {
}
}
// class CacheScrollPositionController extends ScrollController {
// final String key;
//
// CacheScrollPositionController({
// required this.key,
// double initialScrollOffset = 0.0,
// super.keepScrollOffset = true,
// super.debugLabel,
// super.onAttach,
// super.onDetach,
// });
//
// @override
// ScrollPosition createScrollPosition(
// ScrollPhysics physics,
// ScrollContext context,
// ScrollPosition? oldPosition,
// ) {
// return ScrollPositionWithSingleContext(
// physics: physics,
// context: context,
// initialPixels:
// globalState.scrollPositionCache[key] ?? initialScrollOffset,
// keepScrollOffset: keepScrollOffset,
// oldPosition: oldPosition,
// debugLabel: debugLabel,
// );
// }
//
// double? get cacheOffset => globalState.scrollPositionCache[key];
//
// _handleScroll() {
// globalState.scrollPositionCache[key] = position.pixels;
// }
//
// @override
// void attach(ScrollPosition position) {
// super.attach(position);
// addListener(_handleScroll);
// }
//
// @override
// void detach(ScrollPosition position) {
// removeListener(_handleScroll);
// super.detach(position);
// }
// }
class ReverseScrollController extends ScrollController {
ReverseScrollController({
super.initialScrollOffset,
-4
View File
@@ -79,10 +79,6 @@ extension StringExtension on String {
return md5.convert(bytes).toString();
}
// bool containsToLower(String target) {
// return toLowerCase().contains(target);
// }
Future<T> commonToJSON<T>() async {
const thresholdLimit = 51200;
if (length < thresholdLimit) {
-3
View File
@@ -364,9 +364,6 @@ Future<MigrationData> _oldToNowTask(
configMap['appSettingProps'] = appSettingProps;
configMap['proxiesStyleProps'] = configMap['proxiesStyle'];
configMap['proxiesStyleProps'] = configMap['proxiesStyle'];
// final overwriteMap = configMap['overwrite'] as Map? ?? {};
// configMap['overwriteType'] = overwriteMap['type'];
// configMap['scriptId'] = overwriteMap['scriptOverwrite'];
List rawScripts = configMap['scripts'] as List<dynamic>? ?? [];
if (rawScripts.isEmpty) {
final scriptPropsJson = configMap['scriptProps'] as Map<String, dynamic>?;
-6
View File
@@ -184,12 +184,6 @@ class Utils {
return build1.compareTo(build2);
}
// String getPinyin(String value) {
// return value.isNotEmpty
// ? PinyinHelper.getFirstWordPinyin(value.substring(0, 1))
// : '';
// }
String? getFileNameForDisposition(String? disposition) {
if (disposition == null) return null;
final parseValue = HeaderValue.parse(disposition);
-1
View File
@@ -27,7 +27,6 @@ class Window {
protocol.register('flclash');
}
await windowManager.ensureInitialized();
// kDebugMode ? Size(680, 580) :
final WindowOptions windowOptions = WindowOptions(
size: props.size,
minimumSize: const Size(380, 400),
-7
View File
@@ -53,13 +53,6 @@ class Database extends _$Database {
await _migrateRules(m);
}
},
beforeOpen: (details) async {
// final m = Migrator(this);
// await m.createTable(iconRecords);
// await _migrateRules(m);
// await m.deleteTable('proxy_groups');
// await m.createTable(proxyGroups);
},
);
}
-1
View File
@@ -95,7 +95,6 @@ class RulesDao extends DatabaseAccessor<Database> with _$RulesDaoMixin {
stmt.orderBy([
(t) => OrderingTerm.asc(t.scene),
//v0.8.92 ordering desc
(t) => OrderingTerm.desc(t.order),
(t) => OrderingTerm.desc(t.id),
]);
+1 -17
View File
@@ -146,10 +146,6 @@ enum RestoreOption { all, onlyProfiles }
enum ChipType { action, delete }
enum CommonCardType { plain, filled }
//
// extension CommonCardTypeExt on CommonCardType {
// CommonCardType get variant => CommonCardType.plain;
// }
enum ProxiesType { tab, list }
@@ -438,12 +434,7 @@ extension RuleActionExt on RuleAction {
enum OverrideRuleType { override, added }
enum OverwriteType {
// none,
standard,
script,
custom,
}
enum OverwriteType { standard, script, custom }
enum RuleTarget {
DIRECT,
@@ -451,13 +442,6 @@ enum RuleTarget {
static Set<String> get baseTargets =>
RuleTarget.values.map((item) => item.name).toSet();
// static bool isBaseRuleTarget(String? target) {
// return RuleTarget.values.indexWhere(
// (item) => item.name == target?.toUpperCase(),
// ) !=
// -1;
// }
}
enum RestoreStrategy { compatible, override }
-25
View File
@@ -140,36 +140,11 @@ class AppSidebarContainer extends ConsumerWidget {
const AppSidebarContainer({super.key, required this.child});
// Widget _buildLoading() {
// return Consumer(
// builder: (_, ref, _) {
// final loading = ref.watch(loadingProvider);
// final isMobileView = ref.watch(isMobileViewProvider);
// return loading && !isMobileView
// ? RotatedBox(
// quarterTurns: 1,
// child: const LinearProgressIndicator(),
// )
// : Container();
// },
// );
// }
Widget _buildBackground({
required BuildContext context,
required Widget child,
}) {
return Material(color: context.colorScheme.surfaceContainer, child: child);
// if (!system.isMacOS) {
// return Material(
// color: context.colorScheme.surfaceContainer,
// child: child,
// );
// }
// return child;
// return TransparentMacOSSidebar(
// child: Material(color: Colors.transparent, child: child),
// );
}
void _updateSideBarWidth(WidgetRef ref, double contentWidth) {
-62
View File
@@ -190,7 +190,6 @@ class StatusManagerState extends State<StatusManager> {
),
),
),
// LoadingIndicator(),
],
),
),
@@ -198,64 +197,3 @@ class StatusManagerState extends State<StatusManager> {
);
}
}
// class LoadingIndicator extends ConsumerWidget {
// const LoadingIndicator({super.key});
//
// @override
// Widget build(BuildContext context, ref) {
// final loading = ref.watch(loadingProvider);
// final isMobileView = ref.watch(isMobileViewProvider);
// return AnimatedSwitcher(
// switchInCurve: Curves.easeIn,
// switchOutCurve: Curves.easeOut,
// duration: midDuration,
// transitionBuilder: (Widget child, Animation<double> animation) {
// return SlideTransition(
// position: Tween<Offset>(
// begin: const Offset(1, 0),
// end: Offset.zero,
// ).animate(animation),
// child: child,
// );
// },
// child: loading && isMobileView
// ? Container(
// height: 54,
// margin: EdgeInsets.only(top: 8, left: 14, right: 14),
// child: Material(
// elevation: 3,
// color: context.colorScheme.surfaceContainer,
// surfaceTintColor: context.colorScheme.surfaceTint,
// shape: const RoundedSuperellipseBorder(
// borderRadius: BorderRadius.all(Radius.circular(14)),
// ),
// child: Padding(
// padding: EdgeInsets.symmetric(horizontal: 16),
// child: Row(
// mainAxisSize: MainAxisSize.min,
// spacing: 12,
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Flexible(
// child: Text(
// context.appLocalizations.loading,
// style: context.textTheme.labelLarge?.copyWith(
// color: context.colorScheme.onSurfaceVariant,
// ),
// ),
// ),
// SizedBox(
// height: 32,
// width: 32,
// child: CommonCircleLoading(),
// ),
// ],
// ),
// ),
// ),
// )
// : SizedBox(),
// );
// }
// }
-16
View File
@@ -42,22 +42,6 @@ class ThemeManager extends ConsumerWidget {
);
}
// _buildScrollbar(Widget child) {
// return Consumer(
// builder: (_, ref, child) {
// final isMobileView = ref.read(isMobileViewProvider);
// if (isMobileView) {
// return ScrollConfiguration(
// behavior: HiddenBarScrollBehavior(),
// child: child!,
// );
// }
// return child!;
// },
// child: child,
// );
// }
@override
Widget build(BuildContext context, ref) {
final textScale = ref.read(
-3
View File
@@ -233,9 +233,6 @@ class _WindowHeaderState extends State<WindowHeader> {
},
icon: const Icon(Icons.close),
),
// const SizedBox(
// width: 8,
// ),
],
);
}
-45
View File
@@ -333,10 +333,6 @@ abstract class Rule with _$Rule {
String? order,
}) = _Rule;
// factory Rule.parseString(String? value) {
// return Rule.parse(Rule.value(value ?? ''));
// }
factory Rule.init() {
return Rule(
ruleAction: RuleAction.DOMAIN,
@@ -442,39 +438,6 @@ extension RuleExt on Rule {
}
}
// @freezed
// abstract class Rule with _$Rule {
// const factory Rule({required int id, required String value, String? order}) =
// _Rule;
//
// factory Rule.value(String value) {
// return Rule(value: value, id: snowflake.id);
// }
//
// factory Rule.fromJson(Map<String, Object?> json) => _$RuleFromJson(json);
// }
//
// extension RulesExt on List<Rule> {
// List<Rule> copyAndPut(Rule rule) {
// var newList = List<Rule>.from(this);
// final index = newList.indexWhere((item) => item.id == rule.id);
// if (index != -1) {
// rule = newList[index] = rule;
// } else {
// newList.insert(0, rule);
// }
// return newList;
// }
// }
// @freezed
// abstract class SubRule with _$SubRule {
// const factory SubRule({required String name}) = _SubRule;
//
// factory SubRule.fromJson(Map<String, Object?> json) =>
// _$SubRuleFromJson(json);
// }
//
List<Rule> _genRules(List<dynamic>? rules) {
if (rules == null) {
return [];
@@ -482,14 +445,6 @@ List<Rule> _genRules(List<dynamic>? rules) {
return rules.map((item) => Rule.parse(item)).toList();
}
// List<RuleProvider> _genRuleProviders(Map<String, dynamic> json) {
// return json.entries.map((entry) => RuleProvider(name: entry.key)).toList();
// }
//
// List<SubRule> _genSubRules(Map<String, dynamic> json) {
// return json.entries.map((entry) => SubRule(name: entry.key)).toList();
// }
List<String> _genList(Map<String, dynamic> json) {
return json.entries.map((entry) => entry.key).toList();
}
+1 -10
View File
@@ -140,25 +140,16 @@ String _logDateTime(dynamic _) {
return DateTime.now().showFull;
}
// String _logId(_) {
// return utils.id;
// }
@freezed
abstract class Log with _$Log {
const factory Log({
// @JsonKey(fromJson: _logId) required String id,
@JsonKey(name: 'LogLevel') @Default(LogLevel.info) LogLevel logLevel,
@JsonKey(name: 'Payload') @Default('') String payload,
@JsonKey(fromJson: _logDateTime) required String dateTime,
}) = _Log;
factory Log.app(String payload) {
return Log(
payload: payload,
dateTime: _logDateTime(null),
// id: _logId(null),
);
return Log(payload: payload, dateTime: _logDateTime(null));
}
factory Log.fromJson(Map<String, Object?> json) => _$LogFromJson(json);
-25
View File
@@ -93,18 +93,6 @@ extension ProfileRuleLinkExt on ProfileRuleLink {
}
}
// @freezed
// abstract class Overwrite with _$Overwrite {
// const factory Overwrite({
// @Default(OverwriteType.standard) OverwriteType type,
// @Default(StandardOverwrite()) StandardOverwrite standardOverwrite,
// @Default(ScriptOverwrite()) ScriptOverwrite scriptOverwrite,
// }) = _Overwrite;
//
// factory Overwrite.fromJson(Map<String, Object?> json) =>
// _$OverwriteFromJson(json);
// }
@freezed
abstract class StandardOverwrite with _$StandardOverwrite {
const factory StandardOverwrite({
@@ -178,19 +166,6 @@ extension ProfileExtension on Profile {
return file.create(recursive: true);
}
return file;
// final oldPath = await appPath.getProfilePath(id);
// final newPath = await appPath.getProfilePath(fileName);
// final oldFile = oldPath == newPath ? null : File(oldPath);
// final oldIsExists = await oldFile?.exists() ?? false;
// if (oldIsExists) {
// return await oldFile!.rename(newPath);
// }
// final file = File(newPath);
// final isExists = await file.exists();
// if (!isExists && autoCreate) {
// return await file.create(recursive: true);
// }
// return file;
}
Future<File> get file async {
-39
View File
@@ -369,42 +369,3 @@ abstract class SetupState with _$SetupState {
required Dns dns,
}) = _SetupState;
}
// extension SetupStateExt on SetupState {
// bool needSetup(SetupState? lastSetupState) {
// if (lastSetupState == null) {
// return false;
// }
// if (profileId != lastSetupState.profileId) {
// return true;
// }
// if (profileLastUpdateDate != lastSetupState.profileLastUpdateDate) {
// return true;
// }
// final scriptIsChange = script != lastSetupState.script;
// if (overwriteType != lastSetupState.overwriteType) {
// if (!ruleListEquality.equals(addedRules, lastSetupState.addedRules) ||
// scriptIsChange) {
// return true;
// }
// } else {
// if (overwriteType == OverwriteType.script) {
// if (scriptIsChange) {
// return true;
// }
// }
// if (overwriteType == OverwriteType.standard) {
// if (!ruleListEquality.equals(addedRules, lastSetupState.addedRules)) {
// return true;
// }
// }
// }
// if (overrideDns != lastSetupState.overrideDns) {
// return true;
// }
// if (overrideDns == true && dns != lastSetupState.dns) {
// return true;
// }
// return false;
// }
// }
-3
View File
@@ -500,9 +500,6 @@ ColorScheme genColorScheme(
),
);
if (color == null && (ignoreConfig == true || vm2.a == null)) {
// if (globalState.corePalette != null) {
// return globalState.corePalette!.toColorScheme(brightness: brightness);
// }
return ColorScheme.fromSeed(
seedColor:
globalState.corePalette
-3
View File
@@ -199,9 +199,6 @@ class Avatar extends StatelessWidget {
Text(contributor.name, style: context.textTheme.bodySmall),
],
),
// onTap: () {
// globalState.openUrl(contributor.link);
// },
);
}
}
-16
View File
@@ -45,22 +45,6 @@ class TrackerInfoItem extends ConsumerWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(trackerInfo.desc, style: context.textTheme.bodyLarge),
// Row(
// mainAxisSize: MainAxisSize.max,
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// spacing: 8,
// children: [
// Flexible(
// child: Text(trackerInfo.desc, style: context.textTheme.bodyLarge),
// ),
// Text(
// trackerInfo.start.lastUpdateTimeDesc,
// style: context.textTheme.bodySmall?.copyWith(
// color: context.colorScheme.onSurface.opacity60,
// ),
// ),
// ],
// ),
const SizedBox(height: 6),
Text(
_getSourceText(context, trackerInfo),
@@ -179,18 +179,6 @@ class OutboundModeV2 extends StatelessWidget {
height: 8.ap,
width: constraints.maxWidth,
padding: const EdgeInsets.symmetric(horizontal: 16),
// child: Row(
// children: [
// Container(
// width: (constraints.maxWidth - 32) / 3,
// height: 3,
// decoration: BoxDecoration(
// color: _getTextColor(context, mode),
// borderRadius: BorderRadius.circular(2),
// ),
// ),
// ],
// ),
),
],
);
-9
View File
@@ -69,15 +69,6 @@ class DeveloperView extends ConsumerWidget {
.handleClear();
},
),
// ListItem(
// title: Text(appLocalizations.loadTest),
// minVerticalPadding: 12,
// onTap: () {
// ref.read(loadingProvider.notifier).value = !ref.read(
// loadingProvider,
// );
// },
// ),
ListItem(
title: Text(appLocalizations.pruneCache),
minVerticalPadding: 12,
-13
View File
@@ -24,22 +24,9 @@ class _ProfilesViewState extends State<ProfilesView> {
Function? applyConfigDebounce;
bool _isUpdating = false;
// final GlobalKey _targetKey = GlobalKey();
@override
void initState() {
super.initState();
// WidgetsBinding.instance.addPostFrameCallback((_) {
// final context = _targetKey.currentContext;
// if (context == null) {
// return;
// }
// Scrollable.ensureVisible(
// context,
// duration: commonDuration,
// alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtEnd,
// );
// });
}
void _handleShowAddExtendPage() {
-10
View File
@@ -154,16 +154,6 @@ class CommonCard extends StatelessWidget {
Color? _buildBackgroundColor(BuildContext context) {
final colorScheme = context.colorScheme;
// if (isError) {
// if (type == CommonCardType.filled) {
// return isSelected
// ? colorScheme.errorContainer.opacity80
// : colorScheme.errorContainer;
// }
// return isSelected
// ? colorScheme.errorContainer.opacity60
// : colorScheme.errorContainer.opacity12;
// }
if (type == CommonCardType.filled) {
if (isSelected) {
return colorScheme.secondaryContainer.opacity80;
-2
View File
@@ -203,12 +203,10 @@ class _ThemeAwareSvg extends StatelessWidget {
'#E8DEF8',
'#${_colorToHex(colorScheme.secondaryContainer)}',
);
// primary ??
svgString = svgString.replaceAll(
'#6750A4',
'#${_colorToHex(colorScheme.primary)}',
);
// surface ??
svgString = svgString.replaceAll(
'#FDF7FF',
'#${_colorToHex(colorScheme.surface)}',
-25
View File
@@ -628,28 +628,3 @@ Future<T?> showModalSideSheet<T>({
),
);
}
// class ModalAppBar extends StatelessWidget {
// final String title;
//
// const ModalAppBar({
// super.key,
// required this.title,
// });
//
// @override
// Widget build(BuildContext context) {
// return AppBar(
// automaticallyImplyLeading: false,
// title: Text(title),
// centerTitle: false,
// actions: const [
// SizedBox(
// height: kToolbarHeight,
// width: kToolbarHeight,
// child: CloseButton(),
// )
// ],
// );
// }
// }
-16
View File
@@ -130,19 +130,3 @@ class EmojiText extends StatelessWidget {
);
}
}
// class HighlightText extends StatelessWidget {
// const HighlightText({super.key});
//
// @override
// Widget build(BuildContext context) {
// return RichText(
// textScaler: MediaQuery.of(context).textScaler,
// maxLines: maxLines,
// overflow: overflow ?? TextOverflow.clip,
// text: TextSpan(
// children: _buildTextSpans(text),
// ),
// );
// }
// }