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 {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
ndk {
|
||||||
|
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
|
||||||
|
}
|
||||||
signingConfig signingConfigs.release
|
signingConfig signingConfigs.release
|
||||||
applicationVariants.all { variant ->
|
applicationVariants.all { variant ->
|
||||||
variant.outputs.all { output ->
|
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/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
|
import 'package:rhttp/rhttp.dart';
|
||||||
import 'package:venera/foundation/log.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/comic_source_page.dart';
|
||||||
import 'package:venera/pages/main_page.dart';
|
import 'package:venera/pages/main_page.dart';
|
||||||
import 'package:venera/pages/settings/settings_page.dart';
|
import 'package:venera/pages/settings/settings_page.dart';
|
||||||
@@ -20,6 +22,8 @@ void main(List<String> args) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
runZonedGuarded(() async {
|
runZonedGuarded(() async {
|
||||||
|
await Rhttp.init();
|
||||||
|
AppDio.init();
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await init();
|
await init();
|
||||||
if (App.isAndroid) {
|
if (App.isAndroid) {
|
||||||
|
@@ -2,8 +2,9 @@ import 'dart:convert';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
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:flutter/services.dart';
|
||||||
|
import 'package:rhttp/rhttp.dart' as rhttp;
|
||||||
import 'package:venera/foundation/appdata.dart';
|
import 'package:venera/foundation/appdata.dart';
|
||||||
import 'package:venera/foundation/log.dart';
|
import 'package:venera/foundation/log.dart';
|
||||||
import 'package:venera/network/cache.dart';
|
import 'package:venera/network/cache.dart';
|
||||||
@@ -106,10 +107,16 @@ class MyLogInterceptor implements Interceptor {
|
|||||||
class AppDio with DioMixin {
|
class AppDio with DioMixin {
|
||||||
String? _proxy = proxy;
|
String? _proxy = proxy;
|
||||||
|
|
||||||
|
static rhttp.RhttpCompatibleClient? _compatibleClient;
|
||||||
|
|
||||||
|
static void init() {
|
||||||
|
_compatibleClient = rhttp.RhttpCompatibleClient.createSync();
|
||||||
|
}
|
||||||
|
|
||||||
AppDio([BaseOptions? options]) {
|
AppDio([BaseOptions? options]) {
|
||||||
this.options = options ?? BaseOptions();
|
this.options = options ?? BaseOptions();
|
||||||
interceptors.add(MyLogInterceptor());
|
interceptors.add(MyLogInterceptor());
|
||||||
httpClientAdapter = IOHttpClientAdapter(createHttpClient: createHttpClient);
|
httpClientAdapter = ConversionLayerAdapter(_compatibleClient!);
|
||||||
interceptors.add(CookieManagerSql(SingleInstanceCookieJar.instance!));
|
interceptors.add(CookieManagerSql(SingleInstanceCookieJar.instance!));
|
||||||
interceptors.add(NetworkCacheManager());
|
interceptors.add(NetworkCacheManager());
|
||||||
interceptors.add(CloudflareInterceptor());
|
interceptors.add(CloudflareInterceptor());
|
||||||
@@ -136,8 +143,9 @@ class AppDio with DioMixin {
|
|||||||
static String? proxy;
|
static String? proxy;
|
||||||
|
|
||||||
static Future<String?> getProxy() async {
|
static Future<String?> getProxy() async {
|
||||||
if ((appdata.settings['proxy'] as String).removeAllBlank == "direct")
|
if ((appdata.settings['proxy'] as String).removeAllBlank == "direct") {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
if (appdata.settings['proxy'] != "system") return appdata.settings['proxy'];
|
if (appdata.settings['proxy'] != "system") return appdata.settings['proxy'];
|
||||||
|
|
||||||
String res;
|
String res;
|
||||||
@@ -187,10 +195,22 @@ class AppDio with DioMixin {
|
|||||||
}) async {
|
}) async {
|
||||||
proxy = await getProxy();
|
proxy = await getProxy();
|
||||||
if (_proxy != proxy) {
|
if (_proxy != proxy) {
|
||||||
|
Log.info("Network", "Proxy changed to $proxy");
|
||||||
_proxy = proxy;
|
_proxy = proxy;
|
||||||
(httpClientAdapter as IOHttpClientAdapter).close();
|
(httpClientAdapter as ConversionLayerAdapter).close();
|
||||||
httpClientAdapter =
|
_compatibleClient = await rhttp.RhttpCompatibleClient.create(
|
||||||
IOHttpClientAdapter(createHttpClient: createHttpClient);
|
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(
|
Log.info(
|
||||||
"Network",
|
"Network",
|
||||||
|
@@ -15,6 +15,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
|||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
lodepng_flutter
|
lodepng_flutter
|
||||||
|
rhttp
|
||||||
zip_flutter
|
zip_flutter
|
||||||
)
|
)
|
||||||
|
|
||||||
|
56
pubspec.lock
56
pubspec.lock
@@ -57,6 +57,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
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:
|
characters:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -130,6 +138,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.7.0"
|
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:
|
dio_web_adapter:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -341,6 +357,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.0.1"
|
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:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -368,6 +392,14 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
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:
|
gtk:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -424,6 +456,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.1"
|
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:
|
leak_tracker:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -459,11 +499,9 @@ packages:
|
|||||||
lodepng_flutter:
|
lodepng_flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "C:\\Users\\wgh19\\IdeaProjects\\lodepng_flutter"
|
||||||
ref: HEAD
|
relative: false
|
||||||
resolved-ref: "5223cf4ce8aad1c2315db0093db3cc5c6c7191a8"
|
source: path
|
||||||
url: "https://github.com/venera-app/lodepng_flutter"
|
|
||||||
source: git
|
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
@@ -594,6 +632,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.9.1"
|
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:
|
screen_retriever:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@@ -57,6 +57,8 @@ dependencies:
|
|||||||
lodepng_flutter:
|
lodepng_flutter:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/venera-app/lodepng_flutter
|
url: https://github.com/venera-app/lodepng_flutter
|
||||||
|
rhttp: 0.9.1
|
||||||
|
dio_compatibility_layer: ^0.1.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
@@ -17,6 +17,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
|||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
lodepng_flutter
|
lodepng_flutter
|
||||||
|
rhttp
|
||||||
zip_flutter
|
zip_flutter
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user