mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: open in browser
Closes #140 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -318,6 +318,9 @@ class GStorage {
|
||||
static bool get horizontalPreview => GStorage.setting
|
||||
.get(SettingBoxKey.horizontalPreview, defaultValue: false);
|
||||
|
||||
static bool get openInBrowser =>
|
||||
GStorage.setting.get(SettingBoxKey.openInBrowser, defaultValue: false);
|
||||
|
||||
static bool get savedRcmdTip =>
|
||||
GStorage.setting.get(SettingBoxKey.savedRcmdTip, defaultValue: true);
|
||||
|
||||
@@ -534,6 +537,7 @@ class SettingBoxKey {
|
||||
banWordForReply = 'banWordForReply',
|
||||
banWordForZone = 'banWordForZone',
|
||||
savedRcmdTip = 'savedRcmdTip',
|
||||
openInBrowser = 'openInBrowser',
|
||||
|
||||
// Sponsor Block
|
||||
enableSponsorBlock = 'enableSponsorBlock',
|
||||
|
||||
@@ -66,14 +66,7 @@ class UrlUtils {
|
||||
preventDuplicates: false,
|
||||
);
|
||||
} else {
|
||||
await Get.toNamed(
|
||||
'/webview',
|
||||
parameters: {
|
||||
'url': redirectUrl,
|
||||
'type': 'url',
|
||||
'pageTitle': title,
|
||||
},
|
||||
);
|
||||
Utils.handleWebview(redirectUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,24 @@ class Utils {
|
||||
|
||||
static const channel = MethodChannel("PiliPlus");
|
||||
|
||||
static void handleWebview(String url, {bool off = false}) {
|
||||
if (GStorage.openInBrowser) {
|
||||
launchURL(url);
|
||||
} else {
|
||||
if (off) {
|
||||
Get.offNamed(
|
||||
'/webview',
|
||||
parameters: {'url': url},
|
||||
);
|
||||
} else {
|
||||
toDupNamed(
|
||||
'/webview',
|
||||
parameters: {'url': url},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool viewPgcFromUri(String uri) {
|
||||
String? id = RegExp(r'(ep|ss)\d+').firstMatch(uri)?.group(0);
|
||||
if (id != null) {
|
||||
|
||||
Reference in New Issue
Block a user