opt: pm share

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-26 10:26:16 +08:00
parent b8d2ff7e9b
commit 0bdf620c2f
9 changed files with 210 additions and 134 deletions

View File

@@ -349,12 +349,27 @@ class BangumiIntroController
try {
EpisodeItem item = bangumiItem!.episodes!
.firstWhere((item) => item.epId == epId);
PageUtils.pmShareVideo(
id: epId!,
source: 16,
cover: item.cover!,
title: '${bangumiItem!.title!} ${item.showTitle}',
url: item.shareUrl,
final title = '${bangumiItem!.title!} ${item.showTitle}';
PageUtils.pmShare(
content: {
"id": epId!.toString(),
"title": title,
"url": item.shareUrl,
"headline": title,
"source": 16,
"extra": {},
"thumb": item.cover,
"source_desc": switch (bangumiItem!.type) {
1 => '番剧',
2 => '电影',
3 => '纪录片',
4 => '国创',
5 => '电视剧',
6 => '漫画',
7 => '综艺',
_ => null,
}
},
);
} catch (e) {
SmartDialog.showToast(e.toString());

View File

@@ -5,6 +5,7 @@ import 'package:PiliPlus/common/widgets/report.dart';
import 'package:PiliPlus/common/widgets/save_panel.dart';
import 'package:PiliPlus/http/video.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/page_utils.dart';
import 'package:PiliPlus/utils/request_utils.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:cached_network_image/cached_network_image.dart';
@@ -284,6 +285,16 @@ class AuthorPanel extends StatelessWidget {
style: Theme.of(context).textTheme.titleSmall,
),
),
ListTile(
onTap: () {
Get.back();
SavePanel.toSavePanel(item: item);
},
minLeadingWidth: 0,
leading: const Icon(Icons.save_alt, size: 19),
title: Text('保存动态',
style: Theme.of(context).textTheme.titleSmall!),
),
ListTile(
title: Text(
'分享动态',
@@ -297,16 +308,52 @@ class AuthorPanel extends StatelessWidget {
},
minLeadingWidth: 0,
),
ListTile(
onTap: () {
Get.back();
SavePanel.toSavePanel(item: item);
},
minLeadingWidth: 0,
leading: const Icon(Icons.save_alt, size: 19),
title: Text('保存动态',
style: Theme.of(context).textTheme.titleSmall!),
),
if (item.basic['comment_type'] == 17 ||
item.basic['comment_type'] == 11)
ListTile(
title: Text(
'分享至消息',
style: Theme.of(context).textTheme.titleSmall,
),
leading: const Icon(Icons.forward_to_inbox, size: 19),
onTap: () {
Get.back();
try {
bool isDyn = item.basic['comment_type'] == 17;
String id = isDyn ? item.idStr : item.basic['rid_str'];
int source = isDyn ? 11 : 2;
String title;
if (item.modules.moduleDynamic.desc != null) {
title = item.modules.moduleDynamic.desc.text;
} else if (item.modules.moduleDynamic.major != null) {
title =
item.modules.moduleDynamic.major.opus.summary.text;
} else {
throw UnsupportedError(
'error getting title: {"type": ${item.basic['comment_type']}, "id": $id}');
}
String thumb = isDyn
? item.modules.moduleAuthor.face
: item
.modules.moduleDynamic.major.opus.pics.first.url;
PageUtils.pmShare(
content: {
"id": id,
"title": title,
"headline": "",
"source": source,
"extra": {},
"thumb": thumb,
"author": item.modules.moduleAuthor.name,
"author_id": item.modules.moduleAuthor.mid.toString()
},
);
} catch (e) {
SmartDialog.showToast(e.toString());
}
},
minLeadingWidth: 0,
),
ListTile(
title: Text(
'临时屏蔽:${item.modules?.moduleAuthor?.name}',
@@ -317,9 +364,9 @@ class AuthorPanel extends StatelessWidget {
Get.back();
Get.find<DynamicsController>()
.tempBannedList
.add(item.modules!.moduleAuthor!.mid!);
.add(item.modules.moduleAuthor.mid);
SmartDialog.showToast(
'已临时屏蔽${item.modules?.moduleAuthor?.name}(${item.modules!.moduleAuthor!.mid}),重启恢复');
'已临时屏蔽${item.modules?.moduleAuthor?.name}(${item.modules.moduleAuthor.mid}),重启恢复');
},
minLeadingWidth: 0,
),

View File

@@ -56,6 +56,7 @@ class HtmlRenderController extends ReplyController<MainListReply> {
'status': true,
'isFav': res['data']?['favorite'] ?? false,
'favNum': res['data']?['stats']?['favorite'] ?? 0,
'data': res['data'],
});
}
});

View File

@@ -17,6 +17,7 @@ import 'package:PiliPlus/utils/utils.dart';
import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart';
import 'package:PiliPlus/common/skeleton/video_reply.dart';
@@ -633,6 +634,40 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
],
),
),
if (_htmlRenderCtr.dynamicType == 'read' &&
_htmlRenderCtr.favStat['status'])
PopupMenuItem(
onTap: () {
try {
PageUtils.pmShare(
content: {
"id": _htmlRenderCtr.id.substring(2),
"title": "- 哔哩哔哩专栏",
"headline": _htmlRenderCtr.favStat['data']['title'],
"source": 6,
"thumb": (_htmlRenderCtr.favStat['data']
['origin_image_urls'] as List?)
?.firstOrNull ??
'',
"author": _htmlRenderCtr.favStat['data']
['author_name'],
"author_id":
_htmlRenderCtr.favStat['data']['mid'].toString(),
},
);
} catch (e) {
SmartDialog.showToast(e.toString());
}
},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.forward_to_inbox, size: 19),
SizedBox(width: 10),
Text('分享至动态'),
],
),
),
],
),
const SizedBox(width: 6)

View File

@@ -18,7 +18,6 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:PiliPlus/common/widgets/network_img_layer.dart';
import 'package:PiliPlus/plugin/pl_player/index.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:screen_brightness/screen_brightness.dart';
import '../../utils/storage.dart';
@@ -416,35 +415,6 @@ class _LiveRoomPageState extends State<LiveRoomPage>
),
],
),
const Spacer(),
Obx(
() => IconButton(
onPressed: plPlayerController.setOnlyPlayAudio,
icon: Icon(
plPlayerController.onlyPlayAudio.value
? MdiIcons.musicCircle
: MdiIcons.musicCircleOutline,
color: Colors.white,
),
),
),
IconButton(
tooltip: '刷新',
onPressed: () {
_futureBuilderFuture =
_liveRoomController.queryLiveInfo();
},
icon: const Icon(Icons.refresh),
),
IconButton(
tooltip: '浏览器打开',
onPressed: () {
PageUtils.inAppWebview(
'https://live.bilibili.com/h5/${_liveRoomController.roomId}',
off: true,
);
},
icon: const Icon(Icons.open_in_browser)),
],
),
);
@@ -453,6 +423,71 @@ class _LiveRoomPageState extends State<LiveRoomPage>
}
},
),
actions: [
IconButton(
tooltip: '刷新',
onPressed: () {
_futureBuilderFuture = _liveRoomController.queryLiveInfo();
},
icon: const Icon(Icons.refresh),
),
PopupMenuButton(
icon: const Icon(Icons.more_vert, size: 19),
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
PopupMenuItem(
onTap: () {
PageUtils.inAppWebview(
'https://live.bilibili.com/h5/${_liveRoomController.roomId}',
off: true,
);
},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.open_in_browser, size: 19),
SizedBox(width: 10),
Text('浏览器打开'),
],
),
),
PopupMenuItem(
onTap: () {
try {
PageUtils.pmShare(
content: {
"cover": _liveRoomController
.roomInfoH5.value.roomInfo!.cover!,
"sourceID": _liveRoomController.roomId.toString(),
"title": _liveRoomController
.roomInfoH5.value.roomInfo!.title!,
"url":
"https://live.bilibili.com/${_liveRoomController.roomId}",
"authorID": _liveRoomController
.roomInfoH5.value.roomInfo!.uid
.toString(),
"source": "直播",
"desc": _liveRoomController
.roomInfoH5.value.roomInfo!.title!,
"author": _liveRoomController
.roomInfoH5.value.anchorInfo!.baseInfo!.uname,
},
);
} catch (e) {
SmartDialog.showToast(e.toString());
}
},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.forward_to_inbox, size: 19),
SizedBox(width: 10),
Text('分享至消息'),
],
),
),
],
),
],
);
Widget get _buildBodyH {

View File

@@ -509,13 +509,16 @@ class VideoIntroController extends GetxController {
onTap: () {
Get.back();
try {
PageUtils.pmShareVideo(
author: videoDetail.value.owner!.name!,
id: videoDetail.value.aid!,
source: 5,
cover: videoDetail.value.pic!,
title: videoDetail.value.title!,
bvid: videoDetail.value.bvid!,
PageUtils.pmShare(
content: {
"id": videoDetail.value.aid!.toString(),
"title": videoDetail.value.title!,
"headline": videoDetail.value.title!,
"source": 5,
"thumb": videoDetail.value.pic!,
"author": videoDetail.value.owner!.name!,
"author_id": videoDetail.value.owner!.mid!.toString(),
},
);
} catch (e) {
SmartDialog.showToast(e.toString());

View File

@@ -34,37 +34,21 @@ class UserModel {
int get hashCode => mid.hashCode;
}
class ShareVideoPanel extends StatefulWidget {
const ShareVideoPanel({
class SharePanel extends StatefulWidget {
const SharePanel({
super.key,
this.author,
required this.id,
required this.source,
required this.cover,
required this.title,
this.bvid,
this.url,
this.authorId,
this.sourceDesc,
required this.content,
this.userList,
});
final String? author;
final int id;
final int source;
final String cover;
final String title;
final String? bvid;
final String? url;
final int? authorId;
final String? sourceDesc;
final Map content;
final List<UserModel>? userList;
@override
State<ShareVideoPanel> createState() => _ShareVideoPanelState();
State<SharePanel> createState() => _SharePanelState();
}
class _ShareVideoPanelState extends State<ShareVideoPanel> {
class _SharePanelState extends State<SharePanel> {
int _selectedIndex = -1;
final List<UserModel> _userList = <UserModel>[];
final ScrollController _scrollController = ScrollController();
@@ -245,17 +229,9 @@ class _ShareVideoPanelState extends State<ShareVideoPanel> {
SmartDialog.showToast('请选择分享的用户');
return;
}
RequestUtils.pmShareVideo(
RequestUtils.pmShare(
receiverId: _userList[_selectedIndex].mid,
author: widget.author,
id: widget.id,
source: widget.source,
cover: widget.cover,
title: widget.title,
bvid: widget.bvid,
url: widget.url,
authorId: widget.authorId,
sourceDesc: widget.sourceDesc,
content: widget.content,
message: _controller.text,
);
},