diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index e6cf086b..074847ea 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -606,8 +606,8 @@ class LockDetailLogic extends BaseGetXController { // 远程开锁 Future remoteOpenLock() async { - final LoginEntity entity = await ApiRepository.to - .remoteOpenLock(lockId: state.keyInfos.value.lockId.toString()); + final LoginEntity entity = await ApiRepository.to.remoteOpenLock( + lockId: state.keyInfos.value.lockId.toString(), timeOut: 60); if (entity.errorCode!.codeIsSuccessful) { showToast('已开锁'.tr); } diff --git a/lib/main_local.dart b/lib/main_local.dart index 9e30d007..f56b6d65 100755 --- a/lib/main_local.dart +++ b/lib/main_local.dart @@ -4,7 +4,7 @@ import 'flavors.dart'; import 'main.dart' as runner; Future main() async { - F.appFlavor = Flavor.xhj; + F.appFlavor = Flavor.xhj_pre; // AppLog.log('local调用了main函数'); await runner.main(); } diff --git a/lib/mine/gateway/addGateway/gatewayConfigurationWifi/gatewayConfigurationWifi_logic.dart b/lib/mine/gateway/addGateway/gatewayConfigurationWifi/gatewayConfigurationWifi_logic.dart index 1cf70a9e..17344cda 100644 --- a/lib/mine/gateway/addGateway/gatewayConfigurationWifi/gatewayConfigurationWifi_logic.dart +++ b/lib/mine/gateway/addGateway/gatewayConfigurationWifi/gatewayConfigurationWifi_logic.dart @@ -31,7 +31,8 @@ class GatewayConfigurationWifiLogic extends BaseGetXController { networkName: state.wifiNameTF.text, networkMac: state.gatewayModel.wifiMac, version: state.gatewayModel.gatewayVersion, - gatewayJson: jsonDecode(state.gatewayJson)); + gatewayJson: jsonDecode(state.gatewayJson), + timeout: 60); if (entity.errorCode!.codeIsSuccessful) { showToast('配网成功'.tr, something: () { // eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); @@ -42,7 +43,7 @@ class GatewayConfigurationWifiLogic extends BaseGetXController { Future getGatewayConfiguration() async { final GetGatewayConfigurationEntity entity = - await ApiRepository.to.getGatewayConfiguration(); + await ApiRepository.to.getGatewayConfiguration(timeout: 60); if (entity.errorCode!.codeIsSuccessful) { state.getGatewayConfigurationStr = entity.data ?? ''; // AppLog.log('state.getGatewayConfigurationStr:${state.getGatewayConfigurationStr}'); diff --git a/lib/mine/gateway/addGateway/gatewayConfigurationWifi/gatewayConfigurationWifi_page.dart b/lib/mine/gateway/addGateway/gatewayConfigurationWifi/gatewayConfigurationWifi_page.dart index 02433378..e1e20481 100755 --- a/lib/mine/gateway/addGateway/gatewayConfigurationWifi/gatewayConfigurationWifi_page.dart +++ b/lib/mine/gateway/addGateway/gatewayConfigurationWifi/gatewayConfigurationWifi_page.dart @@ -3,7 +3,6 @@ import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/commonItem.dart'; diff --git a/lib/mine/gateway/addGateway/gatewayGetWifiList/gatewayGetWifiList_logic.dart b/lib/mine/gateway/addGateway/gatewayGetWifiList/gatewayGetWifiList_logic.dart index 28f471e9..9d671e45 100644 --- a/lib/mine/gateway/addGateway/gatewayGetWifiList/gatewayGetWifiList_logic.dart +++ b/lib/mine/gateway/addGateway/gatewayGetWifiList/gatewayGetWifiList_logic.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; -import 'package:star_lock/blue/io_gateway/io_gateway_configuringWifi.dart'; import 'package:star_lock/blue/io_gateway/io_gateway_getWifiList.dart'; import 'package:star_lock/tools/baseGetXController.dart'; diff --git a/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_logic.dart b/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_logic.dart index d670c100..1865d315 100644 --- a/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_logic.dart +++ b/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_logic.dart @@ -12,7 +12,8 @@ class GatewayConnectionLockListLogic extends BaseGetXController { Future gatewayConnectionLockListDataRequest() async { final GatewayConnectionLockListEntity entity = await ApiRepository.to - .gatewayConnectionLockLoadData(gatewayId: state.gatewayId.value); + .gatewayConnectionLockLoadData( + gatewayId: state.gatewayId.value, timeout: 60); if (entity.errorCode!.codeIsSuccessful) { state.itemDataList.value = entity.data!.list!; } @@ -21,7 +22,7 @@ class GatewayConnectionLockListLogic extends BaseGetXController { Future gatewayScanDevice() async { final LoginEntity entity = await ApiRepository.to - .gatewayScanDevice(gatewayId: state.gatewayId.value); + .gatewayScanDevice(gatewayId: state.gatewayId.value, timeout: 60); if (entity.errorCode!.codeIsSuccessful) { gatewayConnectionLockListDataRequest(); } diff --git a/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_page.dart b/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_page.dart index 7eaaa516..8978cfce 100755 --- a/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_page.dart +++ b/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_page.dart @@ -49,7 +49,7 @@ class _GatewayConnectionLockListPageState Obx(() => Expanded( child: state.itemDataList.value.isNotEmpty ? ListView.builder( - itemCount: 10, + itemCount: state.itemDataList.value.length, itemBuilder: (BuildContext c, int index) { final GatewayConnectionLockItemEntity entity = state.itemDataList[index]; diff --git a/lib/mine/gateway/gatewayDetail/gatewayDetail_logic.dart b/lib/mine/gateway/gatewayDetail/gatewayDetail_logic.dart index 5ea251f0..eabb827f 100644 --- a/lib/mine/gateway/gatewayDetail/gatewayDetail_logic.dart +++ b/lib/mine/gateway/gatewayDetail/gatewayDetail_logic.dart @@ -12,7 +12,8 @@ class GatewayDetailLogic extends BaseGetXController { Future deletGateway(int isForce) async { final LoginEntity entity = await ApiRepository.to.gatewayDelet( gatewayId: state.getewayItemData.value.gatewayId ?? 0, - isForce: isForce); + isForce: isForce, + timeout: 60); if (entity.errorCode!.codeIsSuccessful) { showToast('删除成功'.tr, something: () { // eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); @@ -27,7 +28,8 @@ class GatewayDetailLogic extends BaseGetXController { Future updateGateway(String gatewayName) async { final LoginEntity entity = await ApiRepository.to.gatewayUpdate( gatewayId: state.getewayItemData.value.gatewayId ?? 0, - gatewayName: gatewayName); + gatewayName: gatewayName, + timeout: 60); if (entity.errorCode!.codeIsSuccessful) { showToast('修改成功'.tr, something: () { // eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); diff --git a/lib/mine/gateway/gatewayList/gatewayList_logic.dart b/lib/mine/gateway/gatewayList/gatewayList_logic.dart index cb99572f..7606aaae 100644 --- a/lib/mine/gateway/gatewayList/gatewayList_logic.dart +++ b/lib/mine/gateway/gatewayList/gatewayList_logic.dart @@ -1,4 +1,3 @@ - import 'package:star_lock/tools/baseGetXController.dart'; import '../../../login/login/entity/LoginEntity.dart'; @@ -18,9 +17,7 @@ class GatewayListLogic extends BaseGetXController { pageNo = 1; } final GetewayDataEntity entity = await ApiRepository.to.getGatewayListData( - pageNo: pageNo.toString(), - pageSize: pageSize, - ); + pageNo: pageNo.toString(), pageSize: pageSize, timeout: 60); if (entity.errorCode!.codeIsSuccessful) { // 更新数据列表 state.getewayListData.addAll(entity.data!.list!); @@ -51,7 +48,6 @@ class GatewayListLogic extends BaseGetXController { // @override // void onInit() { // super.onInit(); - // gatewayDistributionNetwork(); + // gatewayDistributionNetwork(); // } - -} \ No newline at end of file +} diff --git a/lib/mine/mineSet/transferGateway/selectGetewayList_logic.dart b/lib/mine/mineSet/transferGateway/selectGetewayList_logic.dart index 26333cdd..558d4027 100755 --- a/lib/mine/mineSet/transferGateway/selectGetewayList_logic.dart +++ b/lib/mine/mineSet/transferGateway/selectGetewayList_logic.dart @@ -1,20 +1,17 @@ - import 'package:star_lock/mine/mineSet/transferGateway/selectGetewayList_entity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import '../../../network/api_repository.dart'; import 'selectGetewayList_state.dart'; -class SelectGetewayListLogic extends BaseGetXController{ +class SelectGetewayListLogic extends BaseGetXController { SelectGetewayListState state = SelectGetewayListState(); // 获取锁列表 - Future getGetewayListData() async{ - final GetewayDataEntity entity = await ApiRepository.to.getGatewayListData( - pageNo: '1', - pageSize: '20' - ); - if(entity.errorCode!.codeIsSuccessful){ + Future getGetewayListData() async { + final GetewayDataEntity entity = await ApiRepository.to + .getGatewayListData(pageNo: '1', pageSize: '20', timeout: 60); + if (entity.errorCode!.codeIsSuccessful) { state.getewayListData.value = entity.data!.list!; } } @@ -25,5 +22,4 @@ class SelectGetewayListLogic extends BaseGetXController{ getGetewayListData(); } - -} \ No newline at end of file +} diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index 76677fa1..aa72dd07 100755 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -1727,21 +1727,23 @@ class ApiProvider extends BaseProvider { })); // 获取网关列表 - Future getGatewayListData(String pageNo, String pageSize) => post( - gatewaykListURL.toUrl, - jsonEncode({'pageNo': pageNo, 'pageSize': pageSize})); + Future getGatewayListData( + String pageNo, String pageSize, int timeout) => + post(gatewaykListURL.toUrl, + jsonEncode({'pageNo': pageNo, 'pageSize': pageSize}), + timeout: timeout); // 添加网关 Future addGatewayNetwork( - String gatewayName, - String gatewayMac, - String serialNumber, - int gatewayType, - String networkName, - String networkMac, - String version, - Map gatewayJson, - ) => + String gatewayName, + String gatewayMac, + String serialNumber, + int gatewayType, + String networkName, + String networkMac, + String version, + Map gatewayJson, + int timeout) => post( addGatewayURL.toUrl, jsonEncode({ @@ -1753,37 +1755,37 @@ class ApiProvider extends BaseProvider { 'networkMac': networkMac, 'version': version, 'gatewayJson': gatewayJson, - })); + }), + timeout: timeout); // 删除网关 - Future deletGateway(int gatewayId, int isForce) => post( - deletGatewayURL.toUrl, - jsonEncode({ - 'gatewayId': gatewayId, - 'isForce': isForce, - })); + Future deletGateway(int gatewayId, int isForce, int timeout) => + post( + deletGatewayURL.toUrl, + jsonEncode({ + 'gatewayId': gatewayId, + 'isForce': isForce, + }), + timeout: timeout); // 网关更新 Future gatewayUpdate( - int gatewayId, - String gatewayName, - ) => + int gatewayId, String gatewayName, int timeout) => post( updateGatewayURL.toUrl, jsonEncode({ 'gatewayId': gatewayId, 'gatewayName': gatewayName, - })); + }), + timeout: timeout); // 远程开锁 - Future remoteOpenLock( - String lockId, - ) => - post( - remoteOpenLockURL.toUrl, - jsonEncode({ - 'lockId': lockId, - })); + Future remoteOpenLock(String lockId, int timeOut) => post( + remoteOpenLockURL.toUrl, + jsonEncode({ + 'lockId': lockId, + }), + timeout: timeOut); // 转移网关确认 Future transferGatewayConfirmInfoData( @@ -1808,14 +1810,17 @@ class ApiProvider extends BaseProvider { })); // 获取网关配置 - Future getGatewayConfiguration() => - post(getGatewayConfigURL.toUrl, jsonEncode({})); + Future getGatewayConfiguration(int timeout) => + post(getGatewayConfigURL.toUrl, jsonEncode({}), timeout: timeout); - Future gatewayConnectionLockListLoadData(int gatewayId) => - post(gatewayListByLockURL.toUrl, jsonEncode({'gatewayId': gatewayId})); + Future gatewayConnectionLockListLoadData( + int gatewayId, int timeout) => + post(gatewayListByLockURL.toUrl, jsonEncode({'gatewayId': gatewayId}), + timeout: timeout); - Future gatewayScanDevice(int gatewayId) => - post(gatewayScanDeviceURL.toUrl, jsonEncode({'gatewayId': gatewayId})); + Future gatewayScanDevice(int gatewayId, int timeout) => + post(gatewayScanDeviceURL.toUrl, jsonEncode({'gatewayId': gatewayId}), + timeout: timeout); // 移除坏锁 Future removeBrokenLockData(List lockIdList) => diff --git a/lib/network/api_provider_base.dart b/lib/network/api_provider_base.dart index e6563cdb..2d941506 100755 --- a/lib/network/api_provider_base.dart +++ b/lib/network/api_provider_base.dart @@ -37,6 +37,7 @@ class BaseProvider extends GetConnect with Api { bool? isUserBaseUrl = true, // 文件上传不使用baseUrl bool? isShowErrMsg = true, // 是否显示没有网络时的提示 bool? isShowNetworkErrorMsg = true, // 是否显示网络其他报错 如403 500等 + int? timeout = 15, }) async { AppLog.log('post: url:$url body:$body'); if (isUnShowLoading == false) { @@ -47,6 +48,8 @@ class BaseProvider extends GetConnect with Api { } else { httpClient.baseUrl = '${F.apiPrefix}/api'; } + httpClient.timeout = timeout!.seconds; + // AppLog.log('timeout:$timeout httpClient.timeout:${httpClient.timeout}'); var res = await super.post(url, body, contentType: contentType, headers: headers, @@ -78,7 +81,7 @@ class BaseProvider extends GetConnect with Api { statusText: res.statusText, ); } else {} - if(isShowNetworkErrorMsg ?? true){ + if (isShowNetworkErrorMsg ?? true) { getDataResult(res.body); } return res; diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index 1f793ff0..53d9b263 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -1912,22 +1912,24 @@ class ApiRepository { // 获取网关列表 Future getGatewayListData( - {required String pageNo, required String pageSize}) async { - final res = await apiProvider.getGatewayListData(pageNo, pageSize); + {required String pageNo, + required String pageSize, + required int timeout}) async { + final res = await apiProvider.getGatewayListData(pageNo, pageSize, timeout); return GetewayDataEntity.fromJson(res.body); } // 添加网关 - Future gatewayDistributionNetwork({ - required String gatewayName, - required String gatewayMac, - required String serialNumber, - required int gatewayType, - required String networkName, - required String networkMac, - required String version, - required Map gatewayJson, - }) async { + Future gatewayDistributionNetwork( + {required String gatewayName, + required String gatewayMac, + required String serialNumber, + required int gatewayType, + required String networkName, + required String networkMac, + required String version, + required Map gatewayJson, + required int timeout}) async { final res = await apiProvider.addGatewayNetwork( gatewayName, gatewayMac, @@ -1936,25 +1938,27 @@ class ApiRepository { networkName, networkMac, version, - gatewayJson); + gatewayJson, + timeout); return LoginEntity.fromJson(res.body); } // 删除网关 - Future gatewayDelet({ - required int gatewayId, - required int isForce, - }) async { - final res = await apiProvider.deletGateway(gatewayId, isForce); + Future gatewayDelet( + {required int gatewayId, + required int isForce, + required int timeout}) async { + final res = await apiProvider.deletGateway(gatewayId, isForce, timeout); return LoginEntity.fromJson(res.body); } // 网关更新 - Future gatewayUpdate({ - required int gatewayId, - required String gatewayName, - }) async { - final res = await apiProvider.gatewayUpdate(gatewayId, gatewayName); + Future gatewayUpdate( + {required int gatewayId, + required String gatewayName, + required int timeout}) async { + final res = + await apiProvider.gatewayUpdate(gatewayId, gatewayName, timeout); return LoginEntity.fromJson(res.body); } @@ -1970,22 +1974,23 @@ class ApiRepository { // 网关-附近的锁 Future gatewayConnectionLockLoadData( - {required int gatewayId}) async { - final res = await apiProvider.gatewayConnectionLockListLoadData(gatewayId); + {required int gatewayId, required int timeout}) async { + final res = + await apiProvider.gatewayConnectionLockListLoadData(gatewayId, timeout); return GatewayConnectionLockListEntity.fromJson(res.body); } // 网关-扫描设备 - Future gatewayScanDevice({ - required int gatewayId, - }) async { - final res = await apiProvider.gatewayScanDevice(gatewayId); + Future gatewayScanDevice( + {required int gatewayId, required int timeout}) async { + final res = await apiProvider.gatewayScanDevice(gatewayId, timeout); return LoginEntity.fromJson(res.body); } // 远程开锁 - Future remoteOpenLock({required String lockId}) async { - final res = await apiProvider.remoteOpenLock(lockId); + Future remoteOpenLock( + {required String lockId, required int timeOut}) async { + final res = await apiProvider.remoteOpenLock(lockId, timeOut); return LoginEntity.fromJson(res.body); } @@ -2000,8 +2005,9 @@ class ApiRepository { } // 获取网关配置 - Future getGatewayConfiguration() async { - final res = await apiProvider.getGatewayConfiguration(); + Future getGatewayConfiguration( + {required int timeout}) async { + final res = await apiProvider.getGatewayConfiguration(timeout); return GetGatewayConfigurationEntity.fromJson(res.body); } diff --git a/pubspec.yaml b/pubspec.yaml index 2d34dcf6..30320b8d 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -104,7 +104,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # 1.0.85+2024120301:完善网关功能 # 1.0.85+2024120401:修复网关问题,打包给谢敬调试 -version: 1.0.85+2024121301 +version: 1.0.85+2024123102 environment: sdk: '>=2.12.0 <3.0.0'