feat: open in browser

Closes #140

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-01-11 10:05:01 +08:00
parent 54d13fe7f2
commit 2d338450f4
17 changed files with 60 additions and 166 deletions

View File

@@ -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',

View File

@@ -66,14 +66,7 @@ class UrlUtils {
preventDuplicates: false,
);
} else {
await Get.toNamed(
'/webview',
parameters: {
'url': redirectUrl,
'type': 'url',
'pageTitle': title,
},
);
Utils.handleWebview(redirectUrl);
}
}
}

View File

@@ -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) {