网路监控,空白页面

This commit is contained in:
zjx 2025-07-23 18:03:18 +08:00
parent d3cd10c3d7
commit a805885950
17 changed files with 245 additions and 11 deletions

View File

@ -59,6 +59,8 @@
BF3A56812E30C08F009E5CF9 /* BRHotSearchTagCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3A56802E30C08F009E5CF9 /* BRHotSearchTagCell.swift */; };
BF3A56832E30C561009E5CF9 /* BRSearchResultView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3A56822E30C561009E5CF9 /* BRSearchResultView.swift */; };
BF3A56852E30CA78009E5CF9 /* BRSearchResultCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3A56842E30CA78009E5CF9 /* BRSearchResultCell.swift */; };
BF3A56882E30E0DD009E5CF9 /* BREmpty.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3A56872E30E0DD009E5CF9 /* BREmpty.swift */; };
BF3A568A2E30E7EF009E5CF9 /* BRNetworkStatusManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3A56892E30E7EF009E5CF9 /* BRNetworkStatusManager.swift */; };
BF692AEB2E0A475D00A5C2DA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF692AE12E0A475D00A5C2DA /* AppDelegate.swift */; };
BF692AEC2E0A475D00A5C2DA /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF692AE82E0A475D00A5C2DA /* SceneDelegate.swift */; };
BF692AEE2E0A475D00A5C2DA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BF692AE22E0A475D00A5C2DA /* Assets.xcassets */; };
@ -204,6 +206,8 @@
BF3A56802E30C08F009E5CF9 /* BRHotSearchTagCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BRHotSearchTagCell.swift; sourceTree = "<group>"; };
BF3A56822E30C561009E5CF9 /* BRSearchResultView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BRSearchResultView.swift; sourceTree = "<group>"; };
BF3A56842E30CA78009E5CF9 /* BRSearchResultCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BRSearchResultCell.swift; sourceTree = "<group>"; };
BF3A56872E30E0DD009E5CF9 /* BREmpty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BREmpty.swift; sourceTree = "<group>"; };
BF3A56892E30E7EF009E5CF9 /* BRNetworkStatusManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BRNetworkStatusManager.swift; sourceTree = "<group>"; };
BF692AC92E0A475500A5C2DA /* BeeReel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BeeReel.app; sourceTree = BUILT_PRODUCTS_DIR; };
BF692AE12E0A475D00A5C2DA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
BF692AE22E0A475D00A5C2DA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@ -491,6 +495,14 @@
path = View;
sourceTree = "<group>";
};
BF3A56862E30E0C2009E5CF9 /* Empty */ = {
isa = PBXGroup;
children = (
BF3A56872E30E0DD009E5CF9 /* BREmpty.swift */,
);
path = Empty;
sourceTree = "<group>";
};
BF692AC02E0A475500A5C2DA = {
isa = PBXGroup;
children = (
@ -574,6 +586,7 @@
BF692AF62E0A480000A5C2DA /* Lib */ = {
isa = PBXGroup;
children = (
BF3A56862E30E0C2009E5CF9 /* Empty */,
BF692B452E0A9B5800A5C2DA /* Player */,
BF692B1D2E0A803000A5C2DA /* LocalizedManager */,
BF692B142E0A7CB500A5C2DA /* HUD */,
@ -846,6 +859,7 @@
BF692AFB2E0A6F1B00A5C2DA /* BRNetworkTarget.swift */,
BF692AF92E0A6EFD00A5C2DA /* BRNetwork.swift */,
BF78108A2E0D4EB3007DEEBC /* BRURLPath.swift */,
BF3A56892E30E7EF009E5CF9 /* BRNetworkStatusManager.swift */,
);
path = Base;
sourceTree = "<group>";
@ -1090,6 +1104,7 @@
BFC676932E126A62006659E5 /* BRSpotlightNewMainCell.swift in Sources */,
BFC6768D2E123D6E006659E5 /* AttributedString+BRAdd.swift in Sources */,
BF02B8392E30B30400172177 /* AlignedCollectionViewFlowLayout.swift in Sources */,
BF3A56882E30E0DD009E5CF9 /* BREmpty.swift in Sources */,
BF3338F52E1616B200B10F76 /* BRExploreControlView.swift in Sources */,
BF692B132E0A7B9000A5C2DA /* BRUserInfo.swift in Sources */,
BF692B042E0A76D200A5C2DA /* BRLoginManager.swift in Sources */,
@ -1145,6 +1160,7 @@
BF02B7F52E2F203D00172177 /* BRHomeCategoriesViewController.swift in Sources */,
BFC676752E0E93B3006659E5 /* BRTableViewCell.swift in Sources */,
BF78108B2E0D4EB3007DEEBC /* BRURLPath.swift in Sources */,
BF3A568A2E30E7EF009E5CF9 /* BRNetworkStatusManager.swift in Sources */,
BF692B092E0A775500A5C2DA /* BRLoginToken.swift in Sources */,
BF692AFC2E0A6F8000A5C2DA /* BRNetworkTarget.swift in Sources */,
BF02B7FF2E2F2F2900172177 /* BRHomeCategoriesCell.swift in Sources */,

View File

@ -0,0 +1,73 @@
//
// BRNetworkStatusManager.swift
// BeeReel
//
// Created by on 2025/7/23.
//
import UIKit
import Network
class BRNetworkStatusManager: NSObject {
static let manager = BRNetworkStatusManager()
///
var isReachable: Bool?
private var connectionType: NWInterface.InterfaceType?
private var status: NWPath.Status?
private let monitor = NWPathMonitor()
private let queue = DispatchQueue(label: "NetworkMonitorQueue")
func startMonitoring() {
monitor.pathUpdateHandler = { [weak self] path in
guard let self = self else { return }
self.status = path.status
if path.usesInterfaceType(.wifi) {
self.connectionType = .wifi
} else if path.usesInterfaceType(.cellular) {
self.connectionType = .cellular
} else if path.usesInterfaceType(.wiredEthernet) {
self.connectionType = .wiredEthernet
} else {
self.connectionType = nil
}
if path.status == .satisfied, self.connectionType != nil {
if self.isReachable == false {
self.isReachable = true
DispatchQueue.main.async {
NotificationCenter.default.post(name: BRNetworkStatusManager.networkStatusDidChangeNotification, object: nil)
}
} else {
self.isReachable = true
}
} else {
if self.isReachable == true {
self.isReachable = false
DispatchQueue.main.async {
NotificationCenter.default.post(name: BRNetworkStatusManager.networkStatusDidChangeNotification, object: nil)
}
} else {
self.isReachable = false
}
}
}
monitor.start(queue: queue)
}
func stopMonitoring() {
monitor.cancel()
}
}
extension BRNetworkStatusManager {
///
@objc static let networkStatusDidChangeNotification = NSNotification.Name(rawValue: "BRNetworkStatusManager.networkStatusDidChangeNotification")
}

View File

@ -198,6 +198,10 @@ extension BRExploreViewController: BRPlayerListViewControllerDelegate, BRPlayerL
videoNameLabel.text = self.viewModel.currentPlayer?.shortModel?.name
favoriteButton.isSelected = self.viewModel.currentPlayer?.shortModel?.is_collect ?? true
}
func br_playerViewControllerLoadMoreData(playerViewController: BRPlayerListViewController) {
self.requestDataArr(page: self.page + 1)
}
}

View File

@ -47,6 +47,8 @@ class BRFavoritesViewController: BRViewController {
let collectionView = BRCollectionView(frame: .zero, collectionViewLayout: collectionViewLayout)
collectionView.delegate = self
collectionView.dataSource = self
collectionView.ly_emptyView = BREmpty.br_normalEmptyView()
collectionView.ly_emptyView.autoShowEmptyView = false
collectionView.br_addRefreshHeader { [weak self] in
self?.handleHeaderRefresh(nil)
}
@ -105,6 +107,13 @@ class BRFavoritesViewController: BRViewController {
}
}
private func updateEmptyStatus() {
if listArr.isEmpty, self.playHistoryModel == nil {
self.collectionView.ly_showEmpty()
} else {
self.collectionView.ly_hideEmpty()
}
}
}
@ -192,6 +201,7 @@ extension BRFavoritesViewController {
self.page = page
self.collectionView.reloadData()
}
self.updateEmptyStatus()
completer?()
}
@ -202,6 +212,7 @@ extension BRFavoritesViewController {
guard let self = self else { return }
guard let list = listModel?.list else { return }
self.playHistoryModel = list.first
self.updateEmptyStatus()
}
}

View File

@ -142,6 +142,7 @@ class BRHomeViewController: BRViewController {
self.edgesForExtendedLayout = [.top, .bottom]
self.statusBarStyle = .lightContent
self.navigationController?.isNavigationBarHidden = true
NotificationCenter.default.addObserver(self, selector: #selector(networkStatusDidChangeNotification), name: BRNetworkStatusManager.networkStatusDidChangeNotification, object: nil)
br_setupUI()
@ -239,6 +240,18 @@ extension BRHomeViewController {
}
extension BRHomeViewController {
///
@objc private func networkStatusDidChangeNotification() {
guard BRNetworkStatusManager.manager.isReachable == true else {
return
}
if self.viewModel.homeOldDataArr.isEmpty {
self.handleHeaderRefresh(nil)
}
}
@objc private func handleSearchButton() {
let vc = BRSearchViewController()

View File

@ -11,15 +11,11 @@ import SJMediaCacheServer
@objc protocol BRPlayerListViewControllerDelegate {
///
@objc optional func br_playerViewControllerLoadNewDataV2(playerViewController: BRPlayerListViewController)
///
@objc optional func br_playerViewControllerShouldLoadMoreData(playerViewController: BRPlayerListViewController) -> Bool
///
@objc optional func br_playerViewControllerLoadMoreData(playerViewController: BRPlayerListViewController)
///
@objc optional func br_playerViewControllerLoadUpMoreData(playerViewController: BRPlayerListViewController)
///
@objc optional func br_playerListViewController(_ viewController: BRPlayerListViewController, didChangeIndexPathForVisible indexPath: IndexPath)
@ -136,9 +132,9 @@ class BRPlayerListViewController: BRViewController {
self.viewModel.isPlaying = true
// if getDataCount() - viewModel.currentIndexPath.row <= 2 {
// self.loadMoreData()
// }
if (self.collectionView.contentSize.height - self.collectionView.contentOffset.y) / self.contentSize.height <= 3 {
self.loadMoreData()
}
}
func pause() {
@ -364,10 +360,6 @@ extension BRPlayerListViewController {
}
}
private func loadUpMoreData() {
self.delegate?.br_playerViewControllerLoadUpMoreData?(playerViewController: self)
}
private func didChangeIndexPathForVisible() {
self.delegate?.br_playerListViewController?(self, didChangeIndexPathForVisible: viewModel.currentIndexPath)
}

View File

@ -6,6 +6,7 @@
//
import UIKit
import LYEmptyView
class BRSearchResultView: UIView {
@ -35,6 +36,7 @@ class BRSearchResultView: UIView {
collectionView.dataSource = self
collectionView.contentInset = .init(top: 0, left: 0, bottom: UIScreen.tabbarSafeBottomMargin + 10, right: 0)
collectionView.register(BRSearchResultCell.self, forCellWithReuseIdentifier: "cell")
collectionView.ly_emptyView = BREmpty.br_normalEmptyView(image: UIImage(named: "empty_search_image"), title: "kSearchEmptyTitle".localized, detailStr: "kSearchEmptyDetail".localized)
return collectionView
}()

View File

@ -14,6 +14,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
BRAppTool.appDelegate = self
BRNetworkStatusManager.manager.startMonitoring()
NotificationCenter.default.addObserver(self, selector: #selector(networkStatusDidChangeNotification), name: BRNetworkStatusManager.networkStatusDidChangeNotification, object: nil)
BRLoginManager.manager.updateUserInfo(completer: nil)
@ -39,3 +41,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
extension AppDelegate {
@objc private func networkStatusDidChangeNotification() {
if BRNetworkStatusManager.manager.isReachable == true {
BRLoginManager.manager.updateUserInfo(completer: nil)
}
}
}

View File

@ -0,0 +1,24 @@
//
// BREmpty.swift
// BeeReel
//
// Created by on 2025/7/23.
//
import UIKit
import LYEmptyView
class BREmpty: NSObject {
static func br_normalEmptyView(image: UIImage? = UIImage(named: "empty_normal_image"), title: String? = "kNormalRmptyTitle".localized, detailStr: String? = "kNormalRmptyDetail".localized) -> LYEmptyView {
let view = LYEmptyView.empty(with: image, titleStr: title, detailStr: detailStr)
view?.titleLabFont = .fontMedium(ofSize: 15)
view?.titleLabTextColor = .color1C1C1C()
view?.detailLabFont = .fontRegular(ofSize: 12)
view?.detailLabTextColor = .color777777()
view?.contentViewOffset = -100
view?.subViewMargin = 10
return view!
}
}

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "内容为空@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "内容为空@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "搜索无结果@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "搜索无结果@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

View File

@ -122,6 +122,50 @@
}
}
},
"kNormalRmptyDetail" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Start exploring and add something"
}
}
}
},
"kNormalRmptyTitle" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Nothing Here Yet"
}
}
}
},
"kSearchEmptyDetail" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Check spelling or use simpler keywords"
}
}
}
},
"kSearchEmptyTitle" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "No Results Found"
}
}
}
},
"Last Searched" : {
"extractionState" : "manual",
"localizations" : {

View File

@ -30,5 +30,6 @@ target 'BeeReel' do
pod 'MJRefresh' #刷新控件
pod 'HWPanModal' #底部弹出控制器
pod 'FDFullscreenPopGesture' #全屏手势返回
pod 'LYEmptyView'
end