From 9dcc6fbbb575b1d365208defe34290640d4be887 Mon Sep 17 00:00:00 2001
From: czw <selecti@yeah.net>
Date: 星期四, 03 七月 2025 17:16:42 +0800
Subject: [PATCH] 1

---
 2025年6月12日/AuxAllWCS/Build/Project/AuxAllWCS.csproj        |    1 +
 2025年6月12日/AuxAllWCS/Build/Project/界面/View1.xaml.cs        |   30 +++++++++++++++++++++++++-----
 2025年6月12日/AuxAllWCS/Build/Project/界面/View1.xaml           |    2 +-
 2025年6月12日/AuxAllWCS/Build/Project/代码/VS自定义类/AutoThread.cs |   11 ++++-------
 4 files changed, 31 insertions(+), 13 deletions(-)

diff --git "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/AuxAllWCS.csproj" "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/AuxAllWCS.csproj"
index e545d23..8480445 100644
--- "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/AuxAllWCS.csproj"
+++ "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/AuxAllWCS.csproj"
@@ -34,6 +34,7 @@
     <StartupObject />
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Microsoft.Web.WebView2.Core, Version=1.0.3351.48, Culture=neutral, PublicKeyToken=2a8ab48044d2601e" />
     <Reference Include="Microsoft.Web.WebView2.Wpf, Version=1.0.3351.48, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
       <HintPath>packages\Microsoft.Web.WebView2.1.0.3351.48\lib\net462\Microsoft.Web.WebView2.Wpf.dll</HintPath>
     </Reference>
diff --git "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs" "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs"
index 6cf597f..969ecf1 100644
--- "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs"
+++ "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs"
@@ -2027,24 +2027,23 @@
 
 
 
-
-
     }
+
 
     public class HttpServer
     {
         System.Net.HttpListener HttpSvcHost = null;
 
-        private readonly string _listenerPrefix = "";
+        public static string _listenerPrefix = "";
         public HttpServer(string ip)
         {
-            _listenerPrefix = ip;
+            _listenerPrefix = $"http://{ip}:8808/";
         }
         public void HttpServerRun()
         {
             HttpSvcHost = new System.Net.HttpListener();
             HttpSvcHost.AuthenticationSchemes = System.Net.AuthenticationSchemes.Anonymous;
-            HttpSvcHost.Prefixes.Add($"http://{_listenerPrefix}:8808/");
+            HttpSvcHost.Prefixes.Add(_listenerPrefix);
             HttpSvcHost.Start();
             HttpSvcHost.BeginGetContext(HttpSvcListenerCallback, null);
         }
@@ -2327,8 +2326,6 @@
         }
 
     }
-
-
 
     internal class WebSocketClient
     {
diff --git "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\347\225\214\351\235\242/View1.xaml" "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\347\225\214\351\235\242/View1.xaml"
index 21fe8c7..460b311 100644
--- "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\347\225\214\351\235\242/View1.xaml"
+++ "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\347\225\214\351\235\242/View1.xaml"
@@ -68,7 +68,7 @@
                             <TextBlock Text="WebView" Foreground="Purple" />
                         </StackPanel>
                     </TabItem.Header>
-                    <wv2:WebView2 x:Name="webView" Source="https://developer.microsoft.com/zh-cn/"/>
+                    <wv2:WebView2 x:Name="webView" />
                 </TabItem>
                 <!--<TabItem>
                     <TabItem.Header>
diff --git "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\347\225\214\351\235\242/View1.xaml.cs" "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\347\225\214\351\235\242/View1.xaml.cs"
index 0b220b8..3ce9c97 100644
--- "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\347\225\214\351\235\242/View1.xaml.cs"
+++ "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\347\225\214\351\235\242/View1.xaml.cs"
@@ -28,6 +28,8 @@
 using GZ.DB.Repository.OIDATABASE;
 using GZ.DB.IRepository.OIDATABASE;
 using GZ.DB.Entity.OIDATABASE;
+using Microsoft.Web.WebView2.Wpf;
+using System.Threading;
 
 namespace GZ.Projects.AuxAllWCS
 {
@@ -39,18 +41,36 @@
         public View1()
         {
             InitializeComponent();
-			#region 闄愬埗杩愯瀹炰緥鏁伴噺
+            #region 闄愬埗杩愯瀹炰緥鏁伴噺
             System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("AuxAllWCS");
             if (processes.Length > System.Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["InstanceLimit"]))
             {
                 System.Windows.MessageBox.Show("杩愯澶辫触:杩愯瀹炰緥鏁伴噺宸茶秴鍑洪檺鍒�);
                 this.Close();
             }
-			#endregion
-            this.DataContext = ViewModel.CreateInstance(this,typeof(View1));
+            #endregion
+            this.DataContext = ViewModel.CreateInstance(this, typeof(View1));
             this.Loaded += (this.DataContext as ViewModel).View1_LoadEvent;
-			this.Closing += (this.DataContext as ViewModel).View1_CloseEvent;
+            this.Closing += (this.DataContext as ViewModel).View1_CloseEvent;
+
+            commmd();
+        }
+
+        public async void commmd()
+        {
+            await webView.EnsureCoreWebView2Async();
+        labbb:
+            if (!string.IsNullOrEmpty(HttpServer._listenerPrefix))
+                if (webView.Source != new Uri(HttpServer._listenerPrefix))
+                {
+                    webView.CoreWebView2.Navigate(HttpServer._listenerPrefix + "/index.html");
+                    goto EndInit;
+                }
+            System.Threading.Thread.Sleep(2000);
+            goto labbb;
+        EndInit:
+            Console.WriteLine("end");
         }
     }
 }
-    
+

--
Gitblit v1.9.1