mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: create dyn antifraud
Closes #278 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
|
|
||||||
import '../models/dynamics/result.dart';
|
import '../models/dynamics/result.dart';
|
||||||
import '../models/dynamics/up.dart';
|
import '../models/dynamics/up.dart';
|
||||||
@@ -84,17 +85,23 @@ class DynamicsHttp {
|
|||||||
|
|
||||||
//
|
//
|
||||||
static Future dynamicDetail({
|
static Future dynamicDetail({
|
||||||
String? id,
|
dynamic id,
|
||||||
dynamic rid,
|
dynamic rid,
|
||||||
dynamic type,
|
dynamic type,
|
||||||
|
bool? clearCookie,
|
||||||
}) async {
|
}) async {
|
||||||
var res = await Request().get(Api.dynamicDetail, queryParameters: {
|
var res = await Request().get(
|
||||||
'timezone_offset': -480,
|
Api.dynamicDetail,
|
||||||
if (id != null) 'id': id,
|
queryParameters: {
|
||||||
if (rid != null) 'rid': rid,
|
'timezone_offset': -480,
|
||||||
if (type != null) 'type': type,
|
if (id != null) 'id': id,
|
||||||
'features': 'itemOpusStyle',
|
if (rid != null) 'rid': rid,
|
||||||
});
|
if (type != null) 'type': type,
|
||||||
|
'features': 'itemOpusStyle',
|
||||||
|
},
|
||||||
|
options:
|
||||||
|
clearCookie == true ? Options(extra: {'clearCookie': true}) : null,
|
||||||
|
);
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
try {
|
try {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -212,7 +212,10 @@ class MsgHttp {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
return {'status': true};
|
return {
|
||||||
|
'status': true,
|
||||||
|
'data': res.data['data'],
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
'status': false,
|
'status': false,
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
|
import 'package:PiliPlus/http/dynamics.dart';
|
||||||
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
import 'package:PiliPlus/http/msg.dart';
|
import 'package:PiliPlus/http/msg.dart';
|
||||||
|
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||||
import 'package:PiliPlus/pages/common/common_publish_page.dart';
|
import 'package:PiliPlus/pages/common/common_publish_page.dart';
|
||||||
|
import 'package:PiliPlus/pages/dynamics/tab/controller.dart';
|
||||||
import 'package:PiliPlus/pages/dynamics/view.dart';
|
import 'package:PiliPlus/pages/dynamics/view.dart';
|
||||||
import 'package:PiliPlus/pages/emote/controller.dart';
|
import 'package:PiliPlus/pages/emote/controller.dart';
|
||||||
import 'package:PiliPlus/pages/emote/view.dart';
|
import 'package:PiliPlus/pages/emote/view.dart';
|
||||||
import 'package:PiliPlus/pages/video/detail/reply_new/toolbar_icon_button.dart';
|
import 'package:PiliPlus/pages/video/detail/reply_new/toolbar_icon_button.dart';
|
||||||
import 'package:PiliPlus/utils/storage.dart';
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -483,12 +488,36 @@ class _CreateDynPanelState extends CommonPublishPageState<CreateDynPanel> {
|
|||||||
replyOption: _replyOption,
|
replyOption: _replyOption,
|
||||||
privatePub: _isPrivate ? 1 : null,
|
privatePub: _isPrivate ? 1 : null,
|
||||||
);
|
);
|
||||||
|
SmartDialog.dismiss();
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
Get.back();
|
Get.back();
|
||||||
SmartDialog.dismiss();
|
|
||||||
SmartDialog.showToast('发布成功');
|
SmartDialog.showToast('发布成功');
|
||||||
|
try {
|
||||||
|
// insert
|
||||||
|
dynamic id = result['data']['dyn_id'];
|
||||||
|
if (id != null) {
|
||||||
|
await Future.delayed(const Duration(milliseconds: 200));
|
||||||
|
dynamic res = await DynamicsHttp.dynamicDetail(id: id);
|
||||||
|
if (res['status']) {
|
||||||
|
final ctr = Get.find<DynamicsTabController>(tag: 'all');
|
||||||
|
List list = ctr.loadingState.value is Success
|
||||||
|
? (ctr.loadingState.value as Success).response
|
||||||
|
: <DynamicItemModel>[];
|
||||||
|
list.insert(0, res['data']);
|
||||||
|
ctr.loadingState.value = LoadingState.success(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('create dyn $e');
|
||||||
|
}
|
||||||
|
if (GStorage.enableCreateDynAntifraud) {
|
||||||
|
try {
|
||||||
|
Utils.checkCreatedDyn(result['data']['dyn_id'], editController.text);
|
||||||
|
} catch (e) {
|
||||||
|
SmartDialog.showToast(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.dismiss();
|
|
||||||
SmartDialog.showToast(result['msg']);
|
SmartDialog.showToast(result['msg']);
|
||||||
debugPrint('failed to publish: ${result['msg']}');
|
debugPrint('failed to publish: ${result['msg']}');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:PiliPlus/pages/emote/view.dart';
|
|||||||
import 'package:PiliPlus/pages/video/detail/reply_new/toolbar_icon_button.dart';
|
import 'package:PiliPlus/pages/video/detail/reply_new/toolbar_icon_button.dart';
|
||||||
import 'package:PiliPlus/utils/extension.dart';
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
import 'package:PiliPlus/utils/storage.dart';
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -385,6 +386,13 @@ class _RepostPanelState extends CommonPublishPageState<RepostPanel> {
|
|||||||
Get.back();
|
Get.back();
|
||||||
SmartDialog.showToast('转发成功');
|
SmartDialog.showToast('转发成功');
|
||||||
widget.callback?.call();
|
widget.callback?.call();
|
||||||
|
if (GStorage.enableCreateDynAntifraud) {
|
||||||
|
try {
|
||||||
|
Utils.checkCreatedDyn(result['data']['dyn_id'], editController.text);
|
||||||
|
} catch (e) {
|
||||||
|
SmartDialog.showToast(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast(result['msg']);
|
SmartDialog.showToast(result['msg']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1957,11 +1957,10 @@ List<SettingsModel> get extraSettings => [
|
|||||||
leading: Stack(
|
leading: Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.shield),
|
const Icon(Icons.shield_outlined),
|
||||||
Icon(
|
Icon(
|
||||||
Icons.reply,
|
Icons.reply,
|
||||||
size: 16,
|
size: 14,
|
||||||
color: Theme.of(Get.context!).colorScheme.surface,
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -1972,10 +1971,30 @@ List<SettingsModel> get extraSettings => [
|
|||||||
settingsType: SettingsType.sw1tch,
|
settingsType: SettingsType.sw1tch,
|
||||||
title: '使用「哔哩发评反诈」检查评论',
|
title: '使用「哔哩发评反诈」检查评论',
|
||||||
subtitle: '仅对Android生效',
|
subtitle: '仅对Android生效',
|
||||||
leading: Icon(FontAwesomeIcons.b),
|
leading: Icon(
|
||||||
|
FontAwesomeIcons.b,
|
||||||
|
size: 22,
|
||||||
|
),
|
||||||
setKey: SettingBoxKey.biliSendCommAntifraud,
|
setKey: SettingBoxKey.biliSendCommAntifraud,
|
||||||
defaultVal: false,
|
defaultVal: false,
|
||||||
),
|
),
|
||||||
|
SettingsModel(
|
||||||
|
settingsType: SettingsType.sw1tch,
|
||||||
|
title: '发布/转发动态反诈',
|
||||||
|
subtitle: '发布/转发动态后检查动态是否可见',
|
||||||
|
leading: Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.shield_outlined),
|
||||||
|
Icon(
|
||||||
|
Icons.motion_photos_on,
|
||||||
|
size: 12,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
setKey: SettingBoxKey.enableCreateDynAntifraud,
|
||||||
|
defaultVal: false,
|
||||||
|
),
|
||||||
SettingsModel(
|
SettingsModel(
|
||||||
settingsType: SettingsType.sw1tch,
|
settingsType: SettingsType.sw1tch,
|
||||||
title: '屏蔽带货动态',
|
title: '屏蔽带货动态',
|
||||||
|
|||||||
@@ -369,6 +369,9 @@ class GStorage {
|
|||||||
static bool get biliSendCommAntifraud => GStorage.setting
|
static bool get biliSendCommAntifraud => GStorage.setting
|
||||||
.get(SettingBoxKey.biliSendCommAntifraud, defaultValue: false);
|
.get(SettingBoxKey.biliSendCommAntifraud, defaultValue: false);
|
||||||
|
|
||||||
|
static bool get enableCreateDynAntifraud => GStorage.setting
|
||||||
|
.get(SettingBoxKey.enableCreateDynAntifraud, defaultValue: false);
|
||||||
|
|
||||||
static bool get coinWithLike =>
|
static bool get coinWithLike =>
|
||||||
GStorage.setting.get(SettingBoxKey.coinWithLike, defaultValue: false);
|
GStorage.setting.get(SettingBoxKey.coinWithLike, defaultValue: false);
|
||||||
|
|
||||||
@@ -613,6 +616,7 @@ class SettingBoxKey {
|
|||||||
showDmChart = 'showDmChart',
|
showDmChart = 'showDmChart',
|
||||||
enableCommAntifraud = 'enableCommAntifraud',
|
enableCommAntifraud = 'enableCommAntifraud',
|
||||||
biliSendCommAntifraud = 'biliSendCommAntifraud',
|
biliSendCommAntifraud = 'biliSendCommAntifraud',
|
||||||
|
enableCreateDynAntifraud = 'enableCreateDynAntifraud',
|
||||||
coinWithLike = 'coinWithLike',
|
coinWithLike = 'coinWithLike',
|
||||||
isPureBlackTheme = 'isPureBlackTheme',
|
isPureBlackTheme = 'isPureBlackTheme',
|
||||||
antiGoodsDyn = 'antiGoodsDyn',
|
antiGoodsDyn = 'antiGoodsDyn',
|
||||||
|
|||||||
@@ -46,6 +46,20 @@ class Utils {
|
|||||||
|
|
||||||
static const channel = MethodChannel("PiliPlus");
|
static const channel = MethodChannel("PiliPlus");
|
||||||
|
|
||||||
|
static void checkCreatedDyn(id, dynText) async {
|
||||||
|
if (id != null) {
|
||||||
|
dynamic res = await DynamicsHttp.dynamicDetail(id: id, clearCookie: true);
|
||||||
|
showDialog(
|
||||||
|
context: Get.context!,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: Text('动态检查结果'),
|
||||||
|
content: SelectableText(
|
||||||
|
'${res['status'] ? '无账号状态下找到了你的动态,动态正常!' : '你的动态被shadow ban(仅自己可见)!'} \n\n动态内容: $dynText'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 动态点赞
|
// 动态点赞
|
||||||
static Future onLikeDynamic(item, VoidCallback callback) async {
|
static Future onLikeDynamic(item, VoidCallback callback) async {
|
||||||
feedBack();
|
feedBack();
|
||||||
|
|||||||
Reference in New Issue
Block a user