Files
FlClash/lib/common/package.dart
T
chen08209 aaf934c2d1 refactor(app): rebuild core client, providers, models, database, managers, and window handling
Rework the application layer end to end: core IPC client, providers,
models, database, managers, and shared utilities, with riverpod 3.4.2
and freezed 4.0.1. Keep a rejected profile selected, push the empty
config to Core when a profile fails to build, and fall back to the
default activity icon for package icons.

Add opt-in proxy authentication that injects credentials into the
generated profile and the runtime config, force-clears profile-provided
skip-auth-prefixes so loopback stays covered, sends the credentials with
the app's own proxied requests, and withholds the Android VPN system
proxy while credentials are set. HelperCoreLease treats an unreachable
Helper as confirmation once the OS reports the Core pid gone, and the
lifecycle reconcile retries a parked stop, so the Core comes back after
the Helper service dies. Launch arguments seed LinkManager so a clash://
link raises a silently started window, the access control app list is
fetched on every page entry, the desktop header matches a standard title
bar height, and the tray icons ship as resolution-aware assets scoped per
platform. The version moves to 0.8.97+2026090101.

Rule.parse mirrors mihomo's ParseRulePayload: the type is
case-insensitive, MATCH rules keep no content field, a two-field rule is
payload without a target except for comma-payload types whose lone field
is the target, params are matched whole, and the wildcard and
REMATCH-NAME types the core accepts get their own actions instead of
collapsing into DOMAIN. Window routes show, hide and toggle through one
serialized queue and defers the macOS accessory activation switch until
a second after the last regular switch, so hotkey bursts no longer leave
stray Dock icons. The hotkey manager registers through rust_api instead
of hotkey_manager, the window header restyles the caption buttons after
the native Windows title bar, and the proxies tab keeps its tab
controller alive while the empty state animates in. Bootstrap reads the
Android dynamic palette from the plugin channel without the deprecated
CorePalette, dynamic_color moves to its material_ui release,
navigator_resizable 3.1.0 fixes an assertion when popping
mid-transition, reorderable_grid goes, and the SDK floor rises to 3.10.

Changelog: Rework the app layer and window handling, and add proxy authentication
2026-09-10 12:43:00 +08:00

62 lines
1.9 KiB
Dart

import 'dart:io';
import 'package:package_info_plus/package_info_plus.dart';
import 'common.dart';
extension PackageInfoExtension on PackageInfo {
String get ua => [
'$appName/v$version',
'clash-verge',
'Platform/${Platform.operatingSystem}',
].join(' ');
}
int compareVersions(String version1, String version2) {
final List<String> v1 = version1.split('+')[0].split('.');
final List<String> v2 = version2.split('+')[0].split('.');
final int major1 = int.parse(v1[0]);
final int major2 = int.parse(v2[0]);
if (major1 != major2) {
return major1.compareTo(major2);
}
final int minor1 = v1.length > 1 ? int.parse(v1[1]) : 0;
final int minor2 = v2.length > 1 ? int.parse(v2[1]) : 0;
if (minor1 != minor2) {
return minor1.compareTo(minor2);
}
final int patch1 = v1.length > 2 ? int.parse(v1[2]) : 0;
final int patch2 = v2.length > 2 ? int.parse(v2[2]) : 0;
if (patch1 != patch2) {
return patch1.compareTo(patch2);
}
final int build1 = version1.contains('+')
? int.parse(version1.split('+')[1])
: 0;
final int build2 = version2.contains('+')
? int.parse(version2.split('+')[1])
: 0;
return build1.compareTo(build2);
}
const releaseNotesBeginMarker = '<!-- flclash:changelog:begin -->';
const releaseNotesEndMarker = '<!-- flclash:changelog:end -->';
List<String> parseReleaseBody(String? body) {
if (body == null) return [];
final regex = RegExp(r'^[ \t]*-[ \t]+(.*)$', multiLine: true);
return regex
.allMatches(scopeReleaseNotes(body))
.map((match) => match.group(1)?.trim() ?? '')
.where((item) => item.isNotEmpty)
.toList();
}
String scopeReleaseNotes(String body) {
final begin = body.indexOf(releaseNotesBeginMarker);
if (begin < 0) return body;
final start = begin + releaseNotesBeginMarker.length;
final end = body.indexOf(releaseNotesEndMarker, start);
return end < 0 ? body.substring(start) : body.substring(start, end);
}