新版UI-登录页面-我的页面(简单适配)-设备的部分(无设备的+有设备)
This commit is contained in:
@@ -145,7 +145,10 @@ class LocalCameraCubit extends Cubit<LocalCameraState>
|
||||
if (!ok) {
|
||||
final detail = await _describeNetworks();
|
||||
final header = Platform.isIOS
|
||||
? '未检测到局域网连接。请让 iPhone/iPad 与摄像头连入同一 WiFi 后重试'
|
||||
? '未检测到局域网网卡。\n'
|
||||
'• iPad 纯网线:插上 USB‑C 转以太网适配器并接好摄像头网线,'
|
||||
'到「设置 → 以太网」把 IP 配成与摄像头同网段\n'
|
||||
'• iPhone 不支持网线直连,请改用摄像头自带 WiFi 或便携路由'
|
||||
: msgNoNetworkEntry;
|
||||
emit(
|
||||
state.copyWith(
|
||||
@@ -549,18 +552,47 @@ class LocalCameraCubit extends Cubit<LocalCameraState>
|
||||
}
|
||||
}
|
||||
|
||||
/// iOS:局域网连通判据——走同一 WiFi(或以太网),不要求 USB 以太网卡存在。
|
||||
/// iOS:局域网连通判据。
|
||||
/// iPhone/iPad 没有安卓那种「USB-C 转以太网 + 以太网共享」,组网方式不同:
|
||||
/// • 走同一 WiFi(en0);或
|
||||
/// • iPad 插 USB‑C 转以太网适配器「纯网线」直连摄像头(connectivity_plus 常把它
|
||||
/// 报成 other/none,所以必须再用网卡枚举复核)。
|
||||
/// 判据:connectivity 报 WiFi/以太网,或存在任一「非蜂窝、非环回」的 IPv4 网卡。
|
||||
Future<bool> _isLanConnectedForIOS() async {
|
||||
// ① connectivity 快判
|
||||
try {
|
||||
final results = await Connectivity().checkConnectivity();
|
||||
final bool lan = results.contains(ConnectivityResult.wifi) ||
|
||||
results.contains(ConnectivityResult.ethernet);
|
||||
debugPrint(
|
||||
'🌐 [网络检查-iOS] ${lan ? "已连接 WiFi/以太网 LAN ✔" : "未见 LAN"}:$results',
|
||||
);
|
||||
return lan;
|
||||
if (results.contains(ConnectivityResult.wifi) ||
|
||||
results.contains(ConnectivityResult.ethernet)) {
|
||||
debugPrint('🌐 [网络检查-iOS] connectivity 报 WiFi/以太网 LAN ✔ $results');
|
||||
return true;
|
||||
}
|
||||
debugPrint('🌐 [网络检查-iOS] connectivity:$results(转网卡枚举复核)');
|
||||
} catch (e) {
|
||||
debugPrint('🌐 [网络检查-iOS] connectivity 失败:$e(保守放行,交给后续探测)');
|
||||
debugPrint('🌐 [网络检查-iOS] connectivity 失败:$e(转网卡枚举复核)');
|
||||
}
|
||||
// ② 网卡枚举复核:兼容 iPad USB 以太网直连(纯网线、无 WiFi)
|
||||
try {
|
||||
final ifs = await NetworkInterface.list(
|
||||
type: InternetAddressType.IPv4,
|
||||
includeLoopback: false,
|
||||
);
|
||||
for (final i in ifs) {
|
||||
final n = i.name.toLowerCase();
|
||||
// 排除蜂窝(iPhone 数据网络),其余有 IPv4 的接口都算局域网就绪
|
||||
final cellular = n.startsWith('pdp') ||
|
||||
n.startsWith('wwan') ||
|
||||
n.contains('cellular');
|
||||
if (!cellular && i.addresses.isNotEmpty) {
|
||||
final ips = i.addresses.map((a) => a.address.toString()).join(',');
|
||||
debugPrint('🌐 [网络检查-iOS] 采用网卡 ${i.name}($ips) 视为局域网 ✔');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
debugPrint('🌐 [网络检查-iOS] 未发现可用局域网网卡(仅蜂窝/无 IP)');
|
||||
return false;
|
||||
} catch (e) {
|
||||
debugPrint('🌐 [网络检查-iOS] 枚举网卡失败:$e(保守放行,交给后续探测)');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -738,7 +770,7 @@ class LocalCameraCubit extends Cubit<LocalCameraState>
|
||||
phase: LocalCameraPhase.disconnected,
|
||||
playStep: ChainStatus.failed,
|
||||
message: _usesMediaKit
|
||||
? '局域网连接已断开,请检查 WiFi 与摄像头是否在线'
|
||||
? '局域网连接已断开,请检查网线/适配器与摄像头是否在线'
|
||||
: msgDisconnected,
|
||||
showReconnect: true,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user