js_utils.dart 1.1 KB

1234567891011121314151617181920212223242526272829
  1. import 'dart:js' as js;
  2. final ifCurEnvIsShell = js.context.hasProperty('FisShellApi');
  3. final _shellApi = ifCurEnvIsShell
  4. ? js.context['FisShellApi'] as js.JsObject
  5. : js.JsObject(js.context['Object']);
  6. js.JsObject callShellMethod(String method, List<dynamic>? args) {
  7. if (ifCurEnvIsShell) {
  8. return _shellApi.callMethod(method, args ?? []);
  9. } else {
  10. return js.JsObject(js.context['Object']);
  11. }
  12. }
  13. /// JS call Shell 方法,触发 Shell 的切割面计算,会返回一个 Promise 对象回到 JS 上下文,再触发 threejs 内的切割事件
  14. js.JsObject callShellGetClipPlaneData(msg) {
  15. // debugPrint('webview 触发 Dart_getClipPlaneData :$msg');
  16. return callShellMethod('getClipPlaneData', [msg]);
  17. }
  18. /// JS call Shell 方法,获取 AI 切割面
  19. js.JsObject callShellGetVesselClipPlanePoints(msg) {
  20. return callShellMethod('getVesselClipPlanePoints', []);
  21. }
  22. /// JS call Shell 方法,切换测量模式 即转 颈动脉 2D 测量
  23. js.JsObject callShellSwitchMeasureMode(res, imageAdjustPara) =>
  24. callShellMethod("switchMeasureMode", [res, imageAdjustPara.toJson()]);