更新睡眠报告正式地址
This commit is contained in:
@@ -44,10 +44,11 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
||||
web = WebviewHelper(
|
||||
isheadless: false,
|
||||
jsbridge: buildsdk(
|
||||
// father: this,
|
||||
// clientId: '494641114',
|
||||
// dbgserverUrl: 'ws://192.168.1.2:9001',
|
||||
),
|
||||
// father: this,
|
||||
// clientId: '123',
|
||||
// clientId: '494641114',
|
||||
// dbgserverUrl: 'ws://192.168.1.2:9001',
|
||||
),
|
||||
settings: buildsettings(),
|
||||
params: PlatformHeadlessInAppWebViewCreationParams(
|
||||
onLoadStop: (controller, url) {
|
||||
@@ -56,9 +57,9 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
||||
});
|
||||
},
|
||||
onLoadResource: (controller, resource) {
|
||||
sourceTime = web.requestTimestamp;
|
||||
ef.log("[请求资源时间]${web.requestTimestamp}");
|
||||
_startMonitoringIfNeeded();
|
||||
// sourceTime = web.requestTimestamp;
|
||||
// ef.log("[请求资源时间]${web.requestTimestamp}");`
|
||||
// _startMonitoringIfNeeded();
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -113,7 +114,6 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
final normalizedMac = mac.replaceAll(":", "").toUpperCase();
|
||||
|
||||
if (deviceId != null &&
|
||||
@@ -291,7 +291,7 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
||||
return true;
|
||||
});
|
||||
bridge.sdk.updatePermisson((args) async {
|
||||
ef.log('获取权限: $args[0]');
|
||||
// ef.log('获取权限: $args[0]');
|
||||
try {
|
||||
if (MainPageBBottomChange.getCurrentIndex() != 2) {
|
||||
return false;
|
||||
@@ -331,6 +331,17 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
||||
// }
|
||||
// return true;
|
||||
// });
|
||||
bridge.sdk.loadFinish((args) async {
|
||||
ef.log('[资源加载完成]: $args[0]');
|
||||
try {
|
||||
loadRecource.value = true;
|
||||
updateAll();
|
||||
return true;
|
||||
} catch (e) {
|
||||
ef.log("[资源加载完成]:$e");
|
||||
}
|
||||
return true;
|
||||
});
|
||||
});
|
||||
} catch (e, s) {
|
||||
ef.log('$e,$s');
|
||||
@@ -371,7 +382,7 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
||||
ws = Easyws(
|
||||
url: ServiceConstant.webSocketService,
|
||||
onData: (data) {
|
||||
ef.log("ws recv =>$data");
|
||||
// ef.log("ws recv =>$data");
|
||||
try {
|
||||
var tmp;
|
||||
if (data is String) {
|
||||
@@ -412,7 +423,7 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
||||
"data": {"mac".tr: mac},
|
||||
});
|
||||
if (success) {
|
||||
ef.log("✅ 已取消监听:$mac");
|
||||
// ef.log("✅ 已取消监听:$mac");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -435,7 +446,7 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
||||
"data": {"mac".tr: mac},
|
||||
});
|
||||
if (success) {
|
||||
ef.log("✅ 开始监听新设备:$mac");
|
||||
// ef.log("✅ 开始监听新设备:$mac");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -470,25 +481,6 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
||||
ef.log('$e,$s');
|
||||
}
|
||||
}
|
||||
|
||||
void _startMonitoringIfNeeded() {
|
||||
// 如果定时器已启动,则无需重新启动
|
||||
if (_resourceLoadTimer != null) return;
|
||||
|
||||
_resourceLoadTimer = Timer.periodic(Duration(seconds: 1), (timer) {
|
||||
int now = DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
if (sourceTime == 0) return; // 还未加载任何资源
|
||||
|
||||
if (now - sourceTime > 3000) {
|
||||
ef.log("[资源加载完成] 当前时间: $now, 上次请求时间: $sourceTime");
|
||||
_resourceLoadTimer?.cancel();
|
||||
_resourceLoadTimer = null;
|
||||
loadRecource.value = true;
|
||||
updateAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class WebviewTestView extends GetComponent<WebviewTestController> {
|
||||
@@ -634,19 +626,67 @@ class WebviewTestView extends GetComponent<WebviewTestController> {
|
||||
child: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Obx(() {
|
||||
int? aa = MainPageBBottomChange.getCurrentIndex();
|
||||
print(aa);
|
||||
// return (controller.ready.value && (MainPageBBottomChange.getCurrentIndex() == 2))
|
||||
return (controller.ready.value)
|
||||
? controller.web.build()
|
||||
: Center(
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
themeController.currentColor.sc1,
|
||||
// return (controller.ready.value && (MainPageBBottomChange.getCurrentIndex() == 2)&& controller.loadRecource.value == true)
|
||||
// return Stack(children: [
|
||||
// controller.ready.value
|
||||
// ? controller.web.build()
|
||||
// : Container(),
|
||||
// Text("1222121212"),
|
||||
// ]);
|
||||
// return Stack(
|
||||
// children: [
|
||||
// controller.ready.value
|
||||
// ? controller.web.build()
|
||||
// : Container(),
|
||||
|
||||
// // 只有 loadRecource == false 时才显示覆盖文字
|
||||
// if (!controller.loadRecource.value)
|
||||
// Positioned.fill(
|
||||
// child: Container(
|
||||
// color: Colors.black54, // 半透明遮罩,可选
|
||||
// alignment: Alignment.center,
|
||||
// child: Text(
|
||||
// "资源加载中...",
|
||||
// style: TextStyle(
|
||||
// color: Colors.red,
|
||||
// fontSize: 30.rpx,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
return Stack(
|
||||
children: [
|
||||
controller.ready.value
|
||||
? controller.web.build()
|
||||
: Container(),
|
||||
if (!controller.loadRecource.value)
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage(
|
||||
'assets/images/new_background.png'),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CircularProgressIndicator(
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user