mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
fix #127
This commit is contained in:
@@ -8,6 +8,7 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
|||||||
import 'package:url_launcher/url_launcher_string.dart';
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
import 'package:venera/components/components.dart';
|
import 'package:venera/components/components.dart';
|
||||||
import 'package:venera/foundation/app.dart';
|
import 'package:venera/foundation/app.dart';
|
||||||
|
import 'package:venera/foundation/appdata.dart';
|
||||||
import 'package:venera/network/app_dio.dart';
|
import 'package:venera/network/app_dio.dart';
|
||||||
import 'package:venera/utils/ext.dart';
|
import 'package:venera/utils/ext.dart';
|
||||||
import 'package:venera/utils/translations.dart';
|
import 'package:venera/utils/translations.dart';
|
||||||
@@ -83,6 +84,33 @@ class _AppWebviewState extends State<AppWebview> {
|
|||||||
|
|
||||||
double _progress = 0;
|
double _progress = 0;
|
||||||
|
|
||||||
|
late var future = _createWebviewEnvironment();
|
||||||
|
|
||||||
|
Future<WebViewEnvironment> _createWebviewEnvironment() async {
|
||||||
|
var proxy = appdata.settings['proxy'].toString();
|
||||||
|
if (proxy != "system" && proxy != "direct") {
|
||||||
|
var proxyAvailable = await WebViewFeature.isFeatureSupported(
|
||||||
|
WebViewFeature.PROXY_OVERRIDE);
|
||||||
|
if (proxyAvailable) {
|
||||||
|
ProxyController proxyController = ProxyController.instance();
|
||||||
|
await proxyController.clearProxyOverride();
|
||||||
|
if (!proxy.contains("://")) {
|
||||||
|
proxy = "http://$proxy";
|
||||||
|
}
|
||||||
|
await proxyController.setProxyOverride(
|
||||||
|
settings: ProxySettings(
|
||||||
|
proxyRules: [ProxyRule(url: proxy)],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return WebViewEnvironment.create(
|
||||||
|
settings: WebViewEnvironmentSettings(
|
||||||
|
userDataFolder: "${App.dataPath}\\webview",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final actions = [
|
final actions = [
|
||||||
@@ -121,11 +149,7 @@ class _AppWebviewState extends State<AppWebview> {
|
|||||||
|
|
||||||
Widget body = (App.isWindows && AppWebview.webViewEnvironment == null)
|
Widget body = (App.isWindows && AppWebview.webViewEnvironment == null)
|
||||||
? FutureBuilder(
|
? FutureBuilder(
|
||||||
future: WebViewEnvironment.create(
|
future: future,
|
||||||
settings: WebViewEnvironmentSettings(
|
|
||||||
userDataFolder: "${App.dataPath}\\webview",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
builder: (context, e) {
|
builder: (context, e) {
|
||||||
if (e.error != null) {
|
if (e.error != null) {
|
||||||
return Center(child: Text("Error: ${e.error}"));
|
return Center(child: Text("Error: ${e.error}"));
|
||||||
@@ -134,7 +158,8 @@ class _AppWebviewState extends State<AppWebview> {
|
|||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
}
|
}
|
||||||
AppWebview.webViewEnvironment = e.data;
|
AppWebview.webViewEnvironment = e.data;
|
||||||
return createWebviewWithEnvironment(AppWebview.webViewEnvironment);
|
return createWebviewWithEnvironment(
|
||||||
|
AppWebview.webViewEnvironment);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: createWebviewWithEnvironment(AppWebview.webViewEnvironment);
|
: createWebviewWithEnvironment(AppWebview.webViewEnvironment);
|
||||||
|
Reference in New Issue
Block a user