Skip to content

Commit 57cba37

Browse files
committed
Optimize network detection
Optimize tile service
1 parent bef4ad6 commit 57cba37

File tree

3 files changed

+38
-26
lines changed

3 files changed

+38
-26
lines changed

.github/workflows/change.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: change
22

33
on:
44
push:
5-
branches:
6-
- 'main'
5+
tags:
6+
- 'v*'
77

88
jobs:
99
changelog:

lib/fragments/dashboard/network_detection.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class _NetworkDetectionState extends State<NetworkDetection> {
5555
);
5656
return;
5757
}
58-
_setTimeoutTimer = Timer(const Duration(milliseconds: 2000), () {
58+
_clearSetTimeoutTimer();
59+
_setTimeoutTimer = Timer(const Duration(milliseconds: 300), () {
5960
networkDetectionState.value = networkDetectionState.value.copyWith(
6061
isTesting: false,
6162
ipInfo: null,
@@ -156,7 +157,8 @@ class _NetworkDetectionState extends State<NetworkDetection> {
156157
.textTheme
157158
.titleLarge
158159
?.copyWith(
159-
fontFamily: FontFamily.twEmoji.value,
160+
fontFamily:
161+
FontFamily.twEmoji.value,
160162
),
161163
),
162164
)

lib/main.dart

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import 'package:fl_clash/plugins/vpn.dart';
88
import 'package:fl_clash/state.dart';
99
import 'package:flutter/material.dart';
1010
import 'package:package_info_plus/package_info_plus.dart';
11+
1112
import 'application.dart';
13+
import 'common/common.dart';
1214
import 'l10n/l10n.dart';
1315
import 'models/models.dart';
14-
import 'common/common.dart';
1516

1617
Future<void> main() async {
1718
WidgetsFlutterBinding.ensureInitialized();
@@ -96,10 +97,10 @@ Future<void> vpnService() async {
9697
);
9798
},
9899
onStarted: (String runTime) async {
99-
await globalState.applyProfile(
100-
appState: appState,
101-
config: config,
100+
await globalState.updateClashConfig(
102101
clashConfig: clashConfig,
102+
config: config,
103+
isPatch: false,
103104
);
104105
},
105106
onLoaded: (String groupName) {
@@ -115,25 +116,34 @@ Future<void> vpnService() async {
115116
),
116117
);
117118
await app?.tip(appLocalizations.startVpn);
118-
await globalState.handleStart();
119-
120-
tile?.addListener(
121-
TileListenerWithVpn(
122-
onStop: () async {
123-
await app?.tip(appLocalizations.stopVpn);
124-
await globalState.handleStop();
125-
clashCore.shutdown();
126-
exit(0);
127-
},
128-
),
129-
);
130119

131-
globalState.updateTraffic();
132-
globalState.updateFunctionLists = [
133-
() {
134-
globalState.updateTraffic();
135-
}
136-
];
120+
globalState
121+
.updateClashConfig(
122+
clashConfig: clashConfig,
123+
config: config,
124+
isPatch: false,
125+
)
126+
.then((_) async {
127+
await globalState.handleStart();
128+
129+
tile?.addListener(
130+
TileListenerWithVpn(
131+
onStop: () async {
132+
await app?.tip(appLocalizations.stopVpn);
133+
await globalState.handleStop();
134+
clashCore.shutdown();
135+
exit(0);
136+
},
137+
),
138+
);
139+
140+
globalState.updateTraffic();
141+
globalState.updateFunctionLists = [
142+
() {
143+
globalState.updateTraffic();
144+
}
145+
];
146+
});
137147
}
138148

139149
@immutable

0 commit comments

Comments
 (0)