mirror of
https://github.com/foss42/apidash.git
synced 2025-12-03 03:17:00 +08:00
Refactor
This commit is contained in:
@@ -14,7 +14,6 @@ const kAssetSendingLottie = "assets/sending.json";
|
|||||||
const kAssetSavingLottie = "assets/saving.json";
|
const kAssetSavingLottie = "assets/saving.json";
|
||||||
const kAssetSavedLottie = "assets/completed.json";
|
const kAssetSavedLottie = "assets/completed.json";
|
||||||
|
|
||||||
|
|
||||||
final kIsMacOS = !kIsWeb && Platform.isMacOS;
|
final kIsMacOS = !kIsWeb && Platform.isMacOS;
|
||||||
final kIsWindows = !kIsWeb && Platform.isWindows;
|
final kIsWindows = !kIsWeb && Platform.isWindows;
|
||||||
final kIsLinux = !kIsWeb && Platform.isLinux;
|
final kIsLinux = !kIsWeb && Platform.isLinux;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:apidash_core/apidash_core.dart';
|
import 'package:apidash_core/apidash_core.dart';
|
||||||
//import 'package:apidash_core/services/no_ssl_http_service.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:apidash/consts.dart';
|
import 'package:apidash/consts.dart';
|
||||||
import 'providers.dart';
|
import 'providers.dart';
|
||||||
@@ -280,7 +279,7 @@ class CollectionStateNotifier
|
|||||||
requestId,
|
requestId,
|
||||||
substitutedHttpRequestModel,
|
substitutedHttpRequestModel,
|
||||||
defaultUriScheme: defaultUriScheme,
|
defaultUriScheme: defaultUriScheme,
|
||||||
noSSL: noSSL
|
noSSL: noSSL,
|
||||||
);
|
);
|
||||||
|
|
||||||
late final RequestModel newRequestModel;
|
late final RequestModel newRequestModel;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:apidash_design_system/apidash_design_system.dart';
|
import 'package:apidash_design_system/apidash_design_system.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import '../providers/providers.dart';
|
import '../providers/providers.dart';
|
||||||
import '../services/services.dart';
|
import '../services/services.dart';
|
||||||
import '../utils/utils.dart';
|
import '../utils/utils.dart';
|
||||||
@@ -25,9 +25,9 @@ class SettingsPage extends ConsumerWidget {
|
|||||||
child: kIsDesktop
|
child: kIsDesktop
|
||||||
? Text("Settings",
|
? Text("Settings",
|
||||||
style: Theme.of(context).textTheme.headlineLarge)
|
style: Theme.of(context).textTheme.headlineLarge)
|
||||||
: const SizedBox.shrink(),
|
: kSizedBoxEmpty,
|
||||||
)
|
)
|
||||||
: const SizedBox.shrink(),
|
: kSizedBoxEmpty,
|
||||||
kIsDesktop
|
kIsDesktop
|
||||||
? const Padding(
|
? const Padding(
|
||||||
padding: kPh20,
|
padding: kPh20,
|
||||||
@@ -35,24 +35,26 @@ class SettingsPage extends ConsumerWidget {
|
|||||||
height: 1,
|
height: 1,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: const SizedBox.shrink(),
|
: kSizedBoxEmpty,
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
children: [
|
children: [
|
||||||
|
!kIsWeb
|
||||||
!kIsWeb ?SwitchListTile(
|
? SwitchListTile(
|
||||||
hoverColor: kColorTransparent,
|
hoverColor: kColorTransparent,
|
||||||
title: const Text('Disabling SSL verification'),
|
title: const Text('Disable SSL verification'),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
'Current selection: ${settings.isSSLDisabled ? "SSL Verification Disabled" : "SSL Verification Enabled"}',
|
'Current selection: ${settings.isSSLDisabled ? "SSL Verification Disabled" : "SSL Verification Enabled"}',
|
||||||
),
|
),
|
||||||
value: settings.isSSLDisabled,
|
value: settings.isSSLDisabled,
|
||||||
onChanged: (bool? value) {
|
onChanged: (bool? value) {
|
||||||
ref.read(settingsProvider.notifier).update(isSSLDisabled: value ?? false);
|
ref
|
||||||
|
.read(settingsProvider.notifier)
|
||||||
|
.update(isSSLDisabled: value ?? false);
|
||||||
},
|
},
|
||||||
) :const SizedBox.shrink(),
|
)
|
||||||
|
: kSizedBoxEmpty,
|
||||||
SwitchListTile(
|
SwitchListTile(
|
||||||
hoverColor: kColorTransparent,
|
hoverColor: kColorTransparent,
|
||||||
title: const Text('Switch Theme Mode'),
|
title: const Text('Switch Theme Mode'),
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
import 'package:apidash_core/utils/http_request_utils.dart';
|
import 'dart:io';
|
||||||
|
import 'dart:collection';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'dart:collection';
|
import 'package:http/io_client.dart';
|
||||||
import '';
|
|
||||||
|
http.Client createHttpClientWithNoSSL() {
|
||||||
|
var ioClient = HttpClient()
|
||||||
|
..badCertificateCallback =
|
||||||
|
(X509Certificate cert, String host, int port) => true;
|
||||||
|
return IOClient(ioClient);
|
||||||
|
}
|
||||||
|
|
||||||
class HttpClientManager {
|
class HttpClientManager {
|
||||||
static final HttpClientManager _instance = HttpClientManager._internal();
|
static final HttpClientManager _instance = HttpClientManager._internal();
|
||||||
@@ -16,14 +23,16 @@ class HttpClientManager {
|
|||||||
|
|
||||||
HttpClientManager._internal();
|
HttpClientManager._internal();
|
||||||
|
|
||||||
http.Client createClient(String requestId,{bool noSSL = false}) {
|
http.Client createClient(
|
||||||
final client = noSSL && !kIsWeb ? createHttpClientWithNoSSL() :http.Client();
|
String requestId, {
|
||||||
|
bool noSSL = false,
|
||||||
|
}) {
|
||||||
|
final client =
|
||||||
|
(noSSL && !kIsWeb) ? createHttpClientWithNoSSL() : http.Client();
|
||||||
_clients[requestId] = client;
|
_clients[requestId] = client;
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cancelRequest(String? requestId) {
|
void cancelRequest(String? requestId) {
|
||||||
if (requestId != null && _clients.containsKey(requestId)) {
|
if (requestId != null && _clients.containsKey(requestId)) {
|
||||||
_clients[requestId]?.close();
|
_clients[requestId]?.close();
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ import '../utils/utils.dart';
|
|||||||
import 'http_client_manager.dart';
|
import 'http_client_manager.dart';
|
||||||
|
|
||||||
typedef HttpResponse = http.Response;
|
typedef HttpResponse = http.Response;
|
||||||
|
|
||||||
Future<(HttpResponse?, Duration?, String?)> request(
|
Future<(HttpResponse?, Duration?, String?)> request(
|
||||||
String requestId,
|
String requestId,
|
||||||
HttpRequestModel requestModel, {
|
HttpRequestModel requestModel, {
|
||||||
SupportedUriSchemes defaultUriScheme = kDefaultUriScheme,
|
SupportedUriSchemes defaultUriScheme = kDefaultUriScheme,
|
||||||
bool noSSL = false, // Add a parameter to specify SSL-bypass
|
bool noSSL = false,
|
||||||
}) async {
|
}) async {
|
||||||
final clientManager = HttpClientManager();
|
final clientManager = HttpClientManager();
|
||||||
final client = clientManager.createClient(requestId, noSSL: noSSL);
|
final client = clientManager.createClient(requestId, noSSL: noSSL);
|
||||||
@@ -73,7 +74,6 @@ Future<(HttpResponse?, Duration?, String?)> request(
|
|||||||
return (convertedMultiPartResponse, stopwatch.elapsed, null);
|
return (convertedMultiPartResponse, stopwatch.elapsed, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (requestModel.method) {
|
switch (requestModel.method) {
|
||||||
case HTTPVerb.get:
|
case HTTPVerb.get:
|
||||||
response = await client.get(requestUrl, headers: headers);
|
response = await client.get(requestUrl, headers: headers);
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
export 'http_client_manager.dart';
|
export 'http_client_manager.dart';
|
||||||
export 'http_service.dart';
|
export 'http_service.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,6 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:http/http.dart' as http;
|
|
||||||
import 'package:http/io_client.dart';
|
|
||||||
import 'package:seed/seed.dart';
|
import 'package:seed/seed.dart';
|
||||||
|
|
||||||
|
|
||||||
http.Client createHttpClientWithNoSSL() {
|
|
||||||
var ioClient = HttpClient()
|
|
||||||
..badCertificateCallback =
|
|
||||||
(X509Certificate cert, String host, int port) => true;
|
|
||||||
return IOClient(ioClient);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, String>? rowsToMap(
|
Map<String, String>? rowsToMap(
|
||||||
List<NameValueModel>? kvRows, {
|
List<NameValueModel>? kvRows, {
|
||||||
bool isHeader = false,
|
bool isHeader = false,
|
||||||
|
|||||||
Reference in New Issue
Block a user