Files
e-party-iOS/yana/Utils/Network/NetworkMonitor.swift
edwinQQQ 8b4eb9cb7e feat: 更新API相关逻辑及视图结构
- 在Info.plist中新增API签名密钥配置。
- 将Splash视图替换为SplashV2,优化启动逻辑和用户体验。
- 更新API请求中的User-Agent逻辑,使用UserAgentProvider提供的动态值。
- 在APILogger中添加敏感信息脱敏处理,增强安全性。
- 新增CreateFeedPage视图,支持用户发布动态功能。
- 更新MainPage和Splash视图的导航逻辑,整合统一的AppRoute管理。
- 移除冗余的SplashFeature视图,提升代码整洁性和可维护性。
2025-09-17 16:37:21 +08:00

34 lines
1.1 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.

import Foundation
import Network
///
/// WiFi=2, =1, /=0
final class NetworkMonitor: @unchecked Sendable {
static let shared = NetworkMonitor()
private let monitor = NWPathMonitor()
private let queue = DispatchQueue(label: "com.yana.network.monitor")
private var _currentType: Int = 2 //
var currentType: Int { _currentType }
private init() {
monitor.pathUpdateHandler = { [weak self] path in
guard let self = self else { return }
let type: Int
if path.status == .satisfied {
if path.usesInterfaceType(.wifi) { type = 2 }
else if path.usesInterfaceType(.cellular) { type = 1 }
else { type = 0 }
} else {
type = 0
}
// 线线 UI
DispatchQueue.main.async { [weak self] in
self?._currentType = type
}
}
monitor.start(queue: queue)
}
}