mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 08:38:18 +08:00
feat: pm: remove/setTop
This commit is contained in:
@@ -613,4 +613,8 @@ class Api {
|
|||||||
static const String videoTags = '/x/tag/archive/tags';
|
static const String videoTags = '/x/tag/archive/tags';
|
||||||
|
|
||||||
static const String reportMember = '/ajax/report/add';
|
static const String reportMember = '/ajax/report/add';
|
||||||
|
|
||||||
|
static const String removeMsg = '/session_svr/v1/session_svr/remove_session';
|
||||||
|
|
||||||
|
static const String setTop = '/session_svr/v1/session_svr/set_top';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
import 'package:PiliPalaX/http/constants.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
|
||||||
import '../models/msg/account.dart';
|
import '../models/msg/account.dart';
|
||||||
@@ -142,6 +143,56 @@ class MsgHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future removeMsg(
|
||||||
|
dynamic talkerId,
|
||||||
|
) async {
|
||||||
|
String csrf = await Request.getCsrf();
|
||||||
|
Map<String, dynamic> data = await WbiSign().makSign({
|
||||||
|
'talker_id': talkerId,
|
||||||
|
'session_type': 1,
|
||||||
|
'build': 0,
|
||||||
|
'mobi_app': 'web',
|
||||||
|
'csrf_token': csrf,
|
||||||
|
'csrf': csrf
|
||||||
|
});
|
||||||
|
var res = await Request()
|
||||||
|
.post(HttpString.tUrl + Api.removeMsg, data: FormData.fromMap(data));
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
return {'status': true};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
'status': false,
|
||||||
|
'msg': res.data['message'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future setTop(
|
||||||
|
dynamic talkerId,
|
||||||
|
int opType,
|
||||||
|
) async {
|
||||||
|
String csrf = await Request.getCsrf();
|
||||||
|
Map<String, dynamic> data = await WbiSign().makSign({
|
||||||
|
'talker_id': talkerId,
|
||||||
|
'session_type': 1,
|
||||||
|
'op_type': opType,
|
||||||
|
'build': 0,
|
||||||
|
'mobi_app': 'web',
|
||||||
|
'csrf_token': csrf,
|
||||||
|
'csrf': csrf
|
||||||
|
});
|
||||||
|
var res = await Request()
|
||||||
|
.post(HttpString.tUrl + Api.setTop, data: FormData.fromMap(data));
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
return {'status': true};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
'status': false,
|
||||||
|
'msg': res.data['message'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 会话列表
|
// 会话列表
|
||||||
static Future sessionList({int? endTs}) async {
|
static Future sessionList({int? endTs}) async {
|
||||||
Map<String, dynamic> params = {
|
Map<String, dynamic> params = {
|
||||||
|
|||||||
@@ -268,10 +268,8 @@ class ReplyItem extends StatelessWidget {
|
|||||||
child: Text.rich(
|
child: Text.rich(
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
height: 1.75,
|
height: 1.75,
|
||||||
fontSize: Theme.of(context)
|
fontSize:
|
||||||
.textTheme
|
Theme.of(context).textTheme.bodyMedium!.fontSize),
|
||||||
.bodyMedium!
|
|
||||||
.fontSize),
|
|
||||||
TextSpan(
|
TextSpan(
|
||||||
children: [
|
children: [
|
||||||
if (replyItem!.isTop!) ...[
|
if (replyItem!.isTop!) ...[
|
||||||
@@ -298,7 +296,8 @@ class ReplyItem extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)),
|
),
|
||||||
|
),
|
||||||
if (didExceedMaxLines)
|
if (didExceedMaxLines)
|
||||||
Text(
|
Text(
|
||||||
'查看更多',
|
'查看更多',
|
||||||
|
|||||||
@@ -15,29 +15,29 @@ class WhisperController extends GetxController {
|
|||||||
Rx<MsgFeedUnread> msgFeedUnread = MsgFeedUnread().obs;
|
Rx<MsgFeedUnread> msgFeedUnread = MsgFeedUnread().obs;
|
||||||
RxList msgFeedTop = [
|
RxList msgFeedTop = [
|
||||||
{
|
{
|
||||||
"name":"回复我的",
|
"name": "回复我的",
|
||||||
"icon":Icons.message_outlined,
|
"icon": Icons.message_outlined,
|
||||||
"route": "/replyMe",
|
"route": "/replyMe",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"value": 0
|
"value": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"@我",
|
"name": "@我",
|
||||||
"icon":Icons.alternate_email_outlined,
|
"icon": Icons.alternate_email_outlined,
|
||||||
"route": "/atMe",
|
"route": "/atMe",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"value": 0
|
"value": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"收到的赞",
|
"name": "收到的赞",
|
||||||
"icon":Icons.favorite_border_outlined,
|
"icon": Icons.favorite_border_outlined,
|
||||||
"route": "/likeMe",
|
"route": "/likeMe",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"value": 0
|
"value": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"系统通知",
|
"name": "系统通知",
|
||||||
"icon":Icons.notifications_none_outlined,
|
"icon": Icons.notifications_none_outlined,
|
||||||
"route": "/sysMsg",
|
"route": "/sysMsg",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"value": 0
|
"value": 0
|
||||||
@@ -52,7 +52,8 @@ class WhisperController extends GetxController {
|
|||||||
msgFeedTop[1]["value"] = msgFeedUnread.value.at;
|
msgFeedTop[1]["value"] = msgFeedUnread.value.at;
|
||||||
msgFeedTop[2]["value"] = msgFeedUnread.value.like;
|
msgFeedTop[2]["value"] = msgFeedUnread.value.like;
|
||||||
msgFeedTop[3]["value"] = msgFeedUnread.value.sys_msg;
|
msgFeedTop[3]["value"] = msgFeedUnread.value.sys_msg;
|
||||||
if (GStorage.setting.get(SettingBoxKey.disableLikeMsg, defaultValue: false)) {
|
if (GStorage.setting
|
||||||
|
.get(SettingBoxKey.disableLikeMsg, defaultValue: false)) {
|
||||||
msgFeedTop[2]["value"] = -1;
|
msgFeedTop[2]["value"] = -1;
|
||||||
msgFeedTop[2]["enabled"] = false;
|
msgFeedTop[2]["enabled"] = false;
|
||||||
}
|
}
|
||||||
@@ -63,6 +64,41 @@ class WhisperController extends GetxController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future onRemove(int index) async {
|
||||||
|
var res = await MsgHttp.removeMsg(sessionList[index].talkerId);
|
||||||
|
if (res['status']) {
|
||||||
|
sessionList.removeAt(index);
|
||||||
|
SmartDialog.showToast('删除成功');
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(res['msg']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future onSetTop(int index) async {
|
||||||
|
bool isTop = sessionList[index].topTs != 0;
|
||||||
|
var res = await MsgHttp.setTop(
|
||||||
|
sessionList[index].talkerId,
|
||||||
|
isTop ? 1 : 0,
|
||||||
|
);
|
||||||
|
if (res['status']) {
|
||||||
|
List<SessionList> list = sessionList.map((item) {
|
||||||
|
if (item.talkerId == sessionList[index].talkerId) {
|
||||||
|
return item..topTs = isTop ? 0 : 1;
|
||||||
|
} else {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}).toList();
|
||||||
|
if (!isTop) {
|
||||||
|
SessionList item = list.removeAt(index);
|
||||||
|
list.insert(0, item);
|
||||||
|
}
|
||||||
|
sessionList.value = list;
|
||||||
|
SmartDialog.showToast('${isTop ? '移除' : ''}置顶成功');
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(res['msg']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future querySessionList(String? type) async {
|
Future querySessionList(String? type) async {
|
||||||
if (isLoading) return;
|
if (isLoading) return;
|
||||||
var res = await MsgHttp.sessionList(
|
var res = await MsgHttp.sessionList(
|
||||||
|
|||||||
@@ -172,6 +172,57 @@ class _WhisperPageState extends State<WhisperPage> {
|
|||||||
content.toString();
|
content.toString();
|
||||||
}
|
}
|
||||||
return ListTile(
|
return ListTile(
|
||||||
|
tileColor: sessionList[i].topTs == 0
|
||||||
|
? null
|
||||||
|
: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.primaryContainer,
|
||||||
|
onLongPress: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return AlertDialog(
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
|
contentPadding:
|
||||||
|
const EdgeInsets.symmetric(
|
||||||
|
vertical: 12),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
ListTile(
|
||||||
|
dense: true,
|
||||||
|
onTap: () {
|
||||||
|
Get.back();
|
||||||
|
_whisperController
|
||||||
|
.onSetTop(i);
|
||||||
|
},
|
||||||
|
title: Text(
|
||||||
|
sessionList[i].topTs == 0
|
||||||
|
? '置顶'
|
||||||
|
: '移除置顶',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
dense: true,
|
||||||
|
onTap: () {
|
||||||
|
Get.back();
|
||||||
|
_whisperController
|
||||||
|
.onRemove(i);
|
||||||
|
},
|
||||||
|
title: const Text(
|
||||||
|
'删除',
|
||||||
|
style:
|
||||||
|
TextStyle(fontSize: 14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
sessionList[i].unreadCount = 0;
|
sessionList[i].unreadCount = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user