feat: 代理设置
This commit is contained in:
@ -37,6 +37,8 @@ PODS:
|
|||||||
- FMDB (>= 2.7.5)
|
- FMDB (>= 2.7.5)
|
||||||
- status_bar_control (3.2.1):
|
- status_bar_control (3.2.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
|
- system_proxy (0.0.1):
|
||||||
|
- Flutter
|
||||||
- url_launcher_ios (0.0.1):
|
- url_launcher_ios (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- volume_controller (0.0.1):
|
- volume_controller (0.0.1):
|
||||||
@ -65,6 +67,7 @@ DEPENDENCIES:
|
|||||||
- share_plus (from `.symlinks/plugins/share_plus/ios`)
|
- share_plus (from `.symlinks/plugins/share_plus/ios`)
|
||||||
- sqflite (from `.symlinks/plugins/sqflite/ios`)
|
- sqflite (from `.symlinks/plugins/sqflite/ios`)
|
||||||
- status_bar_control (from `.symlinks/plugins/status_bar_control/ios`)
|
- status_bar_control (from `.symlinks/plugins/status_bar_control/ios`)
|
||||||
|
- system_proxy (from `.symlinks/plugins/system_proxy/ios`)
|
||||||
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
|
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
|
||||||
- volume_controller (from `.symlinks/plugins/volume_controller/ios`)
|
- volume_controller (from `.symlinks/plugins/volume_controller/ios`)
|
||||||
- wakelock_plus (from `.symlinks/plugins/wakelock_plus/ios`)
|
- wakelock_plus (from `.symlinks/plugins/wakelock_plus/ios`)
|
||||||
@ -109,6 +112,8 @@ EXTERNAL SOURCES:
|
|||||||
:path: ".symlinks/plugins/sqflite/ios"
|
:path: ".symlinks/plugins/sqflite/ios"
|
||||||
status_bar_control:
|
status_bar_control:
|
||||||
:path: ".symlinks/plugins/status_bar_control/ios"
|
:path: ".symlinks/plugins/status_bar_control/ios"
|
||||||
|
system_proxy:
|
||||||
|
:path: ".symlinks/plugins/system_proxy/ios"
|
||||||
url_launcher_ios:
|
url_launcher_ios:
|
||||||
:path: ".symlinks/plugins/url_launcher_ios/ios"
|
:path: ".symlinks/plugins/url_launcher_ios/ios"
|
||||||
volume_controller:
|
volume_controller:
|
||||||
@ -139,6 +144,7 @@ SPEC CHECKSUMS:
|
|||||||
share_plus: 599aa54e4ea31d4b4c0e9c911bcc26c55e791028
|
share_plus: 599aa54e4ea31d4b4c0e9c911bcc26c55e791028
|
||||||
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
|
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
|
||||||
status_bar_control: 7c84146799e6a076315cc1550f78ef53aae3e446
|
status_bar_control: 7c84146799e6a076315cc1550f78ef53aae3e446
|
||||||
|
system_proxy: bec1a5c5af67dd3e3ebf43979400a8756c04cc44
|
||||||
url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4
|
url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4
|
||||||
volume_controller: 531ddf792994285c9b17f9d8a7e4dcdd29b3eae9
|
volume_controller: 531ddf792994285c9b17f9d8a7e4dcdd29b3eae9
|
||||||
wakelock_plus: 8b09852c8876491e4b6d179e17dfe2a0b5f60d47
|
wakelock_plus: 8b09852c8876491e4b6d179e17dfe2a0b5f60d47
|
||||||
|
@ -15,6 +15,7 @@ import 'package:pilipala/router/app_pages.dart';
|
|||||||
import 'package:pilipala/pages/main/view.dart';
|
import 'package:pilipala/pages/main/view.dart';
|
||||||
import 'package:pilipala/utils/app_scheme.dart';
|
import 'package:pilipala/utils/app_scheme.dart';
|
||||||
import 'package:pilipala/utils/data.dart';
|
import 'package:pilipala/utils/data.dart';
|
||||||
|
import 'package:pilipala/utils/proxy.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import 'package:media_kit/media_kit.dart'; // Provides [Player], [Media], [Playlist] etc.
|
import 'package:media_kit/media_kit.dart'; // Provides [Player], [Media], [Playlist] etc.
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ void main() async {
|
|||||||
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown])
|
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown])
|
||||||
.then((_) async {
|
.then((_) async {
|
||||||
await GStrorage.init();
|
await GStrorage.init();
|
||||||
|
CustomProxy().init();
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
// 小白条、导航栏沉浸
|
// 小白条、导航栏沉浸
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||||
|
26
lib/utils/proxy.dart
Normal file
26
lib/utils/proxy.dart
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
import 'package:system_proxy/system_proxy.dart';
|
||||||
|
|
||||||
|
class CustomProxy {
|
||||||
|
init() async{
|
||||||
|
Map<String, String>? proxy = await SystemProxy.getProxySettings();
|
||||||
|
if (proxy != null) {
|
||||||
|
HttpOverrides.global = ProxiedHttpOverrides(proxy['host']!, proxy['port']!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class ProxiedHttpOverrides extends HttpOverrides {
|
||||||
|
final String _port;
|
||||||
|
final String _host;
|
||||||
|
|
||||||
|
ProxiedHttpOverrides(this._host, this._port);
|
||||||
|
|
||||||
|
@override
|
||||||
|
HttpClient createHttpClient(SecurityContext? context) {
|
||||||
|
return super.createHttpClient(context)
|
||||||
|
// set proxy
|
||||||
|
..findProxy = (uri) {
|
||||||
|
return "PROXY $_host:$_port;";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -1211,6 +1211,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.0"
|
version: "3.1.0"
|
||||||
|
system_proxy:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: system_proxy
|
||||||
|
sha256: bbdfc9736a963409941fb0e7c494606c1f13c2be34de15833ee385da83cf7ab0
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.0"
|
||||||
term_glyph:
|
term_glyph:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -121,6 +121,8 @@ dependencies:
|
|||||||
ref: master
|
ref: master
|
||||||
# 状态栏图标控制
|
# 状态栏图标控制
|
||||||
status_bar_control: ^3.2.1
|
status_bar_control: ^3.2.1
|
||||||
|
# 代理
|
||||||
|
system_proxy: ^0.1.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Reference in New Issue
Block a user