mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
fix windows webview
This commit is contained in:
@@ -70,6 +70,8 @@ class AppWebview extends StatefulWidget {
|
|||||||
|
|
||||||
final bool singlePage;
|
final bool singlePage;
|
||||||
|
|
||||||
|
static WebViewEnvironment? webViewEnvironment;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AppWebview> createState() => _AppWebviewState();
|
State<AppWebview> createState() => _AppWebviewState();
|
||||||
}
|
}
|
||||||
@@ -117,7 +119,50 @@ class _AppWebviewState extends State<AppWebview> {
|
|||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
Widget body = InAppWebView(
|
Widget body = (App.isWindows && AppWebview.webViewEnvironment == null)
|
||||||
|
? FutureBuilder(
|
||||||
|
future: WebViewEnvironment.create(
|
||||||
|
settings: WebViewEnvironmentSettings(
|
||||||
|
userDataFolder: "${App.dataPath}\\webview",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
builder: (context, e) {
|
||||||
|
if(e.error != null) {
|
||||||
|
return Center(child: Text("Error: ${e.error}"));
|
||||||
|
}
|
||||||
|
if(e.data == null) {
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
}
|
||||||
|
AppWebview.webViewEnvironment = e.data;
|
||||||
|
return createWebviewWithEnvironment(AppWebview.webViewEnvironment);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: createWebviewWithEnvironment(AppWebview.webViewEnvironment);
|
||||||
|
|
||||||
|
body = Stack(
|
||||||
|
children: [
|
||||||
|
Positioned.fill(child: body),
|
||||||
|
if (_progress < 1.0)
|
||||||
|
const Positioned.fill(
|
||||||
|
child: Center(child: CircularProgressIndicator()))
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: Appbar(
|
||||||
|
title: Text(
|
||||||
|
title,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
actions: actions,
|
||||||
|
),
|
||||||
|
body: body);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget createWebviewWithEnvironment(WebViewEnvironment? e) {
|
||||||
|
return InAppWebView(
|
||||||
|
webViewEnvironment: e,
|
||||||
initialSettings: InAppWebViewSettings(
|
initialSettings: InAppWebViewSettings(
|
||||||
isInspectable: true,
|
isInspectable: true,
|
||||||
),
|
),
|
||||||
@@ -155,26 +200,6 @@ class _AppWebviewState extends State<AppWebview> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
body = Stack(
|
|
||||||
children: [
|
|
||||||
Positioned.fill(child: body),
|
|
||||||
if (_progress < 1.0)
|
|
||||||
const Positioned.fill(
|
|
||||||
child: Center(child: CircularProgressIndicator()))
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
appBar: Appbar(
|
|
||||||
title: Text(
|
|
||||||
title,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
actions: actions,
|
|
||||||
),
|
|
||||||
body: body);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
windows/.gitignore
vendored
1
windows/.gitignore
vendored
@@ -15,3 +15,4 @@ x86/
|
|||||||
*.[Cc]ache
|
*.[Cc]ache
|
||||||
# but keep track of directories ending in .cache
|
# but keep track of directories ending in .cache
|
||||||
!*.[Cc]ache/
|
!*.[Cc]ache/
|
||||||
|
/ChineseSimplified.isl
|
||||||
|
Reference in New Issue
Block a user