opt member tab

try-catch handle live dm

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-07-14 16:18:37 +08:00
parent e280f6ee4a
commit d6c12195f8
4 changed files with 140 additions and 130 deletions

View File

@@ -58,6 +58,7 @@ class SpaceData {
List<Entry>? entry; List<Entry>? entry;
List<SpaceButtonList>? spaceButtonList; List<SpaceButtonList>? spaceButtonList;
int? relSpecial; int? relSpecial;
bool? hasItem;
SpaceData({ SpaceData({
this.relation, this.relation,
@@ -94,90 +95,95 @@ class SpaceData {
this.relSpecial, this.relSpecial,
}); });
factory SpaceData.fromJson(Map<String, dynamic> json) => SpaceData( SpaceData.fromJson(Map<String, dynamic> json) {
relation: json['relation'] as int?, relation = json['relation'] as int?;
guestRelation: json['guest_relation'] as int?, guestRelation = json['guest_relation'] as int?;
medal: json['medal'] as int?, medal = json['medal'] as int?;
defaultTab: json['default_tab'] as String?, defaultTab = json['default_tab'] as String?;
isParams: json['is_params'] as bool?, isParams = json['is_params'] as bool?;
setting: json['setting'] == null setting = json['setting'] == null
? null ? null
: SpaceSetting.fromJson(json['setting'] as Map<String, dynamic>), : SpaceSetting.fromJson(json['setting'] as Map<String, dynamic>);
tab: json['tab'] == null tab = json['tab'] == null
? null ? null
: SpaceTab.fromJson(json['tab'] as Map<String, dynamic>), : SpaceTab.fromJson(json['tab'] as Map<String, dynamic>);
card: json['card'] == null card = json['card'] == null
? null ? null
: SpaceCard.fromJson(json['card'] as Map<String, dynamic>), : SpaceCard.fromJson(json['card'] as Map<String, dynamic>);
images: json['images'] == null images = json['images'] == null
? null ? null
: SpaceImages.fromJson(json['images'] as Map<String, dynamic>), : SpaceImages.fromJson(json['images'] as Map<String, dynamic>);
live: json['live'] == null live = json['live'] == null
? null ? null
: Live.fromJson(json['live'] as Map<String, dynamic>), : Live.fromJson(json['live'] as Map<String, dynamic>);
elec: json['elec'] == null elec = json['elec'] == null
? null ? null
: Elec.fromJson(json['elec'] as Map<String, dynamic>), : Elec.fromJson(json['elec'] as Map<String, dynamic>);
archive: json['archive'] == null archive = json['archive'] == null
? null ? null
: Archive.fromJson(json['archive'] as Map<String, dynamic>), : Archive.fromJson(json['archive'] as Map<String, dynamic>);
series: json['series'] == null series = json['series'] == null
? null ? null
: SpaceSeries.fromJson(json['series'] as Map<String, dynamic>), : SpaceSeries.fromJson(json['series'] as Map<String, dynamic>);
playGame: json['play_game'] == null playGame = json['play_game'] == null
? null ? null
: PlayGame.fromJson(json['play_game'] as Map<String, dynamic>), : PlayGame.fromJson(json['play_game'] as Map<String, dynamic>);
article: json['article'] == null article = json['article'] == null
? null ? null
: Article.fromJson(json['article'] as Map<String, dynamic>), : Article.fromJson(json['article'] as Map<String, dynamic>);
season: json['season'] == null season = json['season'] == null
? null ? null
: SpaceSeason.fromJson(json['season'] as Map<String, dynamic>), : SpaceSeason.fromJson(json['season'] as Map<String, dynamic>);
coinArchive: json['coin_archive'] == null coinArchive = json['coin_archive'] == null
? null ? null
: CoinArchive.fromJson( : CoinArchive.fromJson(json['coin_archive'] as Map<String, dynamic>);
json['coin_archive'] as Map<String, dynamic>), likeArchive = json['like_archive'] == null
likeArchive: json['like_archive'] == null
? null ? null
: LikeArchive.fromJson( : LikeArchive.fromJson(json['like_archive'] as Map<String, dynamic>);
json['like_archive'] as Map<String, dynamic>), audios = json['audios'] == null
audios: json['audios'] == null
? null ? null
: Audios.fromJson(json['audios'] as Map<String, dynamic>), : Audios.fromJson(json['audios'] as Map<String, dynamic>);
favourite2: json['favourite2'] == null favourite2 = json['favourite2'] == null
? null ? null
: Favourite2.fromJson(json['favourite2'] as Map<String, dynamic>), : Favourite2.fromJson(json['favourite2'] as Map<String, dynamic>);
comic: json['comic'] == null comic = json['comic'] == null
? null ? null
: Comic.fromJson(json['comic'] as Map<String, dynamic>), : Comic.fromJson(json['comic'] as Map<String, dynamic>);
ugcSeason: json['ugc_season'] == null ugcSeason = json['ugc_season'] == null
? null ? null
: UgcSeason.fromJson(json['ugc_season'] as Map<String, dynamic>), : UgcSeason.fromJson(json['ugc_season'] as Map<String, dynamic>);
cheese: json['cheese'] == null cheese = json['cheese'] == null
? null ? null
: Cheese.fromJson(json['cheese'] as Map<String, dynamic>), : Cheese.fromJson(json['cheese'] as Map<String, dynamic>);
guard: json['guard'] == null guard = json['guard'] == null
? null ? null
: Guard.fromJson(json['guard'] as Map<String, dynamic>), : Guard.fromJson(json['guard'] as Map<String, dynamic>);
attentionTip: json['attention_tip'] == null attentionTip = json['attention_tip'] == null
? null ? null
: AttentionTip.fromJson( : AttentionTip.fromJson(json['attention_tip'] as Map<String, dynamic>);
json['attention_tip'] as Map<String, dynamic>), nftShowModule = json['nft_show_module'] == null
nftShowModule: json['nft_show_module'] == null
? null ? null
: NftShowModule.fromJson( : NftShowModule.fromJson(
json['nft_show_module'] as Map<String, dynamic>), json['nft_show_module'] as Map<String, dynamic>);
tab2: (json['tab2'] as List<dynamic>?) tab2 = (json['tab2'] as List<dynamic>?)
?.map((e) => SpaceTab2.fromJson(e as Map<String, dynamic>)) ?.map((e) => SpaceTab2.fromJson(e as Map<String, dynamic>))
.toList(), .toList();
nftFaceButton: json['nft_face_button'] as dynamic, nftFaceButton = json['nft_face_button'] as dynamic;
digitalButton: json['digital_button'] as dynamic, digitalButton = json['digital_button'] as dynamic;
entry: (json['entry'] as List<dynamic>?) entry = (json['entry'] as List<dynamic>?)
?.map((e) => Entry.fromJson(e as Map<String, dynamic>)) ?.map((e) => Entry.fromJson(e as Map<String, dynamic>))
.toList(), .toList();
spaceButtonList: (json['space_button_list'] as List<dynamic>?) spaceButtonList = (json['space_button_list'] as List<dynamic>?)
?.map((e) => SpaceButtonList.fromJson(e as Map<String, dynamic>)) ?.map((e) => SpaceButtonList.fromJson(e as Map<String, dynamic>))
.toList(), .toList();
relSpecial: (json['rel_special'] as num?)?.toInt(), relSpecial = (json['rel_special'] as num?)?.toInt();
); hasItem = archive?.item?.isNotEmpty == true ||
favourite2?.item?.isNotEmpty == true ||
coinArchive?.item?.isNotEmpty == true ||
likeArchive?.item?.isNotEmpty == true ||
article?.item?.isNotEmpty == true ||
audios?.item?.isNotEmpty == true ||
comic?.item?.isNotEmpty == true ||
season?.item?.isNotEmpty == true;
}
} }

View File

@@ -22,7 +22,7 @@ class SpaceTab {
bool? opus; bool? opus;
bool? cheeseVideo; bool? cheeseVideo;
bool? brand; bool? brand;
bool? hasItem; // bool? hasItem;
SpaceTab({ SpaceTab({
this.archive, this.archive,
@@ -74,6 +74,6 @@ class SpaceTab {
opus = json['opus'] as bool?; opus = json['opus'] as bool?;
cheeseVideo = json['cheese_video'] as bool?; cheeseVideo = json['cheese_video'] as bool?;
brand = json['brand'] as bool?; brand = json['brand'] as bool?;
hasItem = json.values.any((e) => e == true); // hasItem = json.values.any((e) => e == true);
} }
} }

View File

@@ -187,6 +187,7 @@ class LiveRoomController extends GetxController {
LiveHttp.liveRoomDanmaPrefetch(roomId: roomId).then((v) { LiveHttp.liveRoomDanmaPrefetch(roomId: roomId).then((v) {
if (v['status']) { if (v['status']) {
if ((v['data'] as List?)?.isNotEmpty == true) { if ((v['data'] as List?)?.isNotEmpty == true) {
try {
messages.addAll((v['data'] as List) messages.addAll((v['data'] as List)
.map((obj) => { .map((obj) => {
'name': obj['user']['base']['name'], 'name': obj['user']['base']['name'],
@@ -201,6 +202,7 @@ class LiveRoomController extends GetxController {
WidgetsBinding.instance.addPostFrameCallback( WidgetsBinding.instance.addPostFrameCallback(
(_) => scrollToBottom(), (_) => scrollToBottom(),
); );
} catch (_) {}
} }
} }
}); });
@@ -268,6 +270,7 @@ class LiveRoomController extends GetxController {
.toList(), .toList(),
) )
..addEventListener((obj) { ..addEventListener((obj) {
try {
if (obj['cmd'] == 'DANMU_MSG') { if (obj['cmd'] == 'DANMU_MSG') {
// logger.i(' 原始弹幕消息 ======> ${jsonEncode(obj)}'); // logger.i(' 原始弹幕消息 ======> ${jsonEncode(obj)}');
final info = obj['info']; final info = obj['info'];
@@ -296,6 +299,7 @@ class LiveRoomController extends GetxController {
.addPostFrameCallback((_) => scrollToBottom()); .addPostFrameCallback((_) => scrollToBottom());
} }
} }
} catch (_) {}
}) })
..init(); ..init();
} }

View File

@@ -85,7 +85,7 @@ class MemberController extends CommonDataController<SpaceData, SpaceData?>
} }
tab2?.retainWhere((item) => implTabs.contains(item.param)); tab2?.retainWhere((item) => implTabs.contains(item.param));
if (tab2?.isNotEmpty == true) { if (tab2?.isNotEmpty == true) {
if (data.tab!.hasItem != true && tab2!.first.param == 'home') { if (data.hasItem != true && tab2!.first.param == 'home') {
// remove empty home tab // remove empty home tab
tab2!.removeAt(0); tab2!.removeAt(0);
} }