mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-22 19:40:10 +08:00
fix in-app webview (#2454)
* fix(webview): inApp 模式下拦截非 http(s) scheme,避免 ERR_UNKNOWN_URL_SCHEME * update --------- Co-authored-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -317,25 +317,25 @@ class _WebviewPageState extends State<WebviewPage> {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
shouldOverrideUrlLoading: (controller, navigationAction) async {
|
shouldOverrideUrlLoading: (controller, navigationAction) async {
|
||||||
if (_inApp) {
|
if (!_inApp) {
|
||||||
return NavigationActionPolicy.ALLOW;
|
final hasMatch = await PiliScheme.routePush(
|
||||||
|
navigationAction.request.url?.uriValue ?? Uri(),
|
||||||
|
selfHandle: true,
|
||||||
|
off: _off,
|
||||||
|
);
|
||||||
|
// if (kDebugMode) debugPrint('webview: [$url], [$hasMatch]');
|
||||||
|
if (hasMatch) {
|
||||||
|
progress.value = 1;
|
||||||
|
return .CANCEL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
late String url = navigationAction.request.url.toString();
|
final url = navigationAction.request.url.toString();
|
||||||
bool hasMatch = await PiliScheme.routePush(
|
if (_prefixRegex.hasMatch(url)) {
|
||||||
navigationAction.request.url?.uriValue ?? Uri(),
|
|
||||||
selfHandle: true,
|
|
||||||
off: _off,
|
|
||||||
);
|
|
||||||
// if (kDebugMode) debugPrint('webview: [$url], [$hasMatch]');
|
|
||||||
if (hasMatch) {
|
|
||||||
progress.value = 1;
|
|
||||||
return NavigationActionPolicy.CANCEL;
|
|
||||||
} else if (_prefixRegex.hasMatch(url)) {
|
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
SnackBar snackBar = SnackBar(
|
final snackBar = SnackBar(
|
||||||
content: const Text('当前网页将要打开外部链接,是否打开'),
|
|
||||||
showCloseIcon: true,
|
|
||||||
persist: false,
|
persist: false,
|
||||||
|
showCloseIcon: true,
|
||||||
|
content: const Text('当前网页将要打开外部链接,是否打开'),
|
||||||
action: SnackBarAction(
|
action: SnackBarAction(
|
||||||
label: '打开',
|
label: '打开',
|
||||||
onPressed: () => PageUtils.launchURL(url),
|
onPressed: () => PageUtils.launchURL(url),
|
||||||
@@ -344,10 +344,10 @@ class _WebviewPageState extends State<WebviewPage> {
|
|||||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||||
}
|
}
|
||||||
progress.value = 1;
|
progress.value = 1;
|
||||||
return NavigationActionPolicy.CANCEL;
|
return .CANCEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NavigationActionPolicy.ALLOW;
|
return .ALLOW;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user