mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-18 14:23:42 +00:00
setting ui
This commit is contained in:
1 parent
5134446c3f
commit
91ac841b9d
12 files changed
+115
-40
No files matched your search
@@ -168,6 +168,7 @@ func (cfg *DownloaderProxyConfig) ToHandler() func(r *http.Request) (*url.URL, e
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if cfg.System {
|
if cfg.System {
|
||||||
|
ieproxy.ReloadConf()
|
||||||
return ieproxy.GetProxyFunc()
|
return ieproxy.GetProxyFunc()
|
||||||
}
|
}
|
||||||
if cfg.Scheme == "" || cfg.Host == "" {
|
if cfg.Scheme == "" || cfg.Host == "" {
|
||||||
@@ -182,6 +183,7 @@ func (cfg *DownloaderProxyConfig) ToUrl() *url.URL {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if cfg.System {
|
if cfg.System {
|
||||||
|
ieproxy.ReloadConf()
|
||||||
static := ieproxy.GetConf().Static
|
static := ieproxy.GetConf().Static
|
||||||
if static.Active && len(static.Protocols) > 0 {
|
if static.Active && len(static.Protocols) > 0 {
|
||||||
// If only one protocol, use it
|
// If only one protocol, use it
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ class ExtraConfig {
|
|||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
class ProxyConfig {
|
class ProxyConfig {
|
||||||
bool enable;
|
bool enable;
|
||||||
|
bool system;
|
||||||
String scheme;
|
String scheme;
|
||||||
String host;
|
String host;
|
||||||
String usr;
|
String usr;
|
||||||
@@ -85,6 +86,7 @@ class ProxyConfig {
|
|||||||
|
|
||||||
ProxyConfig({
|
ProxyConfig({
|
||||||
this.enable = false,
|
this.enable = false,
|
||||||
|
this.system = false,
|
||||||
this.scheme = '',
|
this.scheme = '',
|
||||||
this.host = '',
|
this.host = '',
|
||||||
this.usr = '',
|
this.usr = '',
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ part of 'downloader_config.dart';
|
|||||||
DownloaderConfig _$DownloaderConfigFromJson(Map<String, dynamic> json) =>
|
DownloaderConfig _$DownloaderConfigFromJson(Map<String, dynamic> json) =>
|
||||||
DownloaderConfig(
|
DownloaderConfig(
|
||||||
downloadDir: json['downloadDir'] as String? ?? '',
|
downloadDir: json['downloadDir'] as String? ?? '',
|
||||||
maxRunning: json['maxRunning'] as int? ?? 0,
|
maxRunning: (json['maxRunning'] as num?)?.toInt() ?? 0,
|
||||||
)
|
)
|
||||||
..protocolConfig = ProtocolConfig.fromJson(
|
..protocolConfig = ProtocolConfig.fromJson(
|
||||||
json['protocolConfig'] as Map<String, dynamic>?)
|
json['protocolConfig'] as Map<String, dynamic>?)
|
||||||
@@ -39,7 +39,7 @@ Map<String, dynamic> _$ProtocolConfigToJson(ProtocolConfig instance) =>
|
|||||||
HttpConfig _$HttpConfigFromJson(Map<String, dynamic> json) => HttpConfig(
|
HttpConfig _$HttpConfigFromJson(Map<String, dynamic> json) => HttpConfig(
|
||||||
userAgent: json['userAgent'] as String? ??
|
userAgent: json['userAgent'] as String? ??
|
||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36',
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36',
|
||||||
connections: json['connections'] as int? ?? 16,
|
connections: (json['connections'] as num?)?.toInt() ?? 16,
|
||||||
useServerCtime: json['useServerCtime'] as bool? ?? false,
|
useServerCtime: json['useServerCtime'] as bool? ?? false,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ Map<String, dynamic> _$HttpConfigToJson(HttpConfig instance) =>
|
|||||||
};
|
};
|
||||||
|
|
||||||
BtConfig _$BtConfigFromJson(Map<String, dynamic> json) => BtConfig()
|
BtConfig _$BtConfigFromJson(Map<String, dynamic> json) => BtConfig()
|
||||||
..listenPort = json['listenPort'] as int
|
..listenPort = (json['listenPort'] as num).toInt()
|
||||||
..trackers =
|
..trackers =
|
||||||
(json['trackers'] as List<dynamic>).map((e) => e as String).toList();
|
(json['trackers'] as List<dynamic>).map((e) => e as String).toList();
|
||||||
|
|
||||||
@@ -74,6 +74,7 @@ Map<String, dynamic> _$ExtraConfigToJson(ExtraConfig instance) =>
|
|||||||
|
|
||||||
ProxyConfig _$ProxyConfigFromJson(Map<String, dynamic> json) => ProxyConfig(
|
ProxyConfig _$ProxyConfigFromJson(Map<String, dynamic> json) => ProxyConfig(
|
||||||
enable: json['enable'] as bool? ?? false,
|
enable: json['enable'] as bool? ?? false,
|
||||||
|
system: json['system'] as bool? ?? false,
|
||||||
scheme: json['scheme'] as String? ?? '',
|
scheme: json['scheme'] as String? ?? '',
|
||||||
host: json['host'] as String? ?? '',
|
host: json['host'] as String? ?? '',
|
||||||
usr: json['usr'] as String? ?? '',
|
usr: json['usr'] as String? ?? '',
|
||||||
@@ -83,6 +84,7 @@ ProxyConfig _$ProxyConfigFromJson(Map<String, dynamic> json) => ProxyConfig(
|
|||||||
Map<String, dynamic> _$ProxyConfigToJson(ProxyConfig instance) =>
|
Map<String, dynamic> _$ProxyConfigToJson(ProxyConfig instance) =>
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'enable': instance.enable,
|
'enable': instance.enable,
|
||||||
|
'system': instance.system,
|
||||||
'scheme': instance.scheme,
|
'scheme': instance.scheme,
|
||||||
'host': instance.host,
|
'host': instance.host,
|
||||||
'usr': instance.usr,
|
'usr': instance.usr,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ Options _$OptionsFromJson(Map<String, dynamic> json) => Options(
|
|||||||
name: json['name'] as String,
|
name: json['name'] as String,
|
||||||
path: json['path'] as String,
|
path: json['path'] as String,
|
||||||
selectFiles: (json['selectFiles'] as List<dynamic>?)
|
selectFiles: (json['selectFiles'] as List<dynamic>?)
|
||||||
?.map((e) => e as int)
|
?.map((e) => (e as num).toInt())
|
||||||
.toList() ??
|
.toList() ??
|
||||||
const [],
|
const [],
|
||||||
extra: json['extra'],
|
extra: json['extra'],
|
||||||
@@ -35,7 +35,7 @@ Map<String, dynamic> _$OptionsToJson(Options instance) {
|
|||||||
|
|
||||||
OptsExtraHttp _$OptsExtraHttpFromJson(Map<String, dynamic> json) =>
|
OptsExtraHttp _$OptsExtraHttpFromJson(Map<String, dynamic> json) =>
|
||||||
OptsExtraHttp()
|
OptsExtraHttp()
|
||||||
..connections = json['connections'] as int
|
..connections = (json['connections'] as num).toInt()
|
||||||
..autoTorrent = json['autoTorrent'] as bool;
|
..autoTorrent = json['autoTorrent'] as bool;
|
||||||
|
|
||||||
Map<String, dynamic> _$OptsExtraHttpToJson(OptsExtraHttp instance) =>
|
Map<String, dynamic> _$OptsExtraHttpToJson(OptsExtraHttp instance) =>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ part of 'resource.dart';
|
|||||||
|
|
||||||
Resource _$ResourceFromJson(Map<String, dynamic> json) => Resource(
|
Resource _$ResourceFromJson(Map<String, dynamic> json) => Resource(
|
||||||
name: json['name'] as String? ?? "",
|
name: json['name'] as String? ?? "",
|
||||||
size: json['size'] as int? ?? 0,
|
size: (json['size'] as num?)?.toInt() ?? 0,
|
||||||
range: json['range'] as bool? ?? false,
|
range: json['range'] as bool? ?? false,
|
||||||
files: (json['files'] as List<dynamic>)
|
files: (json['files'] as List<dynamic>)
|
||||||
.map((e) => FileInfo.fromJson(e as Map<String, dynamic>))
|
.map((e) => FileInfo.fromJson(e as Map<String, dynamic>))
|
||||||
@@ -27,7 +27,7 @@ Map<String, dynamic> _$ResourceToJson(Resource instance) => <String, dynamic>{
|
|||||||
FileInfo _$FileInfoFromJson(Map<String, dynamic> json) => FileInfo(
|
FileInfo _$FileInfoFromJson(Map<String, dynamic> json) => FileInfo(
|
||||||
path: json['path'] as String? ?? "",
|
path: json['path'] as String? ?? "",
|
||||||
name: json['name'] as String,
|
name: json['name'] as String,
|
||||||
size: json['size'] as int? ?? 0,
|
size: (json['size'] as num?)?.toInt() ?? 0,
|
||||||
req: json['req'] == null
|
req: json['req'] == null
|
||||||
? null
|
? null
|
||||||
: Request.fromJson(json['req'] as Map<String, dynamic>),
|
: Request.fromJson(json['req'] as Map<String, dynamic>),
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Result<T> _$ResultFromJson<T>(
|
|||||||
T Function(Object? json) fromJsonT,
|
T Function(Object? json) fromJsonT,
|
||||||
) =>
|
) =>
|
||||||
Result<T>(
|
Result<T>(
|
||||||
code: json['code'] as int,
|
code: (json['code'] as num).toInt(),
|
||||||
msg: json['msg'] as String?,
|
msg: json['msg'] as String?,
|
||||||
data: _$nullableGenericFromJson(json['data'], fromJsonT),
|
data: _$nullableGenericFromJson(json['data'], fromJsonT),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ const _$StatusEnumMap = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Progress _$ProgressFromJson(Map<String, dynamic> json) => Progress(
|
Progress _$ProgressFromJson(Map<String, dynamic> json) => Progress(
|
||||||
used: json['used'] as int,
|
used: (json['used'] as num).toInt(),
|
||||||
speed: json['speed'] as int,
|
speed: (json['speed'] as num).toInt(),
|
||||||
downloaded: json['downloaded'] as int,
|
downloaded: (json['downloaded'] as num).toInt(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$ProgressToJson(Progress instance) => <String, dynamic>{
|
Map<String, dynamic> _$ProgressToJson(Progress instance) => <String, dynamic>{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
|
import '../../../../api/model/downloader_config.dart';
|
||||||
import '../../../../i18n/message.dart';
|
import '../../../../i18n/message.dart';
|
||||||
import '../../../../util/input_formatter.dart';
|
import '../../../../util/input_formatter.dart';
|
||||||
import '../../../../util/locale_manager.dart';
|
import '../../../../util/locale_manager.dart';
|
||||||
@@ -408,29 +409,53 @@ class SettingView extends GetView<SettingController> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// advanced config proxy items start
|
// advanced config proxy items start
|
||||||
|
final proxy = downloaderCfg.value.proxy;
|
||||||
final buildProxy = _buildConfigItem(
|
final buildProxy = _buildConfigItem(
|
||||||
'proxy',
|
'proxy',
|
||||||
() => downloaderCfg.value.proxy.enable
|
() {
|
||||||
? '${downloaderCfg.value.proxy.scheme}://${downloaderCfg.value.proxy.host}'
|
switch (proxy.proxyMode) {
|
||||||
: 'notSet'.tr,
|
case ProxyModeEnum.noProxy:
|
||||||
|
return 'noProxy'.tr;
|
||||||
|
case ProxyModeEnum.systemProxy:
|
||||||
|
return 'systemProxy'.tr;
|
||||||
|
case ProxyModeEnum.customProxy:
|
||||||
|
return '${downloaderCfg.value.proxy.scheme}://${downloaderCfg.value.proxy.host}';
|
||||||
|
}
|
||||||
|
},
|
||||||
(Key key) {
|
(Key key) {
|
||||||
final proxy = downloaderCfg.value.proxy;
|
final mode = SizedBox(
|
||||||
|
width: 150,
|
||||||
|
child: DropdownButtonFormField<ProxyModeEnum>(
|
||||||
|
value: proxy.proxyMode,
|
||||||
|
onChanged: (value) async {
|
||||||
|
if (value != null && value != proxy.proxyMode) {
|
||||||
|
proxy.proxyMode = value;
|
||||||
|
downloaderCfg.update((val) {
|
||||||
|
val!.proxy = proxy;
|
||||||
|
});
|
||||||
|
|
||||||
final switcher = Switch(
|
await debounceSave();
|
||||||
value: proxy.enable,
|
}
|
||||||
onChanged: (bool value) async {
|
},
|
||||||
if (value != proxy.enable) {
|
items: [
|
||||||
downloaderCfg.update((val) {
|
DropdownMenuItem<ProxyModeEnum>(
|
||||||
val!.proxy.enable = value;
|
value: ProxyModeEnum.noProxy,
|
||||||
});
|
child: Text('noProxy'.tr),
|
||||||
|
),
|
||||||
await debounceSave();
|
DropdownMenuItem<ProxyModeEnum>(
|
||||||
}
|
value: ProxyModeEnum.systemProxy,
|
||||||
},
|
child: Text('systemProxy'.tr),
|
||||||
|
),
|
||||||
|
DropdownMenuItem<ProxyModeEnum>(
|
||||||
|
value: ProxyModeEnum.customProxy,
|
||||||
|
child: Text('customProxy'.tr),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final scheme = SizedBox(
|
final scheme = SizedBox(
|
||||||
width: 100,
|
width: 150,
|
||||||
child: DropdownButtonFormField<String>(
|
child: DropdownButtonFormField<String>(
|
||||||
value: proxy.scheme,
|
value: proxy.scheme,
|
||||||
onChanged: (value) async {
|
onChanged: (value) async {
|
||||||
@@ -478,7 +503,7 @@ class SettingView extends GetView<SettingController> {
|
|||||||
|
|
||||||
ipController.addListener(updateAddress);
|
ipController.addListener(updateAddress);
|
||||||
portController.addListener(updateAddress);
|
portController.addListener(updateAddress);
|
||||||
final server = [
|
final server = Row(children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
controller: ipController,
|
controller: ipController,
|
||||||
@@ -503,12 +528,12 @@ class SettingView extends GetView<SettingController> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
];
|
]);
|
||||||
|
|
||||||
final usrController = TextEditingController(text: proxy.usr);
|
final usrController = TextEditingController(text: proxy.usr);
|
||||||
final pwdController = TextEditingController(text: proxy.pwd);
|
final pwdController = TextEditingController(text: proxy.pwd);
|
||||||
|
|
||||||
final auth = [
|
final auth = Row(children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
controller: usrController,
|
controller: usrController,
|
||||||
@@ -528,20 +553,21 @@ class SettingView extends GetView<SettingController> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
];
|
]);
|
||||||
|
|
||||||
|
List<Widget> customView() {
|
||||||
|
if (proxy.proxyMode != ProxyModeEnum.customProxy) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return [scheme, server, auth];
|
||||||
|
}
|
||||||
|
|
||||||
return Form(
|
return Form(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: _addPadding([
|
children: _addPadding([
|
||||||
switcher,
|
mode,
|
||||||
scheme,
|
...customView(),
|
||||||
Row(
|
|
||||||
children: server,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
children: auth,
|
|
||||||
),
|
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -857,3 +883,37 @@ class SettingView extends GetView<SettingController> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ProxyModeEnum {
|
||||||
|
noProxy,
|
||||||
|
systemProxy,
|
||||||
|
customProxy,
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ProxyMode on ProxyConfig {
|
||||||
|
ProxyModeEnum get proxyMode {
|
||||||
|
if (!enable) {
|
||||||
|
return ProxyModeEnum.noProxy;
|
||||||
|
}
|
||||||
|
if (system) {
|
||||||
|
return ProxyModeEnum.systemProxy;
|
||||||
|
}
|
||||||
|
return ProxyModeEnum.customProxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
set proxyMode(ProxyModeEnum value) {
|
||||||
|
switch (value) {
|
||||||
|
case ProxyModeEnum.noProxy:
|
||||||
|
enable = false;
|
||||||
|
break;
|
||||||
|
case ProxyModeEnum.systemProxy:
|
||||||
|
enable = true;
|
||||||
|
system = true;
|
||||||
|
break;
|
||||||
|
case ProxyModeEnum.customProxy:
|
||||||
|
enable = true;
|
||||||
|
system = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ StartConfig _$StartConfigFromJson(Map<String, dynamic> json) => StartConfig()
|
|||||||
..address = json['address'] as String
|
..address = json['address'] as String
|
||||||
..storage = json['storage'] as String
|
..storage = json['storage'] as String
|
||||||
..storageDir = json['storageDir'] as String
|
..storageDir = json['storageDir'] as String
|
||||||
..refreshInterval = json['refreshInterval'] as int
|
..refreshInterval = (json['refreshInterval'] as num).toInt()
|
||||||
..apiToken = json['apiToken'] as String;
|
..apiToken = json['apiToken'] as String;
|
||||||
|
|
||||||
Map<String, dynamic> _$StartConfigToJson(StartConfig instance) =>
|
Map<String, dynamic> _$StartConfigToJson(StartConfig instance) =>
|
||||||
|
|||||||
@@ -82,6 +82,9 @@ const enUS = {
|
|||||||
'serviceText': 'Running',
|
'serviceText': 'Running',
|
||||||
'network': 'Network',
|
'network': 'Network',
|
||||||
'proxy': 'Proxy',
|
'proxy': 'Proxy',
|
||||||
|
'noProxy': 'No Proxy',
|
||||||
|
'systemProxy': 'System Proxy',
|
||||||
|
'customProxy': 'Custom Proxy',
|
||||||
'server': 'Server',
|
'server': 'Server',
|
||||||
'username': 'Username',
|
'username': 'Username',
|
||||||
'password': 'Password',
|
'password': 'Password',
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ const zhCN = {
|
|||||||
'serviceText': '运行中',
|
'serviceText': '运行中',
|
||||||
'network': '网络',
|
'network': '网络',
|
||||||
'proxy': '代理',
|
'proxy': '代理',
|
||||||
|
'noProxy': '不使用代理',
|
||||||
|
'systemProxy': '系统代理',
|
||||||
|
'customProxy': '自定义代理',
|
||||||
'server': '服务器',
|
'server': '服务器',
|
||||||
'username': '用户名',
|
'username': '用户名',
|
||||||
'password': '密码',
|
'password': '密码',
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ const zhTW = {
|
|||||||
'serviceText': '執行中',
|
'serviceText': '執行中',
|
||||||
'network': '網路',
|
'network': '網路',
|
||||||
'proxy': '代理',
|
'proxy': '代理',
|
||||||
|
'noProxy': '不使用代理',
|
||||||
|
'systemProxy': '系統代理',
|
||||||
|
'customProxy': '自定義代理',
|
||||||
'server': '伺服器',
|
'server': '伺服器',
|
||||||
'username': '名稱',
|
'username': '名稱',
|
||||||
'password': '密碼',
|
'password': '密碼',
|
||||||
|
|||||||
Reference in new issue
Block a user