mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-03-24 21:51:14 +03:00
fix: Optimize HTTP requests, refine translations, and fix dependencies
This commit is contained in:
@@ -1104,7 +1104,7 @@ class _NetworkState extends State<_Network> with AutomaticKeepAliveClientMixin {
|
||||
child: Column(children: [
|
||||
server(enabled),
|
||||
_Card(title: 'Proxy', children: [
|
||||
_Button("Socks5/Http(s) Proxy", changeSocks5Proxy,
|
||||
_Button('Socks5/Http(s) Proxy', changeSocks5Proxy,
|
||||
enabled: enabled),
|
||||
]),
|
||||
]),
|
||||
@@ -2034,7 +2034,7 @@ void changeSocks5Proxy() async {
|
||||
}
|
||||
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate("Socks5/Http(s) Proxy")),
|
||||
title: Text(translate('Socks5/Http(s) Proxy')),
|
||||
content: ConstrainedBox(
|
||||
constraints: const BoxConstraints(minWidth: 500),
|
||||
child: Column(
|
||||
@@ -2052,7 +2052,7 @@ void changeSocks5Proxy() async {
|
||||
child: TextField(
|
||||
decoration: InputDecoration(
|
||||
errorText: proxyMsg.isNotEmpty ? proxyMsg : null,
|
||||
hintText: translate("Default proxy protocol is socks5"),
|
||||
hintText: translate('Default protocol and port are Socks5 and 1080'),
|
||||
),
|
||||
controller: proxyController,
|
||||
autofocus: true,
|
||||
|
||||
@@ -17,7 +17,6 @@ bool refreshingUser = false;
|
||||
class UserModel {
|
||||
final RxString userName = ''.obs;
|
||||
final RxBool isAdmin = false.obs;
|
||||
|
||||
bool get isLogin => userName.isNotEmpty;
|
||||
WeakReference<FFI> parent;
|
||||
|
||||
|
||||
@@ -13,9 +13,6 @@ class HttpService {
|
||||
dynamic body,
|
||||
}) async {
|
||||
headers ??= {'Content-Type': 'application/json'};
|
||||
String headersJson = jsonEncode(headers);
|
||||
String methodName = method.toString().split('.').last;
|
||||
|
||||
// Determine if there is currently a proxy setting, and if so, use FFI to call the Rust HTTP method.
|
||||
final isProxy = await bind.mainGetProxyStatus();
|
||||
|
||||
@@ -23,13 +20,15 @@ class HttpService {
|
||||
return await _pollFultterHttp(url, method, headers: headers, body: body);
|
||||
}
|
||||
|
||||
String headersJson = jsonEncode(headers);
|
||||
String methodName = method.toString().split('.').last;
|
||||
await bind.mainHttpRequest(
|
||||
url: url.toString(),
|
||||
method: methodName.toLowerCase(),
|
||||
body: body,
|
||||
header: headersJson);
|
||||
|
||||
var resJson = await _pollForResponse();
|
||||
var resJson = await _pollForResponse(url.toString());
|
||||
return _parseHttpResponse(resJson);
|
||||
}
|
||||
|
||||
@@ -39,7 +38,7 @@ class HttpService {
|
||||
Map<String, String>? headers,
|
||||
dynamic body,
|
||||
}) async {
|
||||
var response = http.Response('', 400); // 默认响应
|
||||
var response = http.Response('', 400);
|
||||
|
||||
switch (method) {
|
||||
case HttpMethod.get:
|
||||
@@ -61,13 +60,18 @@ class HttpService {
|
||||
return response;
|
||||
}
|
||||
|
||||
Future<String> _pollForResponse() async {
|
||||
String responseJson = await bind.mainGetAsyncStatus();
|
||||
Future<String> _pollForResponse(String url) async {
|
||||
String? responseJson = " ";
|
||||
while (responseJson == " ") {
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
responseJson = await bind.mainGetAsyncStatus();
|
||||
responseJson = await bind.mainGetHttpStatus(url: url);
|
||||
if (responseJson == null) {
|
||||
throw Exception('The HTTP request failed');
|
||||
}
|
||||
if (responseJson == " ") {
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
}
|
||||
}
|
||||
return responseJson;
|
||||
return responseJson!;
|
||||
}
|
||||
|
||||
http.Response _parseHttpResponse(String responseJson) {
|
||||
|
||||
Reference in New Issue
Block a user