fix: auto repair bugs #53
This commit is contained in:
parent
3f7b38a59b
commit
3a89ad4b55
@ -25,6 +25,7 @@ class DeviceController extends _$DeviceController {
|
||||
return result.fold(
|
||||
(failure) => false,
|
||||
(bindingId) {
|
||||
if (!ref.mounted) return false;
|
||||
ref.invalidateSelf();
|
||||
return true;
|
||||
},
|
||||
@ -38,6 +39,7 @@ class DeviceController extends _$DeviceController {
|
||||
return result.fold(
|
||||
(failure) => false,
|
||||
(_) {
|
||||
if (!ref.mounted) return false;
|
||||
final current = state.value ?? [];
|
||||
state = AsyncData(
|
||||
current.where((d) => d.id != userDeviceId).toList(),
|
||||
@ -54,6 +56,7 @@ class DeviceController extends _$DeviceController {
|
||||
return result.fold(
|
||||
(failure) => false,
|
||||
(updated) {
|
||||
if (!ref.mounted) return false;
|
||||
ref.invalidateSelf();
|
||||
return true;
|
||||
},
|
||||
@ -61,6 +64,7 @@ class DeviceController extends _$DeviceController {
|
||||
}
|
||||
|
||||
void refresh() {
|
||||
if (!ref.mounted) return;
|
||||
ref.invalidateSelf();
|
||||
}
|
||||
}
|
||||
@ -85,6 +89,7 @@ class DeviceDetailController extends _$DeviceDetailController {
|
||||
return result.fold(
|
||||
(failure) => false,
|
||||
(_) {
|
||||
if (!ref.mounted) return false;
|
||||
ref.invalidateSelf();
|
||||
return true;
|
||||
},
|
||||
@ -98,6 +103,7 @@ class DeviceDetailController extends _$DeviceDetailController {
|
||||
return result.fold(
|
||||
(failure) => false,
|
||||
(_) {
|
||||
if (!ref.mounted) return false;
|
||||
ref.invalidateSelf();
|
||||
return true;
|
||||
},
|
||||
@ -105,6 +111,7 @@ class DeviceDetailController extends _$DeviceDetailController {
|
||||
}
|
||||
|
||||
void refresh() {
|
||||
if (!ref.mounted) return;
|
||||
ref.invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@ class _WifiConfigPageState extends ConsumerState<WifiConfigPage>
|
||||
double _progress = 0.0;
|
||||
String _progressText = '正在连接WiFi...';
|
||||
bool _connectFailed = false;
|
||||
bool _isBinding = false;
|
||||
|
||||
// Device Info
|
||||
Map<String, dynamic> _deviceInfo = {};
|
||||
@ -128,12 +129,20 @@ class _WifiConfigPageState extends ConsumerState<WifiConfigPage>
|
||||
if (_currentStep == 2 && _passwordController.text.isEmpty) return;
|
||||
|
||||
if (_currentStep == 4) {
|
||||
if (_isBinding) return;
|
||||
setState(() => _isBinding = true);
|
||||
|
||||
final sn = _deviceInfo['sn'] as String? ?? '';
|
||||
if (sn.isNotEmpty) {
|
||||
debugPrint('[WiFi Config] Binding device sn=$sn');
|
||||
await ref.read(deviceControllerProvider.notifier).bindDevice(sn);
|
||||
try {
|
||||
debugPrint('[WiFi Config] Binding device sn=$sn');
|
||||
await ref.read(deviceControllerProvider.notifier).bindDevice(sn);
|
||||
} catch (e) {
|
||||
debugPrint('[WiFi Config] bindDevice 异常: $e');
|
||||
}
|
||||
}
|
||||
if (!mounted) return;
|
||||
setState(() => _isBinding = false);
|
||||
context.go('/device-control');
|
||||
return;
|
||||
}
|
||||
@ -705,7 +714,7 @@ class _WifiConfigPageState extends ConsumerState<WifiConfigPage>
|
||||
}
|
||||
if (_currentStep == 4) {
|
||||
showNext = true;
|
||||
nextText = '进入设备';
|
||||
nextText = _isBinding ? '绑定中...' : '进入设备';
|
||||
}
|
||||
|
||||
if (!showNext && _currentStep != 3) {
|
||||
@ -764,7 +773,7 @@ class _WifiConfigPageState extends ConsumerState<WifiConfigPage>
|
||||
if (_currentStep < 4) const SizedBox(width: 16),
|
||||
GradientButton(
|
||||
text: nextText,
|
||||
onPressed: _handleNext,
|
||||
onPressed: _isBinding ? null : _handleNext,
|
||||
height: 56,
|
||||
width: _currentStep == 4 ? 200 : 160,
|
||||
),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user