feat: 原网页查看专栏

This commit is contained in:
guozhigq
2024-10-03 16:30:47 +08:00
parent 09d8980001
commit 0654f601f4
6 changed files with 37 additions and 18 deletions

View File

@ -39,6 +39,7 @@ class OpusController extends GetxController {
'articleType': 'cv', 'articleType': 'cv',
}); });
} else { } else {
title.value = res['data'].detail!.basic!.title!;
opusData.value = res['data']; opusData.value = res['data'];
} }
} }
@ -91,6 +92,15 @@ class OpusController extends GetxController {
); );
} }
// 跳转webview
void onJumpWebview() {
Get.toNamed('/webview', parameters: {
'url': url,
'type': 'webview',
'pageTitle': title.value,
});
}
@override @override
void onClose() { void onClose() {
scrollController.removeListener(_scrollListener); scrollController.removeListener(_scrollListener);

View File

@ -60,9 +60,14 @@ class _OpusPageState extends State<OpusPage> {
}, },
), ),
actions: [ actions: [
IconButton( PopupMenuButton(
icon: const Icon(Icons.more_vert_rounded), icon: const Icon(Icons.more_vert_outlined),
onPressed: () {}, itemBuilder: (BuildContext context) => <PopupMenuEntry>[
PopupMenuItem(
onTap: controller.onJumpWebview,
child: const Text('查看原网页'),
)
],
), ),
const SizedBox(width: 16), const SizedBox(width: 16),
], ],

View File

@ -22,6 +22,7 @@ class ReadPageController extends GetxController {
title.value = Get.parameters['title'] ?? ''; title.value = Get.parameters['title'] ?? '';
id = Get.parameters['id']!; id = Get.parameters['id']!;
articleType = Get.parameters['articleType']!; articleType = Get.parameters['articleType']!;
url = 'https://www.bilibili.com/read/cv$id';
scrollController.addListener(_scrollListener); scrollController.addListener(_scrollListener);
fetchViewInfo(); fetchViewInfo();
} }
@ -85,6 +86,15 @@ class ReadPageController extends GetxController {
ReadHttp.getViewInfo(id: id); ReadHttp.getViewInfo(id: id);
} }
// 跳转webview
void onJumpWebview() {
Get.toNamed('/webview', parameters: {
'url': url,
'type': 'webview',
'pageTitle': title.value,
});
}
@override @override
void onClose() { void onClose() {
scrollController.removeListener(_scrollListener); scrollController.removeListener(_scrollListener);

View File

@ -72,9 +72,14 @@ class _ReadPageState extends State<ReadPage> {
}, },
), ),
actions: [ actions: [
IconButton( PopupMenuButton(
icon: const Icon(Icons.more_vert_rounded), icon: const Icon(Icons.more_vert_outlined),
onPressed: () {}, itemBuilder: (BuildContext context) => <PopupMenuEntry>[
PopupMenuItem(
onTap: controller.onJumpWebview,
child: const Text('查看原网页'),
)
],
), ),
const SizedBox(width: 16), const SizedBox(width: 16),
], ],

View File

@ -1,19 +1,8 @@
// ignore_for_file: avoid_print
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/http/init.dart'; import 'package:pilipala/http/init.dart';
import 'package:pilipala/http/user.dart';
import 'package:pilipala/pages/home/index.dart';
import 'package:pilipala/pages/media/index.dart';
import 'package:pilipala/utils/cookie.dart';
import 'package:pilipala/utils/event_bus.dart'; import 'package:pilipala/utils/event_bus.dart';
import 'package:pilipala/utils/id_utils.dart'; import 'package:pilipala/utils/id_utils.dart';
import 'package:pilipala/utils/login.dart'; import 'package:pilipala/utils/login.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:webview_flutter/webview_flutter.dart'; import 'package:webview_flutter/webview_flutter.dart';
class WebviewController extends GetxController { class WebviewController extends GetxController {

View File

@ -82,7 +82,7 @@ class PiliSchame {
case 'opus': case 'opus':
if (path.startsWith('/detail')) { if (path.startsWith('/detail')) {
var opusId = path.split('/').last; var opusId = path.split('/').last;
Get.toNamed('/opus', arguments: { Get.toNamed('/opus', parameters: {
'title': '', 'title': '',
'id': opusId, 'id': opusId,
'articleType': 'opus', 'articleType': 'opus',