This commit is contained in:
wyf
2025-06-22 19:10:47 +08:00
parent 8c27f0b26c
commit c21896a408
2 changed files with 85 additions and 9 deletions

View File

@@ -6,6 +6,7 @@ import 'package:easydevice/easydevice.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/controller/user_info_controller.dart';
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
import 'package:vbvs_app/pages/mh_page/room_picker.dart';
class WebviewTestModel {
WebviewTestModel();
@@ -16,14 +17,14 @@ class WebviewTestModel {
}
class WebviewTestController extends GetControllerEx<WebviewTestModel> {
var selectDevice;
var bluetooth = false;
var selectDevice = {};
var bluetooth = 0;
WebviewTestController() : super(WebviewTestModel()) {
web = WebviewHelper(
jsbridge: buildsdk(
father: this,
// clientId: '494641114',
//dbgserverUrl: 'ws://192.168.1.2:9001',
clientId: '494641114',
// dbgserverUrl: 'ws://192.168.1.2:9001',
),
settings: buildsettings(),
params: PlatformHeadlessInAppWebViewCreationParams(
@@ -46,19 +47,29 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
bridge.sdk.updateDeviceRoute((args) async {
ef.log('updateDeviceRoute: $args');
selectDevice['blueToothStatus'] = bluetooth;
Get.toNamed("$args[0]", arguments: selectDevice);
Get.toNamed("${args[0]}", arguments: selectDevice);
return true;
});
bridge.sdk.selectDevice((args) {
bridge.sdk.selectDevice((args) async {
ef.log('selectDevice: $args');
selectDevice = args[0];
return true;
});
bridge.sdk.updateBlueToothStatus((args) {
bridge.sdk.updateBlueToothStatus((args) async {
ef.log('updateBlueToothStatus: $args');
bluetooth = args[0];
return true;
});
//sdk定义接口
bridge.sdk.querySelectDevice((args) async {
ef.log('updateBlueToothStatus: $args');
// bluetooth = args[0];
MHTHomeController deviceController = Get.find();
final allDevices = deviceController.deviceList.values
.expand((list) => list)
.toList();
return allDevices;
});
});
web
//.file(
@@ -90,7 +101,7 @@ class WebviewTestView extends GetComponent<WebviewTestController> {
Widget build(BuildContext context) {
UserInfoController userInfoController = Get.find();
MHTHomeController deviceController = Get.find();
deviceController.getDeviceList(group: 'room').then((x) {
deviceController.getDeviceList().then((x) {
if (controller.web.jsbridge!.inited) {
//发送测试消息给webview
controller.web.jsbridge!.dart