From 0803444d74d4a22ff9691398832433c35ec2712d Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 25 Aug 2024 22:07:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=A0=87=E8=AE=B0=E5=B7=B2=E8=AF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/http/api.dart | 4 ++++ lib/http/msg.dart | 20 +++++++++++++++++++- lib/pages/message/system/controller.dart | 14 +++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/http/api.dart b/lib/http/api.dart index 31e5a38b..d9286e47 100644 --- a/lib/http/api.dart +++ b/lib/http/api.dart @@ -554,4 +554,8 @@ class Api { /// 系统通知 static const String messageSystemAPi = '${HttpString.messageBaseUrl}/x/sys-msg/query_unified_notify'; + + /// 系统通知标记已读 + static const String systemMarkRead = + '${HttpString.messageBaseUrl}/x/sys-msg/update_cursor'; } diff --git a/lib/http/msg.dart b/lib/http/msg.dart index 86789fd1..2de9cd49 100644 --- a/lib/http/msg.dart +++ b/lib/http/msg.dart @@ -298,7 +298,6 @@ class MsgHttp { }); if (res.data['code'] == 0) { try { - print(res.data['data']['system_notify_list']); return { 'status': true, 'data': res.data['data']['system_notify_list'] @@ -312,4 +311,23 @@ class MsgHttp { return {'status': false, 'date': [], 'msg': res.data['message']}; } } + + // 系统消息标记已读 + static Future systemMarkRead(int cursor) async { + String csrf = await Request.getCsrf(); + var res = await Request().get(Api.systemMarkRead, data: { + 'csrf': csrf, + 'cursor': cursor, + }); + if (res.data['code'] == 0) { + return { + 'status': true, + }; + } else { + return { + 'status': false, + 'msg': res.data['message'], + }; + } + } } diff --git a/lib/pages/message/system/controller.dart b/lib/pages/message/system/controller.dart index bf31f6bc..f63a659a 100644 --- a/lib/pages/message/system/controller.dart +++ b/lib/pages/message/system/controller.dart @@ -8,8 +8,20 @@ class MessageSystemController extends GetxController { Future queryMessageSystem({String type = 'init'}) async { var res = await MsgHttp.messageSystem(); if (res['status']) { - systemItems.addAll(res['data']); + if (type == 'init') { + systemItems.value = res['data']; + } else { + systemItems.addAll(res['data']); + } + if (systemItems.isNotEmpty) { + systemMarkRead(systemItems.first.cursor!); + } } return res; } + + // 标记已读 + void systemMarkRead(int cursor) async { + await MsgHttp.systemMarkRead(cursor); + } }