From: liangzhenying <867174124@qq.com> Date: Thu, 20 Nov 2025 10:31:40 +0000 (+0800) Subject: 增加断开重连 X-Git-Tag: 1.0.2~58 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=0813eb69969a5a546892fc80e8df72967d241419;p=mirrors%2FShenYin.git 增加断开重连 --- diff --git a/ShenYin/ShenYin/Launch/BleManager.swift b/ShenYin/ShenYin/Launch/BleManager.swift index aec7794..681961d 100644 --- a/ShenYin/ShenYin/Launch/BleManager.swift +++ b/ShenYin/ShenYin/Launch/BleManager.swift @@ -60,7 +60,7 @@ extension BleManager:CBCentralManagerDelegate{ break case.poweredOn: // startScanDevice() - checkConnect() + checkConectState() break @unknown default: break @@ -109,6 +109,7 @@ extension BleManager:CBCentralManagerDelegate{ NotificationManager.post(type: .deviceValidChange, objtect: nil) disConnectDeviceCallback?(connectPeripheral!) OtaMananger.shared.otaManager.centralManager(central, didDisconnectPeripheral: peripheral, error: error) + checkConectState() } func getMac(_ dict:[String:Any])->String?{ if let advMsd = dict[CBAdvertisementDataManufacturerDataKey] as? Data { @@ -205,31 +206,10 @@ extension BleManager{ // devices.append(DCPeripheral(device: item,mac: mac)) // } // } - centralManager.scanForPeripherals(withServices: [CBUUID(string: kJoyGemAIServiceUUID)],options: [CBCentralManagerScanOptionAllowDuplicatesKey : false]) discoverDeviceCallback?(devices) } - - func checkConnect(){ -// let list = centralManager.retrieveConnectedPeripherals(withServices: [CBUUID(string: kJoyGemAIServiceUUID)]) -// for item in list { -// devices.append(item) -// break -// } -// -// for item in devices{ -// if let current = CacheManager.shared.currentDevice,current.uuid == item.identifier.uuidString { -// connectPeripheral(item) -// return -// } -// } -// -// if connectPeripheral == nil || connectPeripheral?.state == .disconnected { -// DispatchQueue.main.asyncAfter(deadline:.now() + 3) { -// self.checkConnect() -// } -// } - } + func stopScanDevice() { centralManager.stopScan() @@ -399,7 +379,18 @@ extension BleManager{ extension BleManager{ - func sendOtaData(_ data:Data){ - + func checkConectState(){ + guard let mac = connectPeripheral?.mac else { + return + } + if isConnetd { + return + } + connect(mac: mac) {result in + } + + DispatchQueue.main.asyncAfter(deadline:.now() + 30) { + self.checkConectState() + } } } diff --git "a/ShenYin/ShenYin/Resource/\345\244\247\347\272\246\345\234\250\345\206\254\345\255\243.mp3" "b/ShenYin/ShenYin/Resource/\345\244\247\347\272\246\345\234\250\345\206\254\345\255\243.mp3" deleted file mode 100644 index 4209e87..0000000 Binary files "a/ShenYin/ShenYin/Resource/\345\244\247\347\272\246\345\234\250\345\206\254\345\255\243.mp3" and /dev/null differ diff --git a/ShenYin/ShenYin/UI/Home/Chat/ChatVC.swift b/ShenYin/ShenYin/UI/Home/Chat/ChatVC.swift index 57577cc..6a95210 100644 --- a/ShenYin/ShenYin/UI/Home/Chat/ChatVC.swift +++ b/ShenYin/ShenYin/UI/Home/Chat/ChatVC.swift @@ -180,7 +180,7 @@ class ChatVC:BaseVC{ extension ChatVC:ChatRecordBarDelegate{ func recordBarCancel(_ toolBar: ChatRecordBar) { - JoyGemChatManager.shared().stopChat() +// JoyGemChatManager.shared().stopChat() JoyGemChatManager.shared().stopSingleChat() if let item = JoySdkManager.shared.dataList.last,item.content.isEmpty{ JoySdkManager.shared.dataList.removeLast() @@ -196,7 +196,7 @@ extension ChatVC:ChatRecordBarDelegate{ JoySdkManager.shared.dataList.append(model) refreshData() - JoyGemChatManager.shared().stopChat() +// JoyGemChatManager.shared().stopChat() JoyGemChatManager.shared().startSingleChat() } diff --git a/ShenYin/ShenYin/UI/Home/Chat/RecordButton.swift b/ShenYin/ShenYin/UI/Home/Chat/RecordButton.swift index bb9eb9d..9137ca0 100644 --- a/ShenYin/ShenYin/UI/Home/Chat/RecordButton.swift +++ b/ShenYin/ShenYin/UI/Home/Chat/RecordButton.swift @@ -35,11 +35,13 @@ class RecordButton: UIView { private var isRecording = false private var isCanceling = false + // 取消阈值(可根据需求调整) private let cancelThreshold: CGFloat = 30 var state:RecordStatus = .start{ didSet{ + Logger.debug("当前状态",state) if state == .start { animationBg.backgroundColor = .hexString("#0092E1") animationView.isHidden = false @@ -67,12 +69,7 @@ class RecordButton: UIView { } private func setupUI() { - // 基本样式 -// backgroundColor = normalColor -// layer.cornerRadius = 0 // 圆角在 layoutSubviews 中设置(保证正方形) -// clipsToBounds = true - titleLabel.do { v in v.textColor = .hexString("#121212") v.font = .bold(16) @@ -160,7 +157,7 @@ class RecordButton: UIView { if isRecording { animationView.isHidden = false if isCanceling { - animationBg.backgroundColor = .red + animationBg.backgroundColor = .hexString("#FF4E4E") cancelLabel.isHidden = false titleLabel.isHidden = true }