Merge branch 'develop_liyi' of code-internal.star-lock.cn:StarlockTeam/app-starlock into develop_liyi

This commit is contained in:
Liuyf 2025-02-07 15:44:47 +08:00
commit d5ac3ebf3e
10 changed files with 106 additions and 90 deletions

View File

@ -35,7 +35,6 @@ abstract class SenderProtocol extends IOData {
void printLog(List<int> data) {
AppLog.log(
"App -> 锁,指令类型:${commandType!.typeName} ${commandType!.typeValue == 0x3030 ? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}");
AppLog.log("子命令数据是:${data.sublist(66, 79)}");
}
//

View File

@ -1,4 +1,5 @@
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart';
import 'package:star_lock/talk/starChart/entity/star_chart_register_node_entity.dart';
class LoginData {
LoginData(
@ -63,4 +64,13 @@ class LoginData {
}
return map;
}
void updateStarchart(
StarChartRegisterNodeEntity starChartRegisterNodeEntity) {
starchart = Starchart(
starchartId: starChartRegisterNodeEntity.peer?.id,
starchartPeerPublicKey: starChartRegisterNodeEntity.peer?.publicKey,
starchartPeerPrivateKey: starChartRegisterNodeEntity.peer?.privateKey,
);
}
}

View File

@ -58,17 +58,22 @@ class StarLockLoginLogic extends BaseGetXController {
'login_res': '成功',
});
Storage.saveLoginData(entity.data);
Storage.setBool(saveIsVip, entity.data!.isVip == 1);
//
if (entity.data!.starchart != null) {
final Starchart starChart = entity.data!.starchart!;
Storage.saveStarChartRegisterNodeInfo(StarChartRegisterNodeEntity(
peer: PeerData(
id: starChart.starchartId,
publicKey: starChart.starchartPeerPublicKey,
privateKey: starChart.starchartPeerPrivateKey)));
final StarChartRegisterNodeEntity starChartRegisterNodeEntity =
StarChartRegisterNodeEntity(
peer: PeerData(
id: starChart.starchartId,
publicKey: starChart.starchartPeerPublicKey,
privateKey: starChart.starchartPeerPrivateKey,
),
);
Storage.saveStarChartRegisterNodeInfo(starChartRegisterNodeEntity);
entity.data!.updateStarchart(starChartRegisterNodeEntity);
}
Storage.saveLoginData(entity.data);
Storage.setBool(saveIsVip, entity.data!.isVip == 1);
eventBus.fire(MineInfoChangeRefreshUI());
if (Get.isRegistered<LockMainLogic>()) {
Get.find<LockMainLogic>().getStarLockInfo(isUnShowLoading: true);

View File

@ -10,6 +10,7 @@ import 'package:star_lock/apm/apm_helper.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/main/lockDetail/lockDetail/device_network_info.dart';
import 'package:star_lock/main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart';
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
import 'package:star_lock/talk/starChart/constant/talk_status.dart';
@ -744,12 +745,40 @@ class LockDetailLogic extends BaseGetXController {
eventBus.fire(RefreshLockDetailInfoDataEvent());
}
///
void _requestDeviceNetworkInfo() async {
final DeviceNetwork deviceNetworkInfo =
await ApiRepository.to.getDeviceNetwork(
deviceType: 2,
deviceMac: state.keyInfos.value.mac!,
);
if (deviceNetworkInfo.data?.wifiName == null ||
deviceNetworkInfo.data?.wifiName == '') {
return;
} else {
final peerId = deviceNetworkInfo?.data?.peerId;
if (peerId == null || peerId.isEmpty || peerId == '') {
throw Exception('设备peerId为空');
}
// peerID
StartChartManage().lockPeerId = peerId;
}
}
///
void sendMonitorMessage() {
// id
StartChartManage().startCallRequestMessageTimer(
ToPeerId: StartChartManage().lockPeerId ?? '');
}
@override
Future<void> onReady() async {
super.onReady();
getServerDatetime();
await PermissionDialog.request(Permission.location);
await PermissionDialog.requestBluetooth();
_requestDeviceNetworkInfo();
}
@override

View File

@ -68,7 +68,7 @@ class _LockDetailPageState extends State<LockDetailPage>
lockListInfoItemEntity: widget.lockListInfoItemEntity,
isOnlyOneData: widget.isOnlyOneData);
_handleLockMonitor2();
}
@override
@ -1164,7 +1164,7 @@ class _LockDetailPageState extends State<LockDetailPage>
showWidgetArr.add(
bottomItem('images/main/icon_catEyes.png', '监控'.tr,
state.bottomBtnisEable.value, () async {
await _handleLockMonitor();
logic.sendMonitorMessage();
}),
);
}
@ -1572,36 +1572,4 @@ class _LockDetailPageState extends State<LockDetailPage>
BlueManage().disconnect();
}
Future<void> _handleLockMonitor2() async {
final lockId = state.keyInfos.value.lockId;
final LockSetInfoEntity entity =
await ApiRepository.to.getLockSettingInfoData(
lockId: lockId.toString(),
);
if (entity.errorCode!.codeIsSuccessful) {
final LockSetInfoData data = entity.data!;
final mac = data.lockBasicInfo?.mac;
if (mac != null && mac.isNotEmpty) {
final DeviceNetwork deviceNetworkInfo = await ApiRepository.to
.getDeviceNetwork(deviceType: 2, deviceMac: mac);
if (deviceNetworkInfo.data?.wifiName == null ||
deviceNetworkInfo.data?.wifiName == '') {
return;
} else {
final peerId = deviceNetworkInfo?.data?.peerId;
if (peerId == null || peerId.isEmpty || peerId == '') {
throw Exception('设备peerId为空');
}
// peerID
StartChartManage().lockPeerId = peerId;
}
}
}
}
Future<void> _handleLockMonitor() async {
// id
StartChartManage().startCallRequestMessageTimer(
ToPeerId: StartChartManage().lockPeerId ?? '');
}
}

View File

@ -313,7 +313,7 @@ class LockMainLogic extends BaseGetXController {
// UDP
// AppLog.log('onReady() LockMainLogic');
UdpHelp().openUDP();
// UdpHelp().openUDP();
BlueManage();
}

View File

@ -53,9 +53,11 @@ class LockMainXHJLogic extends BaseGetXController {
}
}
if (entity.data!.starchart != null) {
if (entity.data!.starchart!.starchartId!.isEmpty) {
if (entity.data!.starchart!.starchartId == null) {
bindStarChart();
}
} else {
StartChartManage().init();
}
}
}

View File

@ -141,7 +141,7 @@ class MineSetLogic extends BaseGetXController {
'logout_result': '成功',
});
UdpHelp().closeUDP();
// UdpHelp().closeUDP();
logOut();
StoreService.to.saveLanguageCode('');

View File

@ -146,23 +146,23 @@ class StartChartManage {
await _requestStarChartRegisterNode();
await _saveStarChartRegisterNodeToStorage(requestStarChartRegisterNode);
FromPeerId = requestStarChartRegisterNode.peer!.id ?? '';
bindUserStarchart();
bindUserStarchart(requestStarChartRegisterNode);
}
}
//
Future<void> bindUserStarchart() async {
Future<void> bindUserStarchart(
StarChartRegisterNodeEntity requestStarChartRegisterNode) async {
try {
final StarChartRegisterNodeEntity? registerNodeEntity =
await Storage.getStarChartRegisterNodeInfo();
final LoginEntity entity = await ApiRepository.to.bindUserStarchart(
starchartId: registerNodeEntity?.peer?.id ?? '',
starchartPeerPublicKey: registerNodeEntity?.peer?.publicKey ?? '',
starchartPeerPrivateKey: registerNodeEntity?.peer?.privateKey ?? '',
starchartId: requestStarChartRegisterNode.peer?.id ?? '',
starchartPeerPublicKey:
requestStarChartRegisterNode.peer?.publicKey ?? '',
starchartPeerPrivateKey:
requestStarChartRegisterNode.peer?.privateKey ?? '',
);
registerNodeEntity?.peer?.id = entity.data?.starchart?.starchartId;
await Storage.saveStarChartRegisterNodeInfo(registerNodeEntity!);
requestStarChartRegisterNode.peer?.id =
entity.data?.starchart?.starchartId;
if (entity.errorCode!.codeIsSuccessful) {
AppLog.log('绑定成功');
} else {
@ -762,6 +762,9 @@ class StartChartManage {
StarChartRegisterNodeEntity starChartRegisterNodeEntity) async {
if (starChartRegisterNodeEntity != null) {
await Storage.saveStarChartRegisterNodeInfo(starChartRegisterNodeEntity);
final LoginData? loginData = await Storage.getLoginData();
loginData?.updateStarchart(starChartRegisterNodeEntity);
Storage.saveLoginData(loginData);
}
}
@ -779,9 +782,9 @@ class StartChartManage {
final RelayInfoEntity? relayInfoEntity = await Storage.getRelayInfo();
//
final publicKey = await getPublicKey();
final String publicKey = await getPublicKey();
//
final privateKey = await getPrivateKey();
final String privateKey = await getPrivateKey();
//
final sign = await DoSign().generateSign(
currentTimestamp: relayInfoEntity!.time ?? 0,

View File

@ -255,39 +255,39 @@ class _TalkViewPageState extends State<TalkViewPage>
)
: Container()),
//ToDo:
Visibility(
visible: true,
child: Positioned(
top: 20, //
left: 20,
right: 20, //
child: Container(
height: 100, // 100
color: Colors.black.withOpacity(0.5), //
padding: const EdgeInsets.all(10), //
child: Consumer<DebugInfoModel>(
builder: (BuildContext context, DebugInfoModel debugInfo,
Widget? child) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'recv ${debugInfo.recvDataRate}KB/s [${debugInfo.recvPacketCount}]',
style: const TextStyle(
color: Colors.white), //
),
Text(
'send ${debugInfo.sendDataRate}KB/s [${debugInfo.sendPacketCount}]',
style: const TextStyle(
color: Colors.white), //
),
],
);
},
),
),
),
),
// Visibility(
// visible: true,
// child: Positioned(
// top: 20, //
// left: 20,
// right: 20, //
// child: Container(
// height: 100, // 100
// color: Colors.black.withOpacity(0.5), //
// padding: const EdgeInsets.all(10), //
// child: Consumer<DebugInfoModel>(
// builder: (BuildContext context, DebugInfoModel debugInfo,
// Widget? child) {
// return Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: <Widget>[
// Text(
// 'recv ${debugInfo.recvDataRate}KB/s [${debugInfo.recvPacketCount}]',
// style: const TextStyle(
// color: Colors.white), //
// ),
// Text(
// 'send ${debugInfo.sendDataRate}KB/s [${debugInfo.sendPacketCount}]',
// style: const TextStyle(
// color: Colors.white), //
// ),
// ],
// );
// },
// ),
// ),
// ),
// ),
//
// Positioned(
// top: 120,