diff --git a/lib/pages/dynamics/create_dyn_panel.dart b/lib/pages/dynamics/create_dyn_panel.dart index cec69434c..e07180277 100644 --- a/lib/pages/dynamics/create_dyn_panel.dart +++ b/lib/pages/dynamics/create_dyn_panel.dart @@ -488,10 +488,11 @@ class _CreateDynPanelState extends CommonPublishPageState { if (result['status']) { Get.back(); SmartDialog.showToast('发布成功'); - Future.wait([ - Utils.insertCreatedDyn(result), - Utils.checkCreatedDyn(result, editController.text) - ]); + Utils.insertCreatedDyn(result); + Utils.checkCreatedDyn( + id: result['data']?['dyn_id'], + dynText: editController.text, + ); } else { SmartDialog.showToast(result['msg']); debugPrint('failed to publish: ${result['msg']}'); diff --git a/lib/pages/dynamics/repost_dyn_panel.dart b/lib/pages/dynamics/repost_dyn_panel.dart index beb06246e..8d000c2c3 100644 --- a/lib/pages/dynamics/repost_dyn_panel.dart +++ b/lib/pages/dynamics/repost_dyn_panel.dart @@ -386,10 +386,11 @@ class _RepostPanelState extends CommonPublishPageState { Get.back(); SmartDialog.showToast('转发成功'); widget.callback?.call(); - Future.wait([ - Utils.insertCreatedDyn(result), - Utils.checkCreatedDyn(result, editController.text) - ]); + Utils.insertCreatedDyn(result); + Utils.checkCreatedDyn( + id: result['data']?['dyn_id'], + dynText: editController.text, + ); } else { SmartDialog.showToast(result['msg']); } diff --git a/lib/pages/dynamics/widgets/author_panel.dart b/lib/pages/dynamics/widgets/author_panel.dart index dc0a5aefb..83127d441 100644 --- a/lib/pages/dynamics/widgets/author_panel.dart +++ b/lib/pages/dynamics/widgets/author_panel.dart @@ -6,7 +6,6 @@ import 'package:PiliPlus/utils/storage.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:dio/dio.dart'; 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:PiliPlus/common/widgets/network_img_layer.dart'; @@ -22,6 +21,7 @@ class AuthorPanel extends StatelessWidget { final Function? addBannedList; final String? source; final Function? onRemove; + const AuthorPanel({ super.key, required this.item, @@ -310,6 +310,62 @@ class AuthorPanel extends StatelessWidget { }, minLeadingWidth: 0, ), + if (item.modules.moduleAuthor.mid == Accounts.main.mid) ...[ + ListTile( + onTap: () { + Get.back(); + Utils.checkCreatedDyn(id: item.idStr, isManual: true); + }, + minLeadingWidth: 0, + leading: Stack( + alignment: Alignment.center, + children: [ + const Icon(Icons.shield_outlined, size: 19), + const Icon(Icons.published_with_changes_sharp, size: 12), + ], + ), + title: + Text('检查动态', style: Theme.of(context).textTheme.titleSmall!), + ), + if (onRemove != null) + ListTile( + onTap: () { + Get.back(); + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('确定删除该动态?'), + actions: [ + TextButton( + onPressed: Get.back, + child: Text( + '取消', + style: TextStyle( + color: Theme.of(context).colorScheme.outline, + ), + ), + ), + TextButton( + onPressed: () { + Get.back(); + onRemove?.call(item.idStr); + }, + child: const Text('确定'), + ), + ], + ), + ); + }, + minLeadingWidth: 0, + leading: Icon(Icons.delete_outline, + color: Theme.of(context).colorScheme.error, size: 19), + title: Text('删除', + style: Theme.of(context) + .textTheme + .titleSmall! + .copyWith(color: Theme.of(context).colorScheme.error)), + ), + ], if (Accounts.main.isLogin) ListTile( title: Text( @@ -357,44 +413,6 @@ class AuthorPanel extends StatelessWidget { }, minLeadingWidth: 0, ), - if (item.modules.moduleAuthor.mid == Accounts.main.mid && - onRemove != null) - ListTile( - onTap: () async { - Get.back(); - showDialog( - context: context, - builder: (context) => AlertDialog( - title: const Text('确定删除该动态?'), - actions: [ - TextButton( - onPressed: Get.back, - child: Text( - '取消', - style: TextStyle( - color: Theme.of(context).colorScheme.outline, - ), - ), - ), - TextButton( - onPressed: () { - Get.back(); - onRemove?.call(item.idStr); - }, - child: const Text('确定'), - ), - ], - )); - }, - minLeadingWidth: 0, - leading: Icon(Icons.delete_outline, - color: Theme.of(context).colorScheme.error, size: 19), - title: Text('删除', - style: Theme.of(context) - .textTheme - .titleSmall! - .copyWith(color: Theme.of(context).colorScheme.error)), - ), const Divider(thickness: 0.1, height: 1), ListTile( onTap: Get.back, diff --git a/lib/utils/accounts/account_manager/account_mgr.dart b/lib/utils/accounts/account_manager/account_mgr.dart index 9677e1b32..6f52f6b11 100644 --- a/lib/utils/accounts/account_manager/account_mgr.dart +++ b/lib/utils/accounts/account_manager/account_mgr.dart @@ -123,6 +123,11 @@ class AccountManager extends Interceptor { } return handler.next(options); } else { + if (account is AnonymousAccount) { + options.headers[HttpHeaders.cookieHeader] = ''; + handler.next(options); + return; + } account.cookieJar.loadForRequest(options.uri).then((cookies) { final previousCookies = options.headers[HttpHeaders.cookieHeader] as String?; diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index e03268d1b..8467bc65a 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -472,12 +472,13 @@ class Utils { } } - static Future checkCreatedDyn(result, dynText) async { - if (GStorage.enableCreateDynAntifraud) { + static Future checkCreatedDyn({id, dynText, isManual}) async { + if (isManual == true || GStorage.enableCreateDynAntifraud) { try { - dynamic id = result['data']['dyn_id']; if (id != null) { - await Future.delayed(const Duration(seconds: 5)); + if (isManual != true) { + await Future.delayed(const Duration(seconds: 5)); + } dynamic res = await DynamicsHttp.dynamicDetail(id: id, clearCookie: true); showDialog( @@ -485,11 +486,13 @@ class Utils { builder: (context) => AlertDialog( title: Text('动态检查结果'), content: SelectableText( - '${res['status'] ? '无账号状态下找到了你的动态,动态正常!' : '你的动态被shadow ban(仅自己可见)!'} \n\n动态内容: $dynText'), + '${res['status'] ? '无账号状态下找到了你的动态,动态正常!' : '你的动态被shadow ban(仅自己可见)!'}${dynText != null ? ' \n\n动态内容: $dynText' : ''}'), ), ); } - } catch (_) {} + } catch (e) { + debugPrint('check dyn error: $e'); + } } }