mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-23 10:40:08 +08:00
@@ -305,21 +305,21 @@ abstract final class ImageUtils {
|
||||
required String fileName,
|
||||
String ext = 'png',
|
||||
}) async {
|
||||
SaveResult? result;
|
||||
SaveResult? res;
|
||||
fileName += '.$ext';
|
||||
if (PlatformUtils.isMobile) {
|
||||
SmartDialog.showLoading(msg: '正在保存');
|
||||
result = await SaverGallery.saveImage(
|
||||
res = await SaverGallery.saveImage(
|
||||
bytes,
|
||||
fileName: fileName,
|
||||
androidRelativePath: _androidRelativePath,
|
||||
skipIfExists: false,
|
||||
);
|
||||
SmartDialog.dismiss();
|
||||
if (result.isSuccess) {
|
||||
if (res.isSuccess) {
|
||||
SmartDialog.showToast(' 已保存 ');
|
||||
} else {
|
||||
SmartDialog.showToast('保存失败,${result.errorMessage}');
|
||||
SmartDialog.showToast('保存失败,${res.errorMessage}');
|
||||
}
|
||||
} else {
|
||||
SmartDialog.dismiss();
|
||||
@@ -333,9 +333,9 @@ abstract final class ImageUtils {
|
||||
}
|
||||
await File(savePath).writeAsBytes(bytes);
|
||||
SmartDialog.showToast(' 已保存 ');
|
||||
result = SaveResult(true, null);
|
||||
res = SaveResult(true, null);
|
||||
}
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
static Future<void> saveFileImg({
|
||||
@@ -350,9 +350,9 @@ abstract final class ImageUtils {
|
||||
SmartDialog.showToast("文件不存在");
|
||||
return;
|
||||
}
|
||||
SaveResult? result;
|
||||
SaveResult? res;
|
||||
if (PlatformUtils.isMobile) {
|
||||
result = await SaverGallery.saveFile(
|
||||
res = await SaverGallery.saveFile(
|
||||
filePath: filePath,
|
||||
fileName: fileName,
|
||||
androidRelativePath: _androidRelativePath,
|
||||
@@ -370,13 +370,13 @@ abstract final class ImageUtils {
|
||||
}
|
||||
await file.copy(savePath);
|
||||
if (del) file.tryDel();
|
||||
result = SaveResult(true, null);
|
||||
res = SaveResult(true, null);
|
||||
}
|
||||
if (needToast) {
|
||||
if (result.isSuccess) {
|
||||
if (res.isSuccess) {
|
||||
SmartDialog.showToast(' 已保存 ');
|
||||
} else {
|
||||
SmartDialog.showToast('保存失败,${result.errorMessage}');
|
||||
SmartDialog.showToast('保存失败,${res.errorMessage}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import 'dart:async' show FutureOr;
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/user.dart';
|
||||
import 'package:PiliPlus/main.dart';
|
||||
import 'package:PiliPlus/models/user/info.dart';
|
||||
import 'package:PiliPlus/services/account_service.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
@@ -46,14 +46,13 @@ abstract final class LoginUtils {
|
||||
|
||||
static Future<void> onLoginMain() async {
|
||||
final account = Accounts.main;
|
||||
final result = await UserHttp.userInfo();
|
||||
if (result.isSuccess) {
|
||||
final res = await UserHttp.userInfo();
|
||||
if (res case Success(:final response)) {
|
||||
setWebCookie(account);
|
||||
RequestUtils.syncHistoryStatus();
|
||||
final UserInfoData data = result.data;
|
||||
if (data.isLogin == true) {
|
||||
if (response.isLogin == true) {
|
||||
final accountService = Get.find<AccountService>()
|
||||
..face.value = data.face!;
|
||||
..face.value = response.face!;
|
||||
|
||||
if (accountService.isLogin.value) {
|
||||
accountService.isLogin.refresh();
|
||||
@@ -62,15 +61,15 @@ abstract final class LoginUtils {
|
||||
}
|
||||
|
||||
SmartDialog.showToast('main登录成功');
|
||||
if (data != Pref.userInfoCache) {
|
||||
await GStorage.userInfo.put('userInfoCache', data);
|
||||
if (response != Pref.userInfoCache) {
|
||||
await GStorage.userInfo.put('userInfoCache', response);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 获取用户信息失败
|
||||
await Accounts.deleteAll({account});
|
||||
SmartDialog.showNotify(
|
||||
msg: '登录失败,请检查cookie是否正确,${result.toString()}',
|
||||
msg: '登录失败,请检查cookie是否正确,${res.toString()}',
|
||||
notifyType: NotifyType.warning,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ import 'package:PiliPlus/common/widgets/interactiveviewer_gallery/hero_dialog_ro
|
||||
import 'package:PiliPlus/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart';
|
||||
import 'package:PiliPlus/grpc/im.dart';
|
||||
import 'package:PiliPlus/http/dynamics.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/search.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/common/image_preview_type.dart';
|
||||
import 'package:PiliPlus/models/common/video/video_type.dart';
|
||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_info_model/episode.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_info_model/result.dart';
|
||||
import 'package:PiliPlus/pages/common/common_intro_controller.dart';
|
||||
import 'package:PiliPlus/pages/common/publish/publish_route.dart';
|
||||
import 'package:PiliPlus/pages/contact/view.dart';
|
||||
@@ -66,18 +66,22 @@ abstract final class PageUtils {
|
||||
|
||||
List<UserModel> userList = <UserModel>[];
|
||||
|
||||
final shareListRes = await ImGrpc.shareList(size: 3);
|
||||
if (shareListRes.isSuccess && shareListRes.data.sessionList.isNotEmpty) {
|
||||
userList.addAll(
|
||||
shareListRes.data.sessionList.map<UserModel>(
|
||||
(item) => UserModel(
|
||||
mid: item.talkerId.toInt(),
|
||||
name: item.talkerUname,
|
||||
avatar: item.talkerIcon,
|
||||
final res = await ImGrpc.shareList(size: 5);
|
||||
if (res case Success(:final response)) {
|
||||
if (response.sessionList.isNotEmpty) {
|
||||
userList.addAll(
|
||||
response.sessionList.map<UserModel>(
|
||||
(item) => UserModel(
|
||||
mid: item.talkerId.toInt(),
|
||||
name: item.talkerUname,
|
||||
avatar: item.talkerIcon,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (context.mounted) {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (userList.isEmpty && context.mounted) {
|
||||
final UserModel? userModel = await Navigator.of(context).push(
|
||||
GetPageRoute(page: () => const ContactPage()),
|
||||
);
|
||||
@@ -291,9 +295,8 @@ abstract final class PageUtils {
|
||||
type: rid != null ? 2 : null,
|
||||
);
|
||||
SmartDialog.dismiss();
|
||||
if (res.isSuccess) {
|
||||
final data = res.data;
|
||||
if (data.basic?.commentType == 12) {
|
||||
if (res case Success(:final response)) {
|
||||
if (response.basic?.commentType == 12) {
|
||||
toDupNamed(
|
||||
'/articlePage',
|
||||
parameters: {
|
||||
@@ -306,7 +309,7 @@ abstract final class PageUtils {
|
||||
toDupNamed(
|
||||
'/dynamicDetail',
|
||||
arguments: {
|
||||
'item': data,
|
||||
'item': response,
|
||||
},
|
||||
off: off,
|
||||
);
|
||||
@@ -808,11 +811,10 @@ abstract final class PageUtils {
|
||||
}) async {
|
||||
try {
|
||||
SmartDialog.showLoading(msg: '资源获取中');
|
||||
final result = await SearchHttp.pgcInfo(seasonId: seasonId, epId: epId);
|
||||
final res = await SearchHttp.pgcInfo(seasonId: seasonId, epId: epId);
|
||||
SmartDialog.dismiss();
|
||||
if (result.isSuccess) {
|
||||
PgcInfoModel data = result.data;
|
||||
final episodes = data.episodes;
|
||||
if (res case Success(:final response)) {
|
||||
final episodes = response.episodes;
|
||||
final hasEpisode = episodes != null && episodes.isNotEmpty;
|
||||
|
||||
EpisodeItem? episode;
|
||||
@@ -822,13 +824,13 @@ abstract final class PageUtils {
|
||||
videoType: VideoType.ugc,
|
||||
bvid: episode.bvid!,
|
||||
cid: episode.cid!,
|
||||
seasonId: data.seasonId,
|
||||
seasonId: response.seasonId,
|
||||
epId: episode.epId,
|
||||
cover: episode.cover,
|
||||
progress: progress == null ? null : int.tryParse(progress),
|
||||
extraArguments: {
|
||||
'pgcApi': true,
|
||||
'pgcItem': data,
|
||||
'pgcItem': response,
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -843,7 +845,7 @@ abstract final class PageUtils {
|
||||
|
||||
// find section
|
||||
if (episode == null) {
|
||||
final sections = data.section;
|
||||
final sections = response.section;
|
||||
if (sections != null && sections.isNotEmpty) {
|
||||
for (final section in sections) {
|
||||
final episodes = section.episodes;
|
||||
@@ -864,24 +866,24 @@ abstract final class PageUtils {
|
||||
if (hasEpisode) {
|
||||
episode ??= findEpisode(
|
||||
episodes,
|
||||
epId: data.userStatus?.progress?.lastEpId,
|
||||
epId: response.userStatus?.progress?.lastEpId,
|
||||
);
|
||||
toVideoPage(
|
||||
videoType: VideoType.pgc,
|
||||
bvid: episode.bvid!,
|
||||
cid: episode.cid!,
|
||||
seasonId: data.seasonId,
|
||||
seasonId: response.seasonId,
|
||||
epId: episode.epId,
|
||||
pgcType: data.type,
|
||||
pgcType: response.type,
|
||||
cover: episode.cover,
|
||||
progress: progress == null ? null : int.tryParse(progress),
|
||||
extraArguments: {
|
||||
'pgcItem': data,
|
||||
'pgcItem': response,
|
||||
},
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
episode ??= data.section?.firstOrNull?.episodes?.firstOrNull;
|
||||
episode ??= response.section?.firstOrNull?.episodes?.firstOrNull;
|
||||
if (episode != null) {
|
||||
viewSection(episode);
|
||||
return;
|
||||
@@ -890,7 +892,7 @@ abstract final class PageUtils {
|
||||
|
||||
SmartDialog.showToast('资源加载失败');
|
||||
} else {
|
||||
result.toast();
|
||||
res.toast();
|
||||
}
|
||||
} catch (e) {
|
||||
SmartDialog.dismiss();
|
||||
@@ -908,9 +910,8 @@ abstract final class PageUtils {
|
||||
SmartDialog.showLoading(msg: '资源获取中');
|
||||
final res = await SearchHttp.pugvInfo(seasonId: seasonId, epId: epId);
|
||||
SmartDialog.dismiss();
|
||||
if (res.isSuccess) {
|
||||
PgcInfoModel data = res.data;
|
||||
final episodes = data.episodes;
|
||||
if (res case Success(:final response)) {
|
||||
final episodes = response.episodes;
|
||||
if (episodes != null && episodes.isNotEmpty) {
|
||||
EpisodeItem? episode;
|
||||
if (aid != null) {
|
||||
@@ -918,18 +919,18 @@ abstract final class PageUtils {
|
||||
}
|
||||
episode ??= findEpisode(
|
||||
episodes,
|
||||
epId: epId ?? data.userStatus?.progress?.lastEpId,
|
||||
epId: epId ?? response.userStatus?.progress?.lastEpId,
|
||||
isPgc: false,
|
||||
);
|
||||
toVideoPage(
|
||||
videoType: VideoType.pugv,
|
||||
aid: episode.aid!,
|
||||
cid: episode.cid!,
|
||||
seasonId: data.seasonId,
|
||||
seasonId: response.seasonId,
|
||||
epId: episode.id,
|
||||
cover: episode.cover,
|
||||
extraArguments: {
|
||||
'pgcItem': data,
|
||||
'pgcItem': response,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/reply.dart';
|
||||
import 'package:PiliPlus/models/common/reply/reply_sort_type.dart';
|
||||
import 'package:PiliPlus/models_new/reply/data.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
import 'package:PiliPlus/utils/extension/iterable_ext.dart';
|
||||
@@ -155,13 +154,12 @@ abstract final class ReplyUtils {
|
||||
page: 1,
|
||||
);
|
||||
|
||||
if (res is Error) {
|
||||
SmartDialog.showToast('获取评论主列表时发生错误:${res.errMsg}');
|
||||
if (res case Error(:final errMsg)) {
|
||||
SmartDialog.showToast('获取评论主列表时发生错误:$errMsg');
|
||||
return;
|
||||
} else if (res.isSuccess) {
|
||||
ReplyData replies = res.data;
|
||||
int index =
|
||||
replies.replies?.indexWhere((item) => item.rpid == id) ?? -1;
|
||||
} else if (res case Success(:final response)) {
|
||||
final index =
|
||||
response.replies?.indexWhere((item) => item.rpid == id) ?? -1;
|
||||
if (index != -1) {
|
||||
// found
|
||||
showReplyCheckResult('无账号状态下找到了你的评论,评论正常!\n\n你的评论:$message');
|
||||
|
||||
@@ -279,17 +279,16 @@ abstract final class RequestUtils {
|
||||
if (id != null) {
|
||||
await Future.delayed(const Duration(milliseconds: 450));
|
||||
final res = await DynamicsHttp.dynamicDetail(id: id);
|
||||
if (res.isSuccess) {
|
||||
if (res case final Success<DynamicItemModel> e) {
|
||||
final ctr = Get.find<DynamicsTabController>(tag: 'all');
|
||||
if (ctr.loadingState.value.isSuccess) {
|
||||
List<DynamicItemModel>? list = ctr.loadingState.value.data;
|
||||
if (list != null) {
|
||||
list.insert(0, res.data);
|
||||
if (ctr.loadingState.value case Success(:final response)) {
|
||||
if (response != null) {
|
||||
response.insert(0, e.response);
|
||||
ctr.loadingState.refresh();
|
||||
return;
|
||||
}
|
||||
}
|
||||
ctr.loadingState.value = Success([res.data]);
|
||||
ctr.loadingState.value = Success([e.response]);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -393,8 +392,10 @@ abstract final class RequestUtils {
|
||||
required dynamic mid,
|
||||
}) {
|
||||
FavHttp.allFavFolders(mid).then((res) {
|
||||
if (context.mounted && res.dataOrNull?.list?.isNotEmpty == true) {
|
||||
final list = res.data.list!;
|
||||
if (!context.mounted) return;
|
||||
if (res case Success(:final response)) {
|
||||
final list = response.list;
|
||||
if (list == null || list.isEmpty) return;
|
||||
int? checkedId;
|
||||
showDialog(
|
||||
context: context,
|
||||
@@ -653,16 +654,15 @@ abstract final class RequestUtils {
|
||||
|
||||
static Future<void> showUserRealName(String mid) async {
|
||||
final res = await UserHttp.getUserRealName(mid);
|
||||
if (res.isSuccess) {
|
||||
final data = res.data;
|
||||
final show = !data.name.isNullOrEmpty;
|
||||
if (res case Success(:final response)) {
|
||||
final show = !response.name.isNullOrEmpty;
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) => AlertDialog(
|
||||
title: SelectableText(
|
||||
show ? data.name! : data.rejectPage?.title ?? '',
|
||||
show ? response.name! : response.rejectPage?.title ?? '',
|
||||
),
|
||||
content: show ? null : Text(data.rejectPage?.text ?? ''),
|
||||
content: show ? null : Text(response.rejectPage?.text ?? ''),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: Get.back,
|
||||
|
||||
Reference in New Issue
Block a user