mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-21 02:50:14 +08:00
mod: use inappwebview
This commit is contained in:
@@ -114,7 +114,7 @@ class VideoCardV extends StatelessWidget {
|
|||||||
default:
|
default:
|
||||||
SmartDialog.showToast(videoItem.goto);
|
SmartDialog.showToast(videoItem.goto);
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url': videoItem.uri,
|
'url': videoItem.uri,
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ class DynamicsController extends GetxController
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url': 'https:$url',
|
'url': 'https:$url',
|
||||||
'type': 'note',
|
'type': 'note',
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ InlineSpan richNode(item, context) {
|
|||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url': i.origText,
|
'url': i.origText,
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
@@ -122,7 +122,7 @@ InlineSpan richNode(item, context) {
|
|||||||
try {
|
try {
|
||||||
String dynamicId = item.basic['comment_id_str'];
|
String dynamicId = item.basic['comment_id_str'];
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url':
|
'url':
|
||||||
'https://t.bilibili.com/vote/h5/index/#/result?vote_id=${i.rid}&dynamic_id=$dynamicId&isWeb=1',
|
'https://t.bilibili.com/vote/h5/index/#/result?vote_id=${i.rid}&dynamic_id=$dynamicId&isWeb=1',
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class HistoryItem extends StatelessWidget {
|
|||||||
// videoItem.history.oid ??
|
// videoItem.history.oid ??
|
||||||
await SearchHttp.ab2c(aid: aid, bvid: bvid);
|
await SearchHttp.ab2c(aid: aid, bvid: bvid);
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url': 'https://www.bilibili.com/read/cv$cid',
|
'url': 'https://www.bilibili.com/read/cv$cid',
|
||||||
'type': 'note',
|
'type': 'note',
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
|||||||
IconButton(
|
IconButton(
|
||||||
tooltip: '用内置浏览器打开',
|
tooltip: '用内置浏览器打开',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Get.toNamed('/webview', parameters: {
|
Get.toNamed('/webviewnew', parameters: {
|
||||||
'url': url.startsWith('http') ? url : 'https:$url',
|
'url': url.startsWith('http') ? url : 'https:$url',
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
'pageTitle': title,
|
'pageTitle': title,
|
||||||
@@ -174,7 +174,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
|||||||
),
|
),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
onTap: () => {
|
onTap: () => {
|
||||||
Get.toNamed('/webview', parameters: {
|
Get.toNamed('/webviewnew', parameters: {
|
||||||
'url': url.startsWith('http') ? url : 'https:$url',
|
'url': url.startsWith('http') ? url : 'https:$url',
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
'pageTitle': title,
|
'pageTitle': title,
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import 'package:PiliPalaX/http/live.dart';
|
|||||||
import 'package:PiliPalaX/models/live/room_info.dart';
|
import 'package:PiliPalaX/models/live/room_info.dart';
|
||||||
import 'package:PiliPalaX/plugin/pl_player/index.dart';
|
import 'package:PiliPalaX/plugin/pl_player/index.dart';
|
||||||
import '../../models/live/room_info_h5.dart';
|
import '../../models/live/room_info_h5.dart';
|
||||||
import '../../utils/storage.dart';
|
|
||||||
import '../../utils/video_utils.dart';
|
import '../../utils/video_utils.dart';
|
||||||
|
|
||||||
class LiveRoomController extends GetxController {
|
class LiveRoomController extends GetxController {
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
|
|||||||
tooltip: '内置浏览器打开',
|
tooltip: '内置浏览器打开',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Get.offNamed(
|
Get.offNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url':
|
'url':
|
||||||
'https://live.bilibili.com/h5/${_liveRoomController.roomId}',
|
'https://live.bilibili.com/h5/${_liveRoomController.roomId}',
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return SimpleDialog(
|
return SimpleDialog(
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
title: const Text('忘记密码?'),
|
title: const Text('忘记密码?'),
|
||||||
contentPadding:
|
contentPadding:
|
||||||
const EdgeInsets.fromLTRB(0.0, 2.0, 0.0, 16.0),
|
const EdgeInsets.fromLTRB(0.0, 2.0, 0.0, 16.0),
|
||||||
@@ -220,7 +221,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
dense: false,
|
dense: false,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
Get.back();
|
Get.back();
|
||||||
Get.toNamed('/webview', parameters: {
|
Get.toNamed('/webviewnew', parameters: {
|
||||||
'url':
|
'url':
|
||||||
'https://passport.bilibili.com/h5-app/passport/login/findPassword',
|
'https://passport.bilibili.com/h5-app/passport/login/findPassword',
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
@@ -238,7 +239,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
dense: false,
|
dense: false,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
Get.back();
|
Get.back();
|
||||||
Get.toNamed('/webview', parameters: {
|
Get.toNamed('/webviewnew', parameters: {
|
||||||
'url':
|
'url':
|
||||||
'https://passport.bilibili.com/pc/passport/findPassword',
|
'https://passport.bilibili.com/pc/passport/findPassword',
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
|
|||||||
@@ -36,11 +36,11 @@ class MediaController extends GetxController {
|
|||||||
{
|
{
|
||||||
'icon': Icons.create_outlined,
|
'icon': Icons.create_outlined,
|
||||||
'title': '创作中心(web)',
|
'title': '创作中心(web)',
|
||||||
'onTap': () => Get.toNamed('/webview', parameters: {
|
'onTap': () => Get.toNamed('/webviewnew', parameters: {
|
||||||
'url': 'https://member.bilibili.com/platform/home',
|
'url': 'https://member.bilibili.com/platform/home',
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
'pageTitle': "创作中心(建议浏览器打开)",
|
'pageTitle': "创作中心(建议浏览器打开)",
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
var userInfo;
|
var userInfo;
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ class ProfilePanel extends StatelessWidget {
|
|||||||
if (ctr.ownerMid == ctr.mid && ctr.ownerMid != -1) ...[
|
if (ctr.ownerMid == ctr.mid && ctr.ownerMid != -1) ...[
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Get.toNamed('/webview', parameters: {
|
Get.toNamed('/webviewnew', parameters: {
|
||||||
'url': 'https://account.bilibili.com/account/home',
|
'url': 'https://account.bilibili.com/account/home',
|
||||||
'pageTitle': '个人中心(建议浏览器打开)',
|
'pageTitle': '个人中心(建议浏览器打开)',
|
||||||
'type': 'url'
|
'type': 'url'
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class MineController extends GetxController {
|
|||||||
onLogin() async {
|
onLogin() async {
|
||||||
if (!userLogin.value) {
|
if (!userLogin.value) {
|
||||||
// Get.toNamed(
|
// Get.toNamed(
|
||||||
// '/webview',
|
// '/webviewnew',
|
||||||
// parameters: {
|
// parameters: {
|
||||||
// 'url': 'https://passport.bilibili.com/h5-app/passport/login',
|
// 'url': 'https://passport.bilibili.com/h5-app/passport/login',
|
||||||
// 'type': 'login',
|
// 'type': 'login',
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ class IntroDetail extends StatelessWidget {
|
|||||||
// 处理点击事件
|
// 处理点击事件
|
||||||
try {
|
try {
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url': match.group(0)!,
|
'url': match.group(0)!,
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
|
|||||||
@@ -625,7 +625,7 @@ InlineSpan buildContent(
|
|||||||
),
|
),
|
||||||
recognizer: TapGestureRecognizer()
|
recognizer: TapGestureRecognizer()
|
||||||
..onTap = () => Get.toNamed(
|
..onTap = () => Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url': content.vote['url'],
|
'url': content.vote['url'],
|
||||||
'type': 'vote',
|
'type': 'vote',
|
||||||
@@ -814,7 +814,7 @@ InlineSpan buildContent(
|
|||||||
// );
|
// );
|
||||||
// } else {
|
// } else {
|
||||||
// Get.toNamed(
|
// Get.toNamed(
|
||||||
// '/webview',
|
// '/webviewnew',
|
||||||
// parameters: {
|
// parameters: {
|
||||||
// 'url': redirectUrl,
|
// 'url': redirectUrl,
|
||||||
// 'type': 'url',
|
// 'type': 'url',
|
||||||
@@ -841,7 +841,7 @@ InlineSpan buildContent(
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url': redirectUrl,
|
'url': redirectUrl,
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
@@ -851,7 +851,7 @@ InlineSpan buildContent(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url': matchStr,
|
'url': matchStr,
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
@@ -922,7 +922,7 @@ InlineSpan buildContent(
|
|||||||
recognizer: TapGestureRecognizer()
|
recognizer: TapGestureRecognizer()
|
||||||
..onTap = () {
|
..onTap = () {
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url': patternStr,
|
'url': patternStr,
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
@@ -1074,7 +1074,7 @@ InlineSpan buildContent(
|
|||||||
),
|
),
|
||||||
recognizer: TapGestureRecognizer()
|
recognizer: TapGestureRecognizer()
|
||||||
..onTap = () => Get.toNamed(
|
..onTap = () => Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url': content.richText['note']['click_url'],
|
'url': content.richText['note']['click_url'],
|
||||||
'type': 'note',
|
'type': 'note',
|
||||||
@@ -1100,11 +1100,10 @@ class MorePanel extends StatelessWidget {
|
|||||||
case 'report':
|
case 'report':
|
||||||
Get.back();
|
Get.back();
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url':
|
'url':
|
||||||
'https://www.bilibili.com/h5/comment/report?mid=${item.mid}&oid=${item.oid}&pageType=1&rpid=${item.rpid}&platform=android',
|
'https://www.bilibili.com/h5/comment/report?mid=${item.mid}&oid=${item.oid}&pageType=1&rpid=${item.rpid}&platform=android',
|
||||||
'type': 'url',
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import 'package:PiliPalaX/models/video/ai.dart';
|
|||||||
import 'package:PiliPalaX/pages/video/detail/index.dart';
|
import 'package:PiliPalaX/pages/video/detail/index.dart';
|
||||||
import 'package:PiliPalaX/utils/utils.dart';
|
import 'package:PiliPalaX/utils/utils.dart';
|
||||||
|
|
||||||
|
|
||||||
class AiDetail extends StatelessWidget {
|
class AiDetail extends StatelessWidget {
|
||||||
final ModelResult? modelResult;
|
final ModelResult? modelResult;
|
||||||
|
|
||||||
@@ -185,7 +184,7 @@ class AiDetail extends StatelessWidget {
|
|||||||
// 处理点击事件
|
// 处理点击事件
|
||||||
try {
|
try {
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url': match.group(0)!,
|
'url': match.group(0)!,
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
|
|||||||
193
lib/pages/webview/webview_page.dart
Normal file
193
lib/pages/webview/webview_page.dart
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:PiliPalaX/http/init.dart';
|
||||||
|
import 'package:PiliPalaX/utils/id_utils.dart';
|
||||||
|
import 'package:PiliPalaX/utils/utils.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
// ignore: constant_identifier_names
|
||||||
|
enum WebviewMenuItem { Refresh, Copy, Open_In_Browser, Clear_Cache, Go_Back }
|
||||||
|
|
||||||
|
class WebviewPageNew extends StatefulWidget {
|
||||||
|
const WebviewPageNew({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<WebviewPageNew> createState() => _WebviewPageNewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _WebviewPageNewState extends State<WebviewPageNew> {
|
||||||
|
final String _url = Get.parameters['url'] ?? '';
|
||||||
|
final uaType = Get.parameters['uaType'] ?? 'mob';
|
||||||
|
final _titleStream = StreamController<String?>();
|
||||||
|
final _progressStream = StreamController<double>();
|
||||||
|
|
||||||
|
InAppWebViewController? _webViewController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_titleStream.close();
|
||||||
|
_progressStream.close();
|
||||||
|
_webViewController = null;
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
titleSpacing: 0,
|
||||||
|
title: StreamBuilder(
|
||||||
|
initialData: null,
|
||||||
|
stream: _titleStream.stream,
|
||||||
|
builder: (_, snapshot) => Text(
|
||||||
|
maxLines: 1,
|
||||||
|
snapshot.hasData ? snapshot.data! : _url,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
bottom: PreferredSize(
|
||||||
|
preferredSize: Size.zero,
|
||||||
|
child: StreamBuilder(
|
||||||
|
initialData: 0.0,
|
||||||
|
stream: _progressStream.stream,
|
||||||
|
builder: (_, snapshot) => snapshot.data as double < 1
|
||||||
|
? LinearProgressIndicator(
|
||||||
|
value: snapshot.data as double,
|
||||||
|
)
|
||||||
|
: const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
PopupMenuButton(
|
||||||
|
onSelected: (item) async {
|
||||||
|
switch (item) {
|
||||||
|
case WebviewMenuItem.Refresh:
|
||||||
|
_webViewController?.reload();
|
||||||
|
break;
|
||||||
|
case WebviewMenuItem.Copy:
|
||||||
|
WebUri? uri = await _webViewController?.getUrl();
|
||||||
|
if (uri != null) {
|
||||||
|
Utils.copyText(uri.toString());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WebviewMenuItem.Open_In_Browser:
|
||||||
|
WebUri? uri = await _webViewController?.getUrl();
|
||||||
|
if (uri != null) {
|
||||||
|
Utils.launchURL(uri.toString());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WebviewMenuItem.Clear_Cache:
|
||||||
|
try {
|
||||||
|
await InAppWebViewController.clearAllCache();
|
||||||
|
await _webViewController?.clearHistory();
|
||||||
|
SmartDialog.showToast('已清理');
|
||||||
|
} catch (e) {
|
||||||
|
SmartDialog.showToast(e.toString());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WebviewMenuItem.Go_Back:
|
||||||
|
if (await _webViewController?.canGoBack() == true) {
|
||||||
|
_webViewController?.goBack();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
itemBuilder: (context) => <PopupMenuEntry<WebviewMenuItem>>[
|
||||||
|
...WebviewMenuItem.values.sublist(0, 4).map(
|
||||||
|
(item) => PopupMenuItem(value: item, child: Text(item.name))),
|
||||||
|
const PopupMenuDivider(),
|
||||||
|
PopupMenuItem(
|
||||||
|
value: WebviewMenuItem.Go_Back,
|
||||||
|
child: Text(
|
||||||
|
WebviewMenuItem.Go_Back.name,
|
||||||
|
style:
|
||||||
|
TextStyle(color: Theme.of(context).colorScheme.error),
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: SafeArea(
|
||||||
|
child: InAppWebView(
|
||||||
|
initialSettings: InAppWebViewSettings(
|
||||||
|
clearCache: true,
|
||||||
|
javaScriptEnabled: true,
|
||||||
|
forceDark: ForceDark.AUTO,
|
||||||
|
useHybridComposition: false,
|
||||||
|
algorithmicDarkeningAllowed: true,
|
||||||
|
useShouldOverrideUrlLoading: true,
|
||||||
|
userAgent: Request().headerUa(type: uaType),
|
||||||
|
mixedContentMode: MixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW,
|
||||||
|
),
|
||||||
|
initialUrlRequest: URLRequest(url: WebUri.uri(Uri.parse(_url))),
|
||||||
|
onWebViewCreated: (InAppWebViewController controller) {
|
||||||
|
_webViewController = controller;
|
||||||
|
},
|
||||||
|
onProgressChanged: (controller, progress) {
|
||||||
|
_progressStream.add(progress / 100);
|
||||||
|
},
|
||||||
|
onTitleChanged: (controller, title) {
|
||||||
|
_titleStream.add(title);
|
||||||
|
},
|
||||||
|
onCloseWindow: (controller) => Get.back(),
|
||||||
|
onLoadStop: (controller, url) {
|
||||||
|
_webViewController?.evaluateJavascript(
|
||||||
|
source: '''
|
||||||
|
document.styleSheets[0].insertRule('div.open-app-btn.bili-btn-warp {display:none;}', 0);
|
||||||
|
document.styleSheets[0].insertRule('#app__display-area > div.control-panel {display:none;}', 0);
|
||||||
|
''',
|
||||||
|
);
|
||||||
|
_webViewController?.evaluateJavascript(
|
||||||
|
source: '''
|
||||||
|
document.querySelector('#internationalHeader').remove();
|
||||||
|
document.querySelector('#message-navbar').remove();
|
||||||
|
''',
|
||||||
|
);
|
||||||
|
},
|
||||||
|
shouldOverrideUrlLoading: (controller, navigationAction) async {
|
||||||
|
final String str = navigationAction.request.url!.pathSegments[0];
|
||||||
|
final Map matchRes = IdUtils.matchAvorBv(input: str);
|
||||||
|
final List matchKeys = matchRes.keys.toList();
|
||||||
|
if (matchKeys.isNotEmpty) {
|
||||||
|
if (matchKeys.first == 'BV') {
|
||||||
|
Get.offAndToNamed(
|
||||||
|
'/searchResult',
|
||||||
|
parameters: {'keyword': matchRes['BV']},
|
||||||
|
);
|
||||||
|
return NavigationActionPolicy.CANCEL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var url = navigationAction.request.url!.toString();
|
||||||
|
if (!url.startsWith('http')) {
|
||||||
|
if (url.startsWith('bilibili://video/')) {
|
||||||
|
String str = Uri.parse(url).pathSegments[0];
|
||||||
|
Get.offAndToNamed(
|
||||||
|
'/searchResult',
|
||||||
|
parameters: {'keyword': str},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
var snackBar = SnackBar(
|
||||||
|
content: const Text('当前网页将要打开外部链接,是否打开'),
|
||||||
|
showCloseIcon: true,
|
||||||
|
action: SnackBarAction(
|
||||||
|
label: '打开',
|
||||||
|
onPressed: () => Utils.launchURL(url),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NavigationActionPolicy.CANCEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NavigationActionPolicy.ALLOW;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -57,7 +57,7 @@ class _WhisperPageState extends State<WhisperPage> {
|
|||||||
color: Theme.of(context).colorScheme.primary),
|
color: Theme.of(context).colorScheme.primary),
|
||||||
tooltip: '用浏览器打开',
|
tooltip: '用浏览器打开',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Get.toNamed('/webview', parameters: {
|
Get.toNamed('/webviewnew', parameters: {
|
||||||
'url': 'https://message.bilibili.com',
|
'url': 'https://message.bilibili.com',
|
||||||
'type': 'whisper',
|
'type': 'whisper',
|
||||||
'pageTitle': '消息中心',
|
'pageTitle': '消息中心',
|
||||||
|
|||||||
@@ -84,8 +84,7 @@ class ChatItem extends StatelessWidget {
|
|||||||
final String emojiKey = match[0]!;
|
final String emojiKey = match[0]!;
|
||||||
print(emojiKey);
|
print(emojiKey);
|
||||||
if (emojiMap.containsKey(emojiKey)) {
|
if (emojiMap.containsKey(emojiKey)) {
|
||||||
children.add(
|
children.add(WidgetSpan(
|
||||||
WidgetSpan(
|
|
||||||
child: NetworkImgLayer(
|
child: NetworkImgLayer(
|
||||||
width: 18,
|
width: 18,
|
||||||
height: 18,
|
height: 18,
|
||||||
@@ -315,7 +314,7 @@ class ChatItem extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast('未匹配到 BV 号');
|
SmartDialog.showToast('未匹配到 BV 号');
|
||||||
Get.toNamed('/webview',
|
Get.toNamed('/webviewnew',
|
||||||
arguments: {'url': i['jump_url']});
|
arguments: {'url': i['jump_url']});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// ignore_for_file: must_be_immutable
|
// ignore_for_file: must_be_immutable
|
||||||
|
|
||||||
|
import 'package:PiliPalaX/pages/webview/webview_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
@@ -80,6 +81,7 @@ class Routes {
|
|||||||
// ),
|
// ),
|
||||||
//
|
//
|
||||||
CustomGetPage(name: '/webview', page: () => const WebviewPage()),
|
CustomGetPage(name: '/webview', page: () => const WebviewPage()),
|
||||||
|
CustomGetPage(name: '/webviewnew', page: () => const WebviewPageNew()),
|
||||||
// 设置
|
// 设置
|
||||||
CustomGetPage(name: '/setting', page: () => const SettingPage()),
|
CustomGetPage(name: '/setting', page: () => const SettingPage()),
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ class PiliScheme {
|
|||||||
if (path.startsWith('/detail')) {
|
if (path.startsWith('/detail')) {
|
||||||
var opusId = path.split('/').last;
|
var opusId = path.split('/').last;
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url': 'https://www.bilibili.com/opus/$opusId',
|
'url': 'https://www.bilibili.com/opus/$opusId',
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
@@ -170,7 +170,7 @@ class PiliScheme {
|
|||||||
void getToOpusWeb() {
|
void getToOpusWeb() {
|
||||||
var opusId = path.split('/').last;
|
var opusId = path.split('/').last;
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url': 'https://m.bilibili.com/dynamic/$opusId',
|
'url': 'https://m.bilibili.com/dynamic/$opusId',
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
@@ -214,7 +214,7 @@ class PiliScheme {
|
|||||||
print(value);
|
print(value);
|
||||||
SmartDialog.showToast('未知路径:$value,请截图反馈给开发者');
|
SmartDialog.showToast('未知路径:$value,请截图反馈给开发者');
|
||||||
// Get.toNamed(
|
// Get.toNamed(
|
||||||
// '/webview',
|
// '/webviewnew',
|
||||||
// parameters: {
|
// parameters: {
|
||||||
// 'url': value.dataString ?? "",
|
// 'url': value.dataString ?? "",
|
||||||
// 'type': 'url',
|
// 'type': 'url',
|
||||||
@@ -332,7 +332,7 @@ class PiliScheme {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {'url': redirectUrl, 'type': 'url', 'pageTitle': ''},
|
parameters: {'url': redirectUrl, 'type': 'url', 'pageTitle': ''},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -396,7 +396,7 @@ class PiliScheme {
|
|||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast('未知路径或匹配错误:$value,先采用浏览器打开');
|
SmartDialog.showToast('未知路径或匹配错误:$value,先采用浏览器打开');
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url': value.toString(),
|
'url': value.toString(),
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class CacheManage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 缓存大小格式转换
|
// 缓存大小格式转换
|
||||||
String formatSize(double value) {
|
static String formatSize(double value) {
|
||||||
List<String> unitArr = ['B', 'K', 'M', 'G'];
|
List<String> unitArr = ['B', 'K', 'M', 'G'];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (value > 1024) {
|
while (value > 1024) {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class UrlUtils {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
await Get.toNamed(
|
await Get.toNamed(
|
||||||
'/webview',
|
'/webviewnew',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url': redirectUrl,
|
'url': redirectUrl,
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import 'package:PiliPalaX/utils/storage.dart';
|
|||||||
import 'package:crypto/crypto.dart';
|
import 'package:crypto/crypto.dart';
|
||||||
import 'package:device_info_plus/device_info_plus.dart';
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
@@ -21,6 +22,22 @@ import '../models/github/latest.dart';
|
|||||||
class Utils {
|
class Utils {
|
||||||
static final Random random = Random();
|
static final Random random = Random();
|
||||||
|
|
||||||
|
static void copyText(String text) {
|
||||||
|
Clipboard.setData(ClipboardData(text: text));
|
||||||
|
SmartDialog.showToast('已复制');
|
||||||
|
}
|
||||||
|
|
||||||
|
static launchURL(String url) async {
|
||||||
|
try {
|
||||||
|
final Uri uri = Uri.parse(url);
|
||||||
|
if (!await launchUrl(uri)) {
|
||||||
|
SmartDialog.showToast('Could not launch $url');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
SmartDialog.showToast(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static Color get vipColor {
|
static Color get vipColor {
|
||||||
return GStorage.brightness == Brightness.light
|
return GStorage.brightness == Brightness.light
|
||||||
? const Color(0xFFFF6699)
|
? const Color(0xFFFF6699)
|
||||||
|
|||||||
62
pubspec.lock
62
pubspec.lock
@@ -604,6 +604,62 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.0-beta.2"
|
version: "3.0.0-beta.2"
|
||||||
|
flutter_inappwebview:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_inappwebview
|
||||||
|
sha256: "3e9a443a18ecef966fb930c3a76ca5ab6a7aafc0c7b5e14a4a850cf107b09959"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.0.0"
|
||||||
|
flutter_inappwebview_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_inappwebview_android
|
||||||
|
sha256: d247f6ed417f1f8c364612fa05a2ecba7f775c8d0c044c1d3b9ee33a6515c421
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.13"
|
||||||
|
flutter_inappwebview_internal_annotations:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_inappwebview_internal_annotations
|
||||||
|
sha256: "5f80fd30e208ddded7dbbcd0d569e7995f9f63d45ea3f548d8dd4c0b473fb4c8"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.1"
|
||||||
|
flutter_inappwebview_ios:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_inappwebview_ios
|
||||||
|
sha256: f363577208b97b10b319cd0c428555cd8493e88b468019a8c5635a0e4312bd0f
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.13"
|
||||||
|
flutter_inappwebview_macos:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_inappwebview_macos
|
||||||
|
sha256: b55b9e506c549ce88e26580351d2c71d54f4825901666bd6cfa4be9415bb2636
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.11"
|
||||||
|
flutter_inappwebview_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_inappwebview_platform_interface
|
||||||
|
sha256: "545fd4c25a07d2775f7d5af05a979b2cac4fbf79393b0a7f5d33ba39ba4f6187"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.10"
|
||||||
|
flutter_inappwebview_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_inappwebview_web
|
||||||
|
sha256: d8c680abfb6fec71609a700199635d38a744df0febd5544c5a020bd73de8ee07
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.8"
|
||||||
flutter_launcher_icons:
|
flutter_launcher_icons:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
@@ -1859,13 +1915,13 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "4.9.0"
|
version: "4.9.0"
|
||||||
webview_flutter_android:
|
webview_flutter_android:
|
||||||
dependency: transitive
|
dependency: "direct overridden"
|
||||||
description:
|
description:
|
||||||
name: webview_flutter_android
|
name: webview_flutter_android
|
||||||
sha256: "6e64fcb1c19d92024da8f33503aaeeda35825d77142c01d0ea2aa32edc79fdc8"
|
sha256: dad3313c9ead95517bb1cae5e1c9d20ba83729d5a59e5e83c0a2d66203f27f91
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.16.7"
|
version: "3.16.1"
|
||||||
webview_flutter_platform_interface:
|
webview_flutter_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ dependencies:
|
|||||||
webview_cookie_manager: ^2.0.6
|
webview_cookie_manager: ^2.0.6
|
||||||
# 浏览器
|
# 浏览器
|
||||||
webview_flutter: ^4.2.2
|
webview_flutter: ^4.2.2
|
||||||
|
flutter_inappwebview: ^6.0.0
|
||||||
# 解决sliver滑动不同步
|
# 解决sliver滑动不同步
|
||||||
extended_nested_scroll_view: ^6.1.2
|
extended_nested_scroll_view: ^6.1.2
|
||||||
# 上拉加载
|
# 上拉加载
|
||||||
@@ -154,6 +155,7 @@ dependency_overrides:
|
|||||||
git: https://github.com/orz12/mime.git
|
git: https://github.com/orz12/mime.git
|
||||||
fading_edge_scrollview: ^4.1.1
|
fading_edge_scrollview: ^4.1.1
|
||||||
rxdart: ^0.28.0
|
rxdart: ^0.28.0
|
||||||
|
webview_flutter_android: 3.16.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user