This commit is contained in:
wyf
2025-06-22 12:04:57 +08:00
parent 6f076f6d74
commit 8c27f0b26c
2 changed files with 36 additions and 9 deletions

View File

@@ -16,6 +16,8 @@ class WebviewTestModel {
}
class WebviewTestController extends GetControllerEx<WebviewTestModel> {
var selectDevice;
var bluetooth = false;
WebviewTestController() : super(WebviewTestModel()) {
web = WebviewHelper(
jsbridge: buildsdk(
@@ -29,13 +31,34 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
url: WebUri(
'https://wyf.it.real.he-info.cn:94/goods-front/index.html'),
),
onLoadStop: (controller, url) => {setState(() => ready.value = true)},
onLoadStop: (controller, url) {
setState(() => ready.value = true);
MHTHomeController deviceController = Get.find();
web.jsbridge!.dart
.updateDeviceList(deviceController.deviceList.values);
},
),
);
try {
web.jsbridge!.bind((bridge) {
var minible = Minibleapp(bridge: bridge);
// minible.bridge.sdk.ble.scanenable(5);
// ef.kvroot.devicelist.listen((x) {});
bridge.sdk.updateDeviceRoute((args) async {
ef.log('updateDeviceRoute: $args');
selectDevice['blueToothStatus'] = bluetooth;
Get.toNamed("$args[0]", arguments: selectDevice);
return true;
});
bridge.sdk.selectDevice((args) {
ef.log('selectDevice: $args');
selectDevice = args[0];
return true;
});
bridge.sdk.updateBlueToothStatus((args) {
ef.log('updateBlueToothStatus: $args');
bluetooth = args[0];
return true;
});
});
web
//.file(
@@ -45,7 +68,6 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
.network()
.then((value) {
if (value) {
//资源准备完成..
setState(() {
ready.value = true;
});
@@ -68,7 +90,14 @@ class WebviewTestView extends GetComponent<WebviewTestController> {
Widget build(BuildContext context) {
UserInfoController userInfoController = Get.find();
MHTHomeController deviceController = Get.find();
deviceController.getDeviceList(group: 'room');
deviceController.getDeviceList(group: 'room').then((x) {
if (controller.web.jsbridge!.inited) {
//发送测试消息给webview
controller.web.jsbridge!.dart
.updateDeviceList(deviceController.deviceList.values);
}
});
return Scaffold(
backgroundColor: Colors.black12,
body: Column(
@@ -90,9 +119,7 @@ class WebviewTestView extends GetComponent<WebviewTestController> {
),
);
}
WebviewTestController webviewTestController = Get.find();
var dataList = deviceController.deviceList.value;
webviewTestController.web.jsbridge!.dart.updateDeviceList(dataList);
return Expanded(
child: Align(
alignment: Alignment.topLeft,