mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
use rhttp
This commit is contained in:
@@ -75,6 +75,9 @@ android {
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
ndk {
|
||||
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
|
||||
}
|
||||
signingConfig signingConfigs.release
|
||||
applicationVariants.all { variant ->
|
||||
variant.outputs.all { output ->
|
||||
|
@@ -3,7 +3,9 @@ import 'package:desktop_webview_window/desktop_webview_window.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:rhttp/rhttp.dart';
|
||||
import 'package:venera/foundation/log.dart';
|
||||
import 'package:venera/network/app_dio.dart';
|
||||
import 'package:venera/pages/comic_source_page.dart';
|
||||
import 'package:venera/pages/main_page.dart';
|
||||
import 'package:venera/pages/settings/settings_page.dart';
|
||||
@@ -20,6 +22,8 @@ void main(List<String> args) {
|
||||
return;
|
||||
}
|
||||
runZonedGuarded(() async {
|
||||
await Rhttp.init();
|
||||
AppDio.init();
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await init();
|
||||
if (App.isAndroid) {
|
||||
|
@@ -2,8 +2,9 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:dio/io.dart';
|
||||
import 'package:dio_compatibility_layer/dio_compatibility_layer.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:rhttp/rhttp.dart' as rhttp;
|
||||
import 'package:venera/foundation/appdata.dart';
|
||||
import 'package:venera/foundation/log.dart';
|
||||
import 'package:venera/network/cache.dart';
|
||||
@@ -106,10 +107,16 @@ class MyLogInterceptor implements Interceptor {
|
||||
class AppDio with DioMixin {
|
||||
String? _proxy = proxy;
|
||||
|
||||
static rhttp.RhttpCompatibleClient? _compatibleClient;
|
||||
|
||||
static void init() {
|
||||
_compatibleClient = rhttp.RhttpCompatibleClient.createSync();
|
||||
}
|
||||
|
||||
AppDio([BaseOptions? options]) {
|
||||
this.options = options ?? BaseOptions();
|
||||
interceptors.add(MyLogInterceptor());
|
||||
httpClientAdapter = IOHttpClientAdapter(createHttpClient: createHttpClient);
|
||||
httpClientAdapter = ConversionLayerAdapter(_compatibleClient!);
|
||||
interceptors.add(CookieManagerSql(SingleInstanceCookieJar.instance!));
|
||||
interceptors.add(NetworkCacheManager());
|
||||
interceptors.add(CloudflareInterceptor());
|
||||
@@ -136,8 +143,9 @@ class AppDio with DioMixin {
|
||||
static String? proxy;
|
||||
|
||||
static Future<String?> getProxy() async {
|
||||
if ((appdata.settings['proxy'] as String).removeAllBlank == "direct")
|
||||
if ((appdata.settings['proxy'] as String).removeAllBlank == "direct") {
|
||||
return null;
|
||||
}
|
||||
if (appdata.settings['proxy'] != "system") return appdata.settings['proxy'];
|
||||
|
||||
String res;
|
||||
@@ -187,10 +195,22 @@ class AppDio with DioMixin {
|
||||
}) async {
|
||||
proxy = await getProxy();
|
||||
if (_proxy != proxy) {
|
||||
Log.info("Network", "Proxy changed to $proxy");
|
||||
_proxy = proxy;
|
||||
(httpClientAdapter as IOHttpClientAdapter).close();
|
||||
httpClientAdapter =
|
||||
IOHttpClientAdapter(createHttpClient: createHttpClient);
|
||||
(httpClientAdapter as ConversionLayerAdapter).close();
|
||||
_compatibleClient = await rhttp.RhttpCompatibleClient.create(
|
||||
settings: rhttp.ClientSettings(
|
||||
proxySettings: proxy == null
|
||||
? const rhttp.ProxySettings.noProxy()
|
||||
: rhttp.ProxySettings.proxy(proxy!),
|
||||
timeoutSettings: const rhttp.TimeoutSettings(
|
||||
connectTimeout: Duration(seconds: 15),
|
||||
keepAliveTimeout: Duration(seconds: 60),
|
||||
keepAlivePing: Duration(seconds: 30),
|
||||
),
|
||||
),
|
||||
);
|
||||
httpClientAdapter = ConversionLayerAdapter(_compatibleClient!);
|
||||
}
|
||||
Log.info(
|
||||
"Network",
|
||||
|
@@ -15,6 +15,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
lodepng_flutter
|
||||
rhttp
|
||||
zip_flutter
|
||||
)
|
||||
|
||||
|
56
pubspec.lock
56
pubspec.lock
@@ -57,6 +57,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
build_cli_annotations:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build_cli_annotations
|
||||
sha256: b59d2769769efd6c9ff6d4c4cede0be115a566afc591705c2040b707534b1172
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -130,6 +138,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.7.0"
|
||||
dio_compatibility_layer:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: dio_compatibility_layer
|
||||
sha256: bb7ea1dd6fe98b8f5e3d90da408802fc3abf14d4485416e882cf1b2c8fb4b209
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.0"
|
||||
dio_web_adapter:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -341,6 +357,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.0.1"
|
||||
flutter_rust_bridge:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_rust_bridge
|
||||
sha256: "5fe868d3cb8cbc4d83091748552e03f00ccfa41b8e44691bc382611f831d5f8b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.5.1"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
@@ -368,6 +392,14 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
freezed_annotation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: freezed_annotation
|
||||
sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.4"
|
||||
gtk:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -424,6 +456,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.1"
|
||||
json_annotation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: json_annotation
|
||||
sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.9.0"
|
||||
leak_tracker:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -459,11 +499,9 @@ packages:
|
||||
lodepng_flutter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: HEAD
|
||||
resolved-ref: "5223cf4ce8aad1c2315db0093db3cc5c6c7191a8"
|
||||
url: "https://github.com/venera-app/lodepng_flutter"
|
||||
source: git
|
||||
path: "C:\\Users\\wgh19\\IdeaProjects\\lodepng_flutter"
|
||||
relative: false
|
||||
source: path
|
||||
version: "0.0.1"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
@@ -594,6 +632,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.9.1"
|
||||
rhttp:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: rhttp
|
||||
sha256: "92fb57dea6338370efe1e4e2101e8b521f91f15bc60ef6908469b4392dd9803a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.1"
|
||||
screen_retriever:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@@ -57,6 +57,8 @@ dependencies:
|
||||
lodepng_flutter:
|
||||
git:
|
||||
url: https://github.com/venera-app/lodepng_flutter
|
||||
rhttp: 0.9.1
|
||||
dio_compatibility_layer: ^0.1.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
@@ -17,6 +17,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
lodepng_flutter
|
||||
rhttp
|
||||
zip_flutter
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user