mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-16 06:03:54 +08:00
feat: handle vote uri (#2105)
This commit is contained in:
committed by
GitHub
parent
ad6c0e0d15
commit
d5293fbc72
@@ -375,7 +375,10 @@ abstract final class DynamicsHttp {
|
|||||||
queryParameters: {'vote_id': voteId},
|
queryParameters: {'vote_id': voteId},
|
||||||
);
|
);
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
return Success(VoteInfo.fromSeparatedJson(res.data['data']));
|
final voteInfo = VoteInfo.fromSeparatedJson(res.data['data']);
|
||||||
|
return voteInfo.voteId == null
|
||||||
|
? const Error('无效的投票id')
|
||||||
|
: Success(voteInfo);
|
||||||
} else {
|
} else {
|
||||||
return Error(res.data['message']);
|
return Error(res.data['message']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class _VotePanelState extends State<VotePanel> {
|
|||||||
late bool _showPercentage = !_enabled;
|
late bool _showPercentage = !_enabled;
|
||||||
late final _maxCnt = _voteInfo.choiceCnt ?? _voteInfo.options.length;
|
late final _maxCnt = _voteInfo.choiceCnt ?? _voteInfo.options.length;
|
||||||
final isLogin = Accounts.main.isLogin;
|
final isLogin = Accounts.main.isLogin;
|
||||||
late final Rxn<List<FolloweeVote>> followeeVote = Rxn<List<FolloweeVote>>();
|
late final followeeVote = Rxn<List<FolloweeVote>>();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -551,18 +551,15 @@ Future<void> showVoteDialog(
|
|||||||
]) async {
|
]) async {
|
||||||
final voteInfo = await DynamicsHttp.voteInfo(voteId);
|
final voteInfo = await DynamicsHttp.voteInfo(voteId);
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
if (voteInfo.isSuccess) {
|
if (voteInfo case Success(:final response)) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => Dialog(
|
builder: (context) => Dialog(
|
||||||
constraints: const BoxConstraints(
|
constraints: const BoxConstraints(minWidth: 280, maxWidth: 625),
|
||||||
minWidth: 280,
|
|
||||||
maxWidth: 625,
|
|
||||||
),
|
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(24),
|
padding: const .all(24),
|
||||||
child: VotePanel(
|
child: VotePanel(
|
||||||
voteInfo: voteInfo.data,
|
voteInfo: response,
|
||||||
onVote: (votes, anonymous) => DynamicsHttp.doVote(
|
onVote: (votes, anonymous) => DynamicsHttp.doVote(
|
||||||
voteId: voteId,
|
voteId: voteId,
|
||||||
votes: votes.toList(),
|
votes: votes.toList(),
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
|||||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||||
import 'package:PiliPlus/common/widgets/pair.dart';
|
import 'package:PiliPlus/common/widgets/pair.dart';
|
||||||
import 'package:PiliPlus/common/widgets/sliver/sliver_pinned_header.dart';
|
import 'package:PiliPlus/common/widgets/sliver/sliver_pinned_header.dart';
|
||||||
|
import 'package:PiliPlus/http/constants.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
import 'package:PiliPlus/models/common/image_type.dart';
|
import 'package:PiliPlus/models/common/image_type.dart';
|
||||||
import 'package:PiliPlus/models_new/dynamic/dyn_topic_feed/item.dart';
|
import 'package:PiliPlus/models_new/dynamic/dyn_topic_feed/item.dart';
|
||||||
@@ -315,7 +316,7 @@ class _DynTopicPageState extends State<DynTopicPage> with DynMixin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PageUtils.inAppWebview(
|
PageUtils.inAppWebview(
|
||||||
'https://www.bilibili.com/h5/topic-active/topic-report?topic_id=${_controller.topicId}&topic_name=${_controller.topicName}&${ThemeUtils.themeUrl(colorScheme.isDark)}',
|
'${HttpString.baseUrl}/h5/topic-active/topic-report?topic_id=${_controller.topicId}&topic_name=${_controller.topicName}&${ThemeUtils.themeUrl(colorScheme.isDark)}',
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:PiliPlus/http/search.dart';
|
|||||||
import 'package:PiliPlus/models/common/fav_type.dart';
|
import 'package:PiliPlus/models/common/fav_type.dart';
|
||||||
import 'package:PiliPlus/models/common/video/source_type.dart';
|
import 'package:PiliPlus/models/common/video/source_type.dart';
|
||||||
import 'package:PiliPlus/pages/audio/view.dart';
|
import 'package:PiliPlus/pages/audio/view.dart';
|
||||||
|
import 'package:PiliPlus/pages/dynamics/widgets/vote.dart';
|
||||||
import 'package:PiliPlus/pages/fan/view.dart';
|
import 'package:PiliPlus/pages/fan/view.dart';
|
||||||
import 'package:PiliPlus/pages/follow/view.dart';
|
import 'package:PiliPlus/pages/follow/view.dart';
|
||||||
import 'package:PiliPlus/pages/follow_type/followed/view.dart';
|
import 'package:PiliPlus/pages/follow_type/followed/view.dart';
|
||||||
@@ -478,13 +479,25 @@ abstract final class PiliScheme {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String path = uri.path;
|
final String path = uri.path;
|
||||||
|
late final queryParameters = uri.queryParameters;
|
||||||
|
|
||||||
if (host.contains('t.bilibili.com')) {
|
if (host.contains('t.bilibili.com')) {
|
||||||
bool hasMatch = _onPushDynDetail(uri, off);
|
if (_onPushDynDetail(uri, off)) {
|
||||||
if (!hasMatch) {
|
return true;
|
||||||
launchURL();
|
} else if (path.startsWith('/vote')) {
|
||||||
|
// t.bilibili.com/vote/h5/index?vote_id={{vote_id}}#/result
|
||||||
|
if (queryParameters['vote_id'] case final voteIdStr?) {
|
||||||
|
final voteId = int.tryParse(voteIdStr);
|
||||||
|
if (voteId != null) {
|
||||||
|
if (Get.context != null) {
|
||||||
|
showVoteDialog(Get.context!, voteId);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return hasMatch;
|
launchURL();
|
||||||
|
return false;
|
||||||
} else if (host.contains('live.bilibili.com')) {
|
} else if (host.contains('live.bilibili.com')) {
|
||||||
String? roomId = uriDigitRegExp.firstMatch(path)?.group(1);
|
String? roomId = uriDigitRegExp.firstMatch(path)?.group(1);
|
||||||
if (roomId != null) {
|
if (roomId != null) {
|
||||||
@@ -513,8 +526,6 @@ abstract final class PiliScheme {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
late final queryParameters = uri.queryParameters;
|
|
||||||
|
|
||||||
// space.bilibili.com/h5/follow?mid={{mid}}&type={{type}}
|
// space.bilibili.com/h5/follow?mid={{mid}}&type={{type}}
|
||||||
if (path.startsWith('/h5/follow')) {
|
if (path.startsWith('/h5/follow')) {
|
||||||
final mid = queryParameters['mid'];
|
final mid = queryParameters['mid'];
|
||||||
|
|||||||
Reference in New Issue
Block a user