|
@@ -542,19 +542,29 @@ extension PQStuckPointMusicController: UITextFieldDelegate {
|
|
}
|
|
}
|
|
|
|
|
|
// MARK: - 缓存相关
|
|
// MARK: - 缓存相关
|
|
-
|
|
|
|
|
|
+//缓存歌曲列表 KEY
|
|
|
|
+let kSaveMusicListDatas = "kSaveMusicListDatas"
|
|
/// 缓存相关
|
|
/// 缓存相关
|
|
extension PQStuckPointMusicController {
|
|
extension PQStuckPointMusicController {
|
|
/// 获取缓存数据
|
|
/// 获取缓存数据
|
|
/// - Parameter itemData: <#itemData description#>
|
|
/// - Parameter itemData: <#itemData description#>
|
|
/// - Returns: <#description#>
|
|
/// - Returns: <#description#>
|
|
func getMusicCacheData(itemData: PQStuckPointMusicTagsModel?) -> (([PQStuckPointMusicTagsModel], ([UICollectionViewLayoutAttributes], CGFloat))?, [PQVoiceModel]?, PQStuckPointMusicTagsModel?)? {
|
|
func getMusicCacheData(itemData: PQStuckPointMusicTagsModel?) -> (([PQStuckPointMusicTagsModel], ([UICollectionViewLayoutAttributes], CGFloat))?, [PQVoiceModel]?, PQStuckPointMusicTagsModel?)? {
|
|
- if itemData != nil, cacheMusicData.keys.contains("\(itemData?.tagId ?? 0)") {
|
|
|
|
- let tempData = cacheMusicData["\(itemData?.tagId ?? 0)"]
|
|
|
|
- return (tempData?["tagInfo"] as? ([PQStuckPointMusicTagsModel], ([UICollectionViewLayoutAttributes], CGFloat)), tempData?["pageList"] as? [PQVoiceModel], tempData?["currentTag"] as? PQStuckPointMusicTagsModel)
|
|
|
|
- } else {
|
|
|
|
- return nil
|
|
|
|
- }
|
|
|
|
|
|
+ let saveMusicListStr = getUserDefaults(key: kSaveMusicListDatas)
|
|
|
|
+
|
|
|
|
+ if(((saveMusicListStr as? String)?.count ?? 0 ) > 0){
|
|
|
|
+ let cacheMusicDataTemp = jsonStringToDictionary(saveMusicListStr as! String)
|
|
|
|
+
|
|
|
|
+ if itemData != nil, cacheMusicData.keys.contains("\(itemData?.tagId ?? 0)") {
|
|
|
|
+ let tempData = cacheMusicDataTemp?["\(itemData?.tagId ?? 0)"] as? Dictionary<String, Any>
|
|
|
|
+
|
|
|
|
+ return (tempData?["tagInfo"] as? ([PQStuckPointMusicTagsModel],([UICollectionViewLayoutAttributes], CGFloat)),tempData?["pageList"] as? [PQVoiceModel],tempData?["currentTag"] as? PQStuckPointMusicTagsModel)
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+ }else{ return nil}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/// 更新缓存
|
|
/// 更新缓存
|
|
@@ -600,6 +610,9 @@ extension PQStuckPointMusicController {
|
|
}
|
|
}
|
|
cacheMusicData["\(tagId)"] = tempDic
|
|
cacheMusicData["\(tagId)"] = tempDic
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ saveUserDefaults(key: kSaveMusicListDatas, value: dictionaryToJsonString(cacheMusicData) as Any)
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|