Music_Player3/MusicPlayer/MP/MPPositive/Models/ViewModels/LoadViewModels/MPPositive_BrowseLoadViewModel.swift
2024-05-11 09:48:37 +08:00

52 lines
1.9 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// MPPositive_LoadMusicModel.swift
// MusicPlayer
//
// Created by Mr.Zhou on 2024/4/25.
//
import UIKit
///bload
class MPPositive_BrowseLoadViewModel: NSObject {
///()
var browseModuleLists:[MPPositive_BrowseModuleListViewModel] = []
///
var listAlbumList:MPPositive_ListAlbumListViewModel!
override init() {
super.init()
//browse
MP_NetWorkManager.shared.browseRequestStateBlock = {
[weak self] (lists,isCompleted) in
guard let self = self else {return}
//
browseModuleLists.append(contentsOf: lists)
//
browseModuleLists = browseModuleLists.filter{($0.items.count != 0)}
//UI
NotificationCenter.notificationKey.post(notificationName: .positive_browses_reload)
}
//
MP_NetWorkManager.shared.listRequestResultBlock = {
[weak self] (list) in
guard let self = self else {return}
listAlbumList = list
//UI
NotificationCenter.notificationKey.post(notificationName: .positive_list_reload)
}
}
///
func reloadBrowseLists() {
//
browseModuleLists.removeAll()
//
MP_NetWorkManager.shared.requestBrowseDatas()
}
///
func requestListOrAlbum(_ item:MPPositive_BrowseItemViewModel) {
//
listAlbumList = nil
//
MP_NetWorkManager.shared.requestAlbumOrListDatas(item)
}
}