Skip to content

Commit

Permalink
feat: 消息添加未阅读数量
Browse files Browse the repository at this point in the history
  • Loading branch information
orz12 committed Jan 24, 2024
1 parent 772a6a9 commit 65e4d6f
Show file tree
Hide file tree
Showing 5 changed files with 272 additions and 181 deletions.
2 changes: 2 additions & 0 deletions lib/http/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ class Api {
// 获取指定分组下的up
static const String followUpGroup = '/x/relation/tag';

static const String msgFeedUnread = '/x/msgfeed/unread';

/// 私聊
/// 'https://api.vc.bilibili.com/session_svr/v1/session_svr/get_sessions?
/// session_type=1&
Expand Down
16 changes: 16 additions & 0 deletions lib/http/msg.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ import 'api.dart';
import 'init.dart';

class MsgHttp {

static Future msgFeedUnread() async {
var res = await Request().get(Api.msgFeedUnread);
if (res.data['code'] == 0) {
return {
'status': true,
'data': res.data['data'],
};
} else {
return {
'status': false,
'date': [],
'msg': res.data['message'],
};
}
}
// 会话列表
static Future sessionList({int? endTs}) async {
Map<String, dynamic> params = {
Expand Down
26 changes: 26 additions & 0 deletions lib/models/msg/msgfeed_unread.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class MsgFeedUnread {
MsgFeedUnread({
this.at = 0,
this.chat = 0,
this.like = 0,
this.reply = 0,
this.sys_msg = 0,
this.up = 0,
});

int at = 0;
int chat = 0;
int like = 0;
int reply = 0;
int sys_msg = 0;
int up = 0;

MsgFeedUnread.fromJson(Map<String, dynamic> json) {
at = json['at'] ?? 0;
chat = json['chat'] ?? 0;
like = json['like'] ?? 0;
reply = json['reply'] ?? 0;
sys_msg = json['sys_msg'] ?? 0;
up = json['up'] ?? 0;
}
}
46 changes: 46 additions & 0 deletions lib/pages/whisper/controller.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,58 @@
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:pilipala/http/msg.dart';
import 'package:pilipala/models/msg/account.dart';
import 'package:pilipala/models/msg/session.dart';

import '../../models/msg/msgfeed_unread.dart';

class WhisperController extends GetxController {
RxList<SessionList> sessionList = <SessionList>[].obs;
RxList<AccountListModel> accountList = <AccountListModel>[].obs;
bool isLoading = false;
Rx<MsgFeedUnread> msgFeedUnread = MsgFeedUnread().obs;
RxList msgFeedTop = [
{
"name":"回复我的",
"icon":Icons.message_outlined,
"route": "/",
"value": 0
},
{
"name":"@我",
"icon":Icons.alternate_email_outlined,
"route": "/",
"value": 0
},
{
"name":"收到的赞",
"icon":Icons.favorite_border_outlined,
"route": "/",
"value": 0
},
{
"name":"系统通知",
"icon":Icons.notifications_none_outlined,
"route": "/",
"value": 0
},
].obs;

Future queryMsgFeedUnread() async {
var res = await MsgHttp.msgFeedUnread();
if (res['status']) {
msgFeedUnread.value = MsgFeedUnread.fromJson(res['data']);
msgFeedTop.value[0]["value"] = msgFeedUnread.value.reply;
msgFeedTop.value[1]["value"] = msgFeedUnread.value.at;
msgFeedTop.value[2]["value"] = msgFeedUnread.value.like;
msgFeedTop.value[3]["value"] = msgFeedUnread.value.sys_msg;
// 触发更新
msgFeedTop.refresh();
} else {
SmartDialog.showToast(res['msg']);
}
}

Future querySessionList(String? type) async {
if (isLoading) return;
Expand Down
Loading

0 comments on commit 65e4d6f

Please sign in to comment.