接入高清场站地图
This commit is contained in:
@@ -13,9 +13,7 @@ class RoutePaths {
|
||||
static const remoteControl = '/home/remote_control';
|
||||
static const routePlan = '/home/route_plan';
|
||||
static const runningStatus = '/home/running_status';
|
||||
static const djMap = '/home/dj_map';
|
||||
|
||||
static const machineDetails = '/machine_details/machine_details';
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
82
lib/features/home/presentation/pages/dj_page.dart
Normal file
82
lib/features/home/presentation/pages/dj_page.dart
Normal file
@@ -0,0 +1,82 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:maibu_satabot_v2/core/router/route_paths.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
class DjPage extends StatefulWidget {
|
||||
const DjPage({super.key});
|
||||
|
||||
@override
|
||||
State<DjPage> createState() => _DjPageState();
|
||||
}
|
||||
|
||||
class _DjPageState extends State<DjPage> {
|
||||
late final WebViewController controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
final url = "https://pvs.satabot.com/?platform=flutter&t=${DateTime.now().millisecondsSinceEpoch}";
|
||||
|
||||
controller = WebViewController()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
// 监听 H5 消息
|
||||
..addJavaScriptChannel(
|
||||
'MapChannel',
|
||||
onMessageReceived: (JavaScriptMessage message) {
|
||||
_handleJsMessage(message.message);
|
||||
},
|
||||
)
|
||||
// 加载网页
|
||||
..loadRequest(Uri.parse(url));
|
||||
}
|
||||
|
||||
/// 处理 H5 返回的数据
|
||||
void _handleJsMessage(String msg) {
|
||||
debugPrint("H5消息: $msg");
|
||||
|
||||
try {
|
||||
final data = jsonDecode(msg);
|
||||
|
||||
final action = data["action"];
|
||||
final page = data["page"];
|
||||
|
||||
if (action == "navigate") {
|
||||
if (page == "gaode") {
|
||||
_openGaode();
|
||||
}
|
||||
|
||||
if (page == "StatusFragment") {
|
||||
context.go(RoutePaths.routePlan);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint("解析H5消息失败: $e");
|
||||
}
|
||||
}
|
||||
|
||||
/// 打开高德地图页面
|
||||
void _openGaode() {
|
||||
context.go(RoutePaths.routePlan);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
||||
onPressed: () {
|
||||
context.go(RoutePaths.home);
|
||||
},
|
||||
),
|
||||
title: const Text("路径规划", style: TextStyle(color: Colors.white)),
|
||||
backgroundColor: const Color(0xFF1677FF),
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
body: WebViewWidget(controller: controller),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -961,9 +961,6 @@ class _RunningStatusPageState extends State<RunningStatusPage> {
|
||||
),
|
||||
// 新增:AppBar底部阴影优化
|
||||
shadowColor: Colors.black12,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(12), bottomRight: Radius.circular(12)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/pages/dj_page.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/pages/home_page.dart';
|
||||
|
||||
import '../../../../core/di/injection.dart';
|
||||
@@ -22,13 +23,11 @@ class HomeRoutes {
|
||||
child: const RemoteControlPage(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: RoutePaths.routePlan,
|
||||
builder: (context, state) => const RoutePlanPage(),
|
||||
),
|
||||
GoRoute(path: RoutePaths.routePlan, builder: (context, state) => const RoutePlanPage()),
|
||||
GoRoute(path: RoutePaths.djMap, builder: (context, state) => const DjPage()),
|
||||
GoRoute(
|
||||
path: RoutePaths.runningStatus,
|
||||
// builder: (context, state) => const RunningStatusPage(),
|
||||
// builder: (context, state) => const RunningStatusPage(),
|
||||
builder: (context, state) => BlocProvider(
|
||||
create: (_) => sl<DeviceStatusBloc>(), // 从 GetIt 获取单例
|
||||
child: const RunningStatusPage(),
|
||||
@@ -39,11 +38,6 @@ class HomeRoutes {
|
||||
/// 2. 首页 Tab 分支(带导航栏)
|
||||
/// 仅保留真正的首页入口
|
||||
static StatefulShellBranch get branch => StatefulShellBranch(
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: RoutePaths.home,
|
||||
builder: (context, state) => const HomePage(),
|
||||
),
|
||||
],
|
||||
routes: [GoRoute(path: RoutePaths.home, builder: (context, state) => const HomePage())],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:maibu_satabot_v2/components/confrim_dialog.dart';
|
||||
@@ -18,6 +19,7 @@ import 'package:maibu_satabot_v2/core/consts/tcp_consts.dart';
|
||||
import 'package:maibu_satabot_v2/core/di/injection.dart';
|
||||
import 'package:maibu_satabot_v2/core/network/net_message_dispatcher.dart';
|
||||
import 'package:maibu_satabot_v2/core/network/protocol_decoder.dart';
|
||||
import 'package:maibu_satabot_v2/core/router/route_paths.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/data/models/device_add_path_point_model.dart' as work_area_model;
|
||||
import 'package:maibu_satabot_v2/features/devices/data/models/device_work_area_param_model.dart' as work_area_model;
|
||||
import 'package:maibu_satabot_v2/features/devices/data/repositories/generate_path_repository_Impl.dart';
|
||||
@@ -2175,6 +2177,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
});
|
||||
},
|
||||
onDjShow: (bool isOpen) {
|
||||
if (isOpen) context.go(RoutePaths.djMap);
|
||||
setState(() {
|
||||
isDjMapShow = isOpen;
|
||||
});
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:maibu_satabot_v2/core/router/route_paths.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/common/enum.dart';
|
||||
|
||||
class VerticalFloatMenu extends StatefulWidget {
|
||||
|
||||
Reference in New Issue
Block a user