| 
									
										
										
										
											2024-04-05 18:09:40 +08:00
										 |  |  | import 'package:bitsdojo_window/bitsdojo_window.dart'; | 
					
						
							| 
									
										
										
										
											2024-03-30 20:14:00 +08:00
										 |  |  | import 'package:flutter/material.dart'; | 
					
						
							| 
									
										
										
										
											2024-04-03 14:36:36 +08:00
										 |  |  | import 'package:web_synchronization_tool/windows/socket_tool.dart'; | 
					
						
							| 
									
										
										
										
											2024-04-02 20:29:52 +08:00
										 |  |  | import 'package:web_synchronization_tool/windows/web_grid_view.dart'; | 
					
						
							| 
									
										
										
										
											2024-03-30 20:14:00 +08:00
										 |  |  | import 'package:webview_windows/webview_windows.dart'; | 
					
						
							| 
									
										
										
										
											2024-04-05 18:09:40 +08:00
										 |  |  | import 'package:window_manager/window_manager.dart'; | 
					
						
							| 
									
										
										
										
											2024-03-30 20:14:00 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | class WindowsPage extends StatefulWidget { | 
					
						
							|  |  |  |   const WindowsPage({super.key}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   State<WindowsPage> createState() => _WindowsPageState(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class _WindowsPageState extends State<WindowsPage> { | 
					
						
							| 
									
										
										
										
											2024-04-02 20:29:52 +08:00
										 |  |  |   Widget? windowsWebWidget; | 
					
						
							|  |  |  |   WebviewController mainController = WebviewController(); | 
					
						
							|  |  |  |   final gridController = WebGridController(); | 
					
						
							| 
									
										
										
										
											2024-03-30 20:14:00 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   bool initDone = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-02 20:29:52 +08:00
										 |  |  |   String clickId = ''; | 
					
						
							|  |  |  |   String zoomId = ''; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-30 20:14:00 +08:00
										 |  |  |   @override | 
					
						
							|  |  |  |   void initState() { | 
					
						
							|  |  |  |     super.initState(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-05 18:09:40 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     initWindow(); | 
					
						
							| 
									
										
										
										
											2024-03-30 20:14:00 +08:00
										 |  |  |     controllerInit(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-05 18:09:40 +08:00
										 |  |  |   initWindow(){ | 
					
						
							|  |  |  |     //允许调整窗口大小
 | 
					
						
							|  |  |  |     windowManager.setResizable(false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const double width = 1920; | 
					
						
							|  |  |  |     const double height = 1000; | 
					
						
							|  |  |  |     //设置最小大小
 | 
					
						
							|  |  |  |     const windowSize = Size(width, height); | 
					
						
							|  |  |  |     windowManager.setSize(windowSize); | 
					
						
							|  |  |  |     appWindow.minSize = windowSize; | 
					
						
							|  |  |  |     windowManager.center(); | 
					
						
							|  |  |  |     windowManager.focus(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-30 20:14:00 +08:00
										 |  |  |   Future controllerInit() async { | 
					
						
							|  |  |  |     await mainController.initialize(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     mainController.loadUrl('http://www.df6831.com/'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-02 20:29:52 +08:00
										 |  |  |     gridController.addWebController(mainController); | 
					
						
							| 
									
										
										
										
											2024-03-30 20:14:00 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     setState(() { | 
					
						
							|  |  |  |       initDone = true; | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2024-04-01 21:41:42 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2024-03-30 20:14:00 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							| 
									
										
										
										
											2024-04-03 10:37:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-30 20:14:00 +08:00
										 |  |  |     if (initDone == false) return Container(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return Scaffold( | 
					
						
							| 
									
										
										
										
											2024-04-03 12:54:07 +08:00
										 |  |  |       body: WebGridWidget( | 
					
						
							|  |  |  |         controller: gridController, | 
					
						
							| 
									
										
										
										
											2024-03-30 20:14:00 +08:00
										 |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |