Skip to content

Commit 6de89d7

Browse files
committed
Optimize proxies page
Fix ua issues Optimize more details
1 parent c36df8c commit 6de89d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1575
-636
lines changed

core/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ func applyConfig() {
423423
if configParams.IsPatch {
424424
patchConfig(cfg.General)
425425
} else {
426+
closeConnections()
426427
runtime.GC()
427428
hub.UltraApplyConfig(cfg, true)
428429
patchSelectGroup()

core/hub.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -299,25 +299,24 @@ func getConnections() *C.char {
299299
}
300300

301301
//export closeConnections
302-
func closeConnections() bool {
302+
func closeConnections() {
303303
statistic.DefaultManager.Range(func(c statistic.Tracker) bool {
304304
err := c.Close()
305305
if err != nil {
306306
return false
307307
}
308308
return true
309309
})
310-
return true
311310
}
312311

313312
//export closeConnection
314-
func closeConnection(id *C.char) bool {
313+
func closeConnection(id *C.char) {
315314
connectionId := C.GoString(id)
316-
err := statistic.DefaultManager.Get(connectionId).Close()
317-
if err != nil {
318-
return false
315+
c := statistic.DefaultManager.Get(connectionId)
316+
if c == nil {
317+
return
319318
}
320-
return true
319+
_ = c.Close()
321320
}
322321

323322
//export getProviders

lib/application.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,7 @@ class ApplicationState extends State<Application> {
157157
GlobalWidgetsLocalizations.delegate
158158
],
159159
builder: (_, child) {
160-
return PopContainer(
161-
child: _buildApp(child!),
162-
);
160+
return _buildApp(child!);
163161
},
164162
scrollBehavior: BaseScrollBehavior(),
165163
title: appName,

lib/clash/core.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,15 @@ class ClashCore {
319319
return connectionsRaw.map((e) => Connection.fromJson(e)).toList();
320320
}
321321

322-
closeConnections(String id) {
322+
closeConnection(String id) {
323323
final idChar = id.toNativeUtf8().cast<Char>();
324324
clashFFI.closeConnection(idChar);
325325
malloc.free(idChar);
326326
}
327+
328+
closeConnections() {
329+
clashFFI.closeConnections();
330+
}
327331
}
328332

329333
final clashCore = ClashCore();

lib/clash/generated/clash_ffi.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5351,16 +5351,16 @@ class ClashFFI {
53515351
late final _getConnections =
53525352
_getConnectionsPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
53535353

5354-
int closeConnections() {
5354+
void closeConnections() {
53555355
return _closeConnections();
53565356
}
53575357

53585358
late final _closeConnectionsPtr =
5359-
_lookup<ffi.NativeFunction<GoUint8 Function()>>('closeConnections');
5359+
_lookup<ffi.NativeFunction<ffi.Void Function()>>('closeConnections');
53605360
late final _closeConnections =
5361-
_closeConnectionsPtr.asFunction<int Function()>();
5361+
_closeConnectionsPtr.asFunction<void Function()>();
53625362

5363-
int closeConnection(
5363+
void closeConnection(
53645364
ffi.Pointer<ffi.Char> id,
53655365
) {
53665366
return _closeConnection(
@@ -5369,10 +5369,10 @@ class ClashFFI {
53695369
}
53705370

53715371
late final _closeConnectionPtr =
5372-
_lookup<ffi.NativeFunction<GoUint8 Function(ffi.Pointer<ffi.Char>)>>(
5372+
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Char>)>>(
53735373
'closeConnection');
53745374
late final _closeConnection =
5375-
_closeConnectionPtr.asFunction<int Function(ffi.Pointer<ffi.Char>)>();
5375+
_closeConnectionPtr.asFunction<void Function(ffi.Pointer<ffi.Char>)>();
53765376

53775377
ffi.Pointer<ffi.Char> getProviders() {
53785378
return _getProviders();

lib/common/iterable.dart

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,58 @@ extension IterableExt<T> on Iterable<T> {
1010
yield iterator.current;
1111
}
1212
}
13+
14+
Iterable<List<T>> chunks(int size) sync* {
15+
if (length == 0) return;
16+
var iterator = this.iterator;
17+
while (iterator.moveNext()) {
18+
var chunk = [iterator.current];
19+
for (var i = 1; i < size && iterator.moveNext(); i++) {
20+
chunk.add(iterator.current);
21+
}
22+
yield chunk;
23+
}
24+
}
25+
26+
Iterable<T> fill(
27+
int length, {
28+
required T Function(int count) filler,
29+
}) sync* {
30+
int count = 0;
31+
for (var item in this) {
32+
yield item;
33+
count++;
34+
if (count >= length) return;
35+
}
36+
while (count < length) {
37+
yield filler(count);
38+
count++;
39+
}
40+
}
41+
}
42+
43+
extension DoubleListExt on List<double> {
44+
int findInterval(num target) {
45+
if (isEmpty) return -1;
46+
if (target < first) return -1;
47+
if (target >= last) return length - 1;
48+
49+
int left = 0;
50+
int right = length - 1;
51+
52+
while (left <= right) {
53+
int mid = left + (right - left) ~/ 2;
54+
55+
if (mid == length - 1 ||
56+
(this[mid] <= target && target < this[mid + 1])) {
57+
return mid;
58+
} else if (target < this[mid]) {
59+
right = mid - 1;
60+
} else {
61+
left = mid + 1;
62+
}
63+
}
64+
65+
return -1; // 这行理论上不会执行到,但为了完整性保留
66+
}
1367
}

lib/common/scroll.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,14 @@ class BaseScrollBehavior extends MaterialScrollBehavior {
1414
PointerDeviceKind.unknown,
1515
};
1616
}
17+
18+
class HiddenBarScrollBehavior extends BaseScrollBehavior {
19+
@override
20+
Widget buildScrollbar(
21+
BuildContext context,
22+
Widget child,
23+
ScrollableDetails details,
24+
) {
25+
return child;
26+
}
27+
}

lib/common/window.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Window {
1919
await windowManager.ensureInitialized();
2020
WindowOptions windowOptions = WindowOptions(
2121
size: Size(props.width, props.height),
22-
minimumSize: const Size(380, 600),
22+
minimumSize: const Size(380, 500),
2323
titleBarStyle: TitleBarStyle.hidden,
2424
);
2525
if (props.left != null || props.top != null) {

lib/controller.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class AppController {
9090
final updateId = config.profiles.first.id;
9191
changeProfile(updateId);
9292
} else {
93-
changeProfile(null);
93+
updateSystemProxy(false);
9494
}
9595
}
9696
}
@@ -193,6 +193,7 @@ class AppController {
193193
}
194194

195195
handleBackOrExit() async {
196+
print(config.isMinimizeOnExit);
196197
if (config.isMinimizeOnExit) {
197198
if (system.isDesktop) {
198199
await savePreferences();
@@ -410,8 +411,7 @@ class AppController {
410411
addProfileFormURL(url);
411412
}
412413

413-
int get columns =>
414-
other.getColumns(appState.viewMode, config.proxiesColumns);
414+
int get columns => other.getColumns(appState.viewMode, config.proxiesColumns);
415415

416416
updateViewWidth(double width) {
417417
WidgetsBinding.instance.addPostFrameCallback((_) {
@@ -453,4 +453,9 @@ class AppController {
453453
ProxiesSortType.name => _sortOfName(proxies),
454454
};
455455
}
456+
457+
String getCurrentSelectedName(String groupName) {
458+
final group = appState.getGroupWithName(groupName);
459+
return config.currentSelectedMap[groupName] ?? group?.now ?? '';
460+
}
456461
}

lib/fragments/about.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:fl_clash/common/common.dart';
22
import 'package:fl_clash/state.dart';
33
import 'package:fl_clash/widgets/list.dart';
44
import 'package:flutter/material.dart';
5-
import 'package:url_launcher/url_launcher.dart';
65

76
@immutable
87
class Contributor {
@@ -90,7 +89,7 @@ class AboutFragment extends StatelessWidget {
9089
];
9190
return generateSection(
9291
separated: false,
93-
title: appLocalizations.contributors,
92+
title: appLocalizations.otherContributors,
9493
items: [
9594
ListItem(
9695
title: SingleChildScrollView(

0 commit comments

Comments
 (0)