Skip to content

Commit 76ad6b2

Browse files
authored
v1.37.0 (#141)
* refactor: rename Dashboard * feat: light client mode * feat: light client mode * feat: light client mode * feat: light client mode * feat: click the dock icon to restore after closing the window on macOS * chore: add flex_color_scheme dep * feat: add theme * feat: enable theme * fix: invalid styles * feat: improve ui * feat: read setting * fix: invalid current proxy info * fix: invalid i18n * feat: upgrade core * fix: invalid styles * feat: handle window event on macOS * feat: proxy mode badge * chore: upgrade deps * refactor: remove unused code * chore: update README * chore: v1.37.0-beat.0 * refactor: remove unused code * fix: invalid styles * fix: invalid styles * chore: add pub_semver dep * feat: check for update * feat: check for update on app started * refactor: remove unused code * Revert "chore: add pub_semver dep" This reverts commit ac7daed. * chore: upgrade core * chore: v1.37.0 * chore: upgrade core * chore: update README
1 parent 40344fc commit 76ad6b2

21 files changed

Lines changed: 1056 additions & 161 deletions

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
## What's Changed
22

3+
### New features
4+
5+
* feat: [Light Client Mode](https://igoogolx.github.io/lux-docs/docs/configuration/light_client_mode)
6+
7+
38
### Bug fixes 🐛
49

5-
* fix: system proxy not working when Allow Lan is enabled
6-
* fix: fail to check for update since v1.35.0
10+
* fix: fail to upgrade form winget
711

812
### Other Changes
913

lib/app.dart

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,46 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter_localizations/flutter_localizations.dart';
3+
import 'package:lux/core_config.dart';
24
import 'package:lux/home.dart';
5+
import 'package:lux/theme.dart';
36
import 'package:lux/tr.dart';
47
import 'package:provider/provider.dart';
58

69
import 'l10n/app_localizations.dart';
710

811
class App extends StatelessWidget {
9-
final String theme;
10-
final Color scaffoldBackgroundColor ;
11-
final LocaleModel defaultLocalModel ;
12+
final ThemeMode theme;
13+
final LocaleModel defaultLocalModel;
14+
final ClientMode clientMode;
1215

13-
const App(this.theme,this.scaffoldBackgroundColor, this.defaultLocalModel,{super.key});
16+
const App(this.theme, this.defaultLocalModel, this.clientMode, {super.key});
1417

1518
@override
1619
Widget build(BuildContext context) {
1720
return ChangeNotifierProvider(
1821
create: (context) => defaultLocalModel,
1922
child: Consumer<LocaleModel>(
2023
builder: (context, localeModel, child) => MaterialApp(
21-
theme: ThemeData(
22-
scaffoldBackgroundColor:scaffoldBackgroundColor ), //Dark mode of dashboard
23-
home: Home(theme, defaultLocalModel),
24+
themeMode: theme,
25+
theme: AppTheme.light,
26+
darkTheme: AppTheme.dark,
27+
home: Home(theme, defaultLocalModel, clientMode),
2428
onGenerateTitle: (context) {
2529
initTr(context);
2630
return 'Lux';
2731
},
2832
locale: localeModel.locale,
2933
localizationsDelegates: [
3034
AppLocalizations.delegate,
35+
GlobalMaterialLocalizations.delegate,
36+
GlobalWidgetsLocalizations.delegate,
3137
],
3238
supportedLocales: [
3339
Locale('en'),
3440
Locale('zh'),
3541
],
36-
)
37-
,
42+
),
3843
),
3944
);
4045
}
4146
}
42-

lib/checksum.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import 'dart:io';
2+
23
import 'package:crypto/crypto.dart';
34

4-
const darwinArm64Checksum =
5-
"061f537ae593688ffab80896a02940efaf0222888d2f2f1b61e96d2acbcf271b";
65
const darwinAmd64Checksum =
7-
"a90af3313dc2d32e584b04910f8c08cd22209783e76ee79f97e1a13899e52191";
6+
"21a5759b749a1ee3bd41a875c53105c75db03be4eea85a5d5be1589815cf3e14";
7+
const darwinArm64Checksum =
8+
"d1ef4b1f7ffc7de8170a9208f916e58bd7c43993c48ed46d31f3caefe707f21d";
89
const windowsAmd64Checksum =
9-
"b901c8680208d3756aeeebfc42d220f41836a2447ed5d71dcdc70552b6f2b7fb";
10+
"7db0495cc478a851d8881f547201c001f4a7b2284d2223d1ad2e99ec2bcb3037";
1011

1112
Future<void> verifyCoreBinary(String filePath) async {
1213
var input = File(filePath);

lib/core_config.dart

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@ import 'package:lux/utils.dart';
22
import 'package:path/path.dart' as path;
33

44
Future<Map<String, dynamic>> readConfig() async {
5-
try{
5+
try {
66
var homeDir = await getHomeDir();
77
var configPath = path.join(homeDir, 'config.json');
88
return await readJsonFile(configPath);
9-
}catch(e) {
9+
} catch (e) {
1010
return {};
1111
}
1212
}
1313

1414
Future<Map<String, dynamic>> readSetting() async {
15-
try{
15+
try {
1616
final config = await readConfig();
1717
if (config.containsKey('setting') &&
1818
config['setting'] is Map<String, dynamic>) {
1919
return config['setting'] as Map<String, dynamic>;
2020
}
2121
return {};
22-
}catch(e){
22+
} catch (e) {
2323
return {};
2424
}
2525
}
@@ -39,6 +39,22 @@ Future<ThemeType> readTheme() async {
3939
return ThemeType.light;
4040
}
4141

42+
enum ClientMode {
43+
light,
44+
webview,
45+
}
46+
47+
Future<ClientMode> readClientMode() async {
48+
var setting = await readSetting();
49+
if (setting.containsKey('lightClientMode') &&
50+
setting['lightClientMode'] is bool) {
51+
if (setting['lightClientMode']) {
52+
return ClientMode.light;
53+
}
54+
}
55+
return ClientMode.webview;
56+
}
57+
4258
Future<bool> readAutoLaunch() async {
4359
var setting = await readSetting();
4460
if (setting.containsKey('autoLaunch') && setting['autoLaunch'] is bool) {

lib/core_manager.dart

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,59 @@ class CoreManager {
150150
await dio.post('$baseUrl/manager/start');
151151
}
152152

153+
Future<bool> getIsStarted() async {
154+
final managerRes = await dio.get('$baseUrl/manager');
155+
var isStarted = managerRes.data['isStarted'];
156+
if (isStarted is bool) {
157+
return isStarted;
158+
}
159+
return false;
160+
}
161+
162+
Future<String> getCurProxyInfo() async {
163+
final managerRes = await dio.get('$baseUrl/proxies/cur-proxy');
164+
var name = managerRes.data['name'];
165+
if (name is String && name.isNotEmpty) {
166+
return name;
167+
}
168+
var addr = managerRes.data['addr'];
169+
if (addr is String && addr.isNotEmpty) {
170+
return addr;
171+
}
172+
return "";
173+
}
174+
175+
Future<ProxyList> getProxyList() async {
176+
final proxiesRes = await dio.get('$baseUrl/proxies');
177+
return ProxyList.fromJson(proxiesRes.data);
178+
}
179+
180+
Future<RuleList> getRuleList() async {
181+
final rulesRes = await dio.get('$baseUrl/rules');
182+
return RuleList.fromJson(rulesRes.data);
183+
}
184+
185+
Future<void> selectProxy(String id) async {
186+
await dio.post('$baseUrl/selected/proxy', data: {'id': id});
187+
}
188+
189+
Future<void> selectRule(String id) async {
190+
await dio.post('$baseUrl/selected/rule', data: {'id': id});
191+
}
192+
193+
Future<ProxyMode> getMode() async {
194+
final setting = await dio.get('$baseUrl/setting');
195+
if (setting.data.containsKey('mode') && setting.data['mode'] is String) {
196+
if (setting.data['mode'] == 'tun') {
197+
return ProxyMode.tun;
198+
}
199+
if (setting.data['mode'] == 'system') {
200+
return ProxyMode.system;
201+
}
202+
}
203+
return ProxyMode.mixed;
204+
}
205+
153206
Future<void> exitCore() async {
154207
if (Platform.isWindows) {
155208
try {
@@ -178,3 +231,59 @@ class CoreManager {
178231
});
179232
}
180233
}
234+
235+
class ProxyItem {
236+
final String id;
237+
final String name;
238+
final String? server;
239+
final int? port;
240+
241+
ProxyItem(this.id, this.name, this.server, this.port);
242+
243+
ProxyItem.fromJson(Map<String, dynamic> json)
244+
: id = (json['id'] as String),
245+
name = (json['name'] as String),
246+
server = (json['server'] as String),
247+
port = (json['port'] as int);
248+
249+
Map<String, dynamic> toJson() => {
250+
'id': id,
251+
'name': name,
252+
};
253+
}
254+
255+
class ProxyList {
256+
final List<ProxyItem> proxies;
257+
String selectedId;
258+
259+
ProxyList(this.proxies, this.selectedId);
260+
261+
ProxyList.fromJson(Map<String, dynamic> json)
262+
: proxies = json['proxies'] != null
263+
? (json['proxies'] as List)
264+
.map((asset) =>
265+
ProxyItem.fromJson(asset as Map<String, dynamic>))
266+
.toList()
267+
: <ProxyItem>[],
268+
selectedId = (json['selectedId'] as String);
269+
270+
Map<String, dynamic> toJson() =>
271+
{'proxies': proxies.map((asset) => asset.toJson()).toList()};
272+
}
273+
274+
class RuleList {
275+
final List<String> rules;
276+
String selectedId;
277+
278+
RuleList(this.rules, this.selectedId);
279+
280+
RuleList.fromJson(Map<String, dynamic> json)
281+
: rules = json['rules'] != null
282+
? (json['rules'] as List).map((asset) => asset as String).toList()
283+
: <String>[],
284+
selectedId = (json['selectedId'] as String);
285+
286+
Map<String, dynamic> toJson() => {'rules': rules};
287+
}
288+
289+
enum ProxyMode { tun, system, mixed }

0 commit comments

Comments
 (0)