Browse Source

移除失效的web页面

yijia
shanji 2 years ago
parent
commit
f4b0e9952b
  1. 2
      BBWYB.Client/App.xaml.cs
  2. 13
      BBWYB.Client/BBWYB.Client.csproj
  3. 2
      BBWYB.Client/GlobalContext.cs
  4. 5
      BBWYB.Client/ViewModels/MainViewModel.cs
  5. 13
      BBWYB.Client/Views/PackPurchaseTask/UpdatePurchaseTaskWindow.xaml.cs
  6. 2
      BBWYB.Client/Views/Web.xaml.cs
  7. 14
      BBWYB.Client/Views/WebB/WebB.xaml
  8. 105
      BBWYB.Client/Views/WebB/WebB.xaml.cs
  9. 14
      BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml
  10. 104
      BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml.cs
  11. 14
      BBWYB.Client/Views/WebB/WebB_KPI.xaml
  12. 87
      BBWYB.Client/Views/WebB/WebB_KPI.xaml.cs
  13. 2
      WebTest/App.xaml.cs
  14. 16
      WebTest/MainWindow.xaml.cs
  15. 6
      WebTest/WebView2Manager.cs

2
BBWYB.Client/App.xaml.cs

@ -32,7 +32,7 @@ namespace BBWYB.Client
#if DEBUG
//齐越山鸡
userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNTM1MzMwMzI4ODkyMTQ5NzYwIiwidGVhbUlkIjoiMTUxNjk3NDI1MDU0MjUwMTg4OCIsInNvblRlYW1JZHMiOiIxNDM2Mjg4NTAwMjM1MjQzNTIwIiwiZXhwIjoxNjk0NjY5NjkxfQ.cSwro-7bGwOu92YejH9JhMenTai7Mvf99i2paQCmxIw";
userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNTM1MzMwMzI4ODkyMTQ5NzYwIiwidGVhbUlkIjoiMTUxNjk3NDI1MDU0MjUwMTg4OCIsInNvblRlYW1JZHMiOiIxNDM2Mjg4NTAwMjM1MjQzNTIwIiwiZXhwIjoxNzI2MzAwNjY0fQ.hPSbgJEuTt0MLy_7YkSJX4rRG3drJAfso-5IS8ZlOkY";
//拳探店铺 陈默
//userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNjI0OTUxNjgzNTc2NTAwMjI0IiwidGVhbUlkIjoiMTYyMDM0MjAxNDcwNjk3ODgxNiIsInNvblRlYW1JZHMiOiIxNjIwMzQyMDE0NzA2OTc4ODE2LDE2MjAzNDM4Mjc0NzI1ODQ3MDQsMTYyMDM0NDAzMzczNTg3MjUxMiwxNjIwMzQ0MDkyODI5NDIxNTY4LDE2MjAzNDQxNDA4NTAwMDgwNjQiLCJleHAiOjE3MjA3NjQzMjV9.Q8fiKXCHgvzbm7NDEre-MeoSju_AmC6Ae6eDY22rUAw";

13
BBWYB.Client/BBWYB.Client.csproj

@ -53,17 +53,4 @@
<Resource Include="Resources\Images\defaultItem.png" />
</ItemGroup>
<ItemGroup>
<Compile Update="Views\WebB\WebB_GoodsSource.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Page Update="Views\WebB\WebB_GoodsSource.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
</Project>

2
BBWYB.Client/GlobalContext.cs

@ -2,7 +2,6 @@
using BBWYB.Client.Helpers;
using BBWYB.Client.Models;
using BBWYB.Client.Views.PackPurchaseTaska;
using BBWYB.Client.Views.WebB;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.Extensions.DependencyInjection;
@ -119,7 +118,6 @@ namespace BBWYB.Client
UpdatePurchaseTaskWindow packTask = new(res.Data, originShopName, orderSku);
if (!packTask.IsClosed)
packTask.Show();
WeakReferenceMessenger.Default.Send(new Message_WebB_RefreshPack(null));
//
}
#endregion

5
BBWYB.Client/ViewModels/MainViewModel.cs

@ -1,7 +1,6 @@
using BBWYB.Client.APIServices;
using BBWYB.Client.Models;
using BBWYB.Client.Views.SelectShop;
using BBWYB.Client.Views.WebB;
using BBWYB.Common.Extensions;
using BBWYB.Common.Models;
using CommunityToolkit.Mvvm.Input;
@ -233,10 +232,6 @@ namespace BBWYB.Client.ViewModels
vm.OrderVM.Refresh();
if (vm.IsCreateWareManager)
vm.WareManager.Refresh();
if (SelectedMenuModel?.Name == "订单列表Bata")
{
WeakReferenceMessenger.Default.Send(new Message_WebB_Refresh(null));
}
}
}
catch (Exception ex)

13
BBWYB.Client/Views/PackPurchaseTask/UpdatePurchaseTaskWindow.xaml.cs

@ -1,24 +1,11 @@
using BBWYB.Client.Models;
using BBWYB.Client.Models.APIModel.Response.PackPurchaseTask;
using BBWYB.Client.ViewModels;
using BBWYB.Client.Views.Ware;
using BBWYB.Client.Views.WebB;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.Mvvm.Messaging.Messages;
using SJ.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace BBWYB.Client.Views.PackPurchaseTaska
{

2
BBWYB.Client/Views/Web.xaml.cs

@ -43,6 +43,8 @@ namespace BBWYB.Client.Views
private void initWebView()
{
#if DEBUG
//var url = "http://qtbbwy.qiyue666.com";
//var registerName = "webContext";
var url = "http://192.168.1.2:8080";
var registerName = "webTestContext";
//var url = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "s.html");

14
BBWYB.Client/Views/WebB/WebB.xaml

@ -1,14 +0,0 @@
<Page x:Class="BBWYB.Client.Views.WebB.WebB"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BBWYB.Client.Views.WebB"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="WebB">
<Grid x:Name="grid">
</Grid>
</Page>

105
BBWYB.Client/Views/WebB/WebB.xaml.cs

@ -1,105 +0,0 @@
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.Mvvm.Messaging.Messages;
using Microsoft.Extensions.DependencyInjection;
using System.Windows;
using System.Windows.Controls;
namespace BBWYB.Client.Views.WebB
{
/// <summary>
/// WebB.xaml 的交互逻辑
/// </summary>
public partial class WebB : Page
{
private WebView2Manager w2m;
private bool isNavigated;
private GlobalContext globalContext;
public WebB()
{
InitializeComponent();
this.Loaded += WebB_Loaded;
this.Unloaded += WebB_Unloaded;
WeakReferenceMessenger.Default.Register<Message_WebB_Refresh>(this, (o, x) =>
{
this.Dispatcher.Invoke(() =>
{
_ = w2m.wb2.ExecuteScriptAsync("window.location.reload();");
});
});
WeakReferenceMessenger.Default.Register<Message_WebB_RefreshPack>(this, (o, x) =>
{
this.Dispatcher.Invoke(() =>
{
_ = w2m.wb2.ExecuteScriptAsync("window.BBWY_B_WebContex('PACK_CONFIG_SUCCESS');");
});
});
}
private void WebB_Unloaded(object sender, RoutedEventArgs e)
{
grid.Children.Remove(w2m.wb2);
//w2m.wb2.Dispose();
w2m.Close();
WeakReferenceMessenger.Default.UnregisterAll(this);
}
private void WebB_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
var sp = (App.Current as App).ServiceProvider;
using (var s = sp.CreateScope())
{
w2m = s.ServiceProvider.GetRequiredService<WebView2Manager>();
globalContext = s.ServiceProvider.GetRequiredService<GlobalContext>();
}
#if DEBUG
var url = "http://192.168.1.8:8080";
var registerName = "webTestContext";
//var url = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "s.html");
#else
var url = "http://qtbbwy.qiyue666.com";
var registerName = "webContext";
#endif
//var url = "http://qtbbwy.qiyue666.com";
w2m.CoreWebView2InitializationCompleted = (e) =>
{
w2m.wb2.CoreWebView2.AddHostObjectToScript(registerName, this.globalContext);
isNavigated = true;
w2m.wb2.CoreWebView2.Navigate(url);
};
w2m.Init("bbwyb_web");
w2m.wb2.SetValue(Grid.RowProperty, 1);
w2m.wb2.Margin = new Thickness(1, 0, 1, 0);
//grid.Children.Clear();
grid.Children.Add(w2m.wb2);
if (w2m.IsInitializationCompleted && !isNavigated)
{
w2m.wb2.CoreWebView2.Navigate(url);
//w2m.wb2.CoreWebView2.NavigateToString(content);
isNavigated = true;
}
}
}
public class Message_WebB_Refresh : ValueChangedMessage<object>
{
public Message_WebB_Refresh(object value) : base(value)
{
}
}
public class Message_WebB_RefreshPack : ValueChangedMessage<object>
{
public Message_WebB_RefreshPack(object value) : base(value)
{
}
}
}

14
BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml

@ -1,14 +0,0 @@
<Page x:Class="BBWYB.Client.Views.WebB.WebB_GoodsSource"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BBWYB.Client.Views.WebB"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="WebB">
<Grid x:Name="grid">
</Grid>
</Page>

104
BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml.cs

@ -1,104 +0,0 @@
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.Mvvm.Messaging.Messages;
using Microsoft.Extensions.DependencyInjection;
using System.Windows;
using System.Windows.Controls;
namespace BBWYB.Client.Views.WebB
{
/// <summary>
/// WebB.xaml 的交互逻辑
/// </summary>
public partial class WebB_GoodsSource : Page
{
private WebView2Manager w2m;
private bool isNavigated;
private GlobalContext globalContext;
public WebB_GoodsSource()
{
InitializeComponent();
this.Loaded += WebB_Loaded;
this.Unloaded += WebB_Unloaded;
//WeakReferenceMessenger.Default.Register<Message_WebB_Refresh>(this, (o, x) =>
//{
// this.Dispatcher.Invoke(() =>
// {
// _ = w2m.wb2.ExecuteScriptAsync("window.location.reload();");
// });
//});
//WeakReferenceMessenger.Default.Register<Message_WebB_RefreshPack>(this, (o, x) =>
//{
// this.Dispatcher.Invoke(() =>
// {
// _ = w2m.wb2.ExecuteScriptAsync("window.BBWY_B_WebContex('PACK_CONFIG_SUCCESS');");
// });
//});
}
private void WebB_Unloaded(object sender, RoutedEventArgs e)
{
grid.Children.Remove(w2m.wb2);
//w2m.wb2.Dispose();
w2m.Close();
WeakReferenceMessenger.Default.UnregisterAll(this);
}
private void WebB_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
var sp = (App.Current as App).ServiceProvider;
using (var s = sp.CreateScope())
{
w2m = s.ServiceProvider.GetRequiredService<WebView2Manager>();
globalContext = s.ServiceProvider.GetRequiredService<GlobalContext>();
}
#if DEBUG
var url = "http://192.168.1.2:8080/#/goods-source";
var registerName = "webTestContext";
//var url = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "s.html");
#else
var url = "http://qtbbwy.qiyue666.com/#/goods-source";
var registerName = "webContext";
#endif
w2m.CoreWebView2InitializationCompleted = (e) =>
{
w2m.wb2.CoreWebView2.AddHostObjectToScript(registerName, this.globalContext);
isNavigated = true;
w2m.wb2.CoreWebView2.Navigate(url);
};
w2m.Init("bbwyb_web");
w2m.wb2.SetValue(Grid.RowProperty, 1);
w2m.wb2.Margin = new Thickness(1, 0, 1, 0);
//grid.Children.Clear();
grid.Children.Add(w2m.wb2);
if (w2m.IsInitializationCompleted && !isNavigated)
{
w2m.wb2.CoreWebView2.Navigate(url);
//w2m.wb2.CoreWebView2.NavigateToString(content);
isNavigated = true;
}
}
}
//public class Message_WebB_GoodsSource_Refresh : ValueChangedMessage<object>
//{
// public Message_WebB_GoodsSource_Refresh(object value) : base(value)
// {
// }
//}
//public class Message_WebB_GoodsSource_RefreshPack : ValueChangedMessage<object>
//{
// public Message_WebB_GoodsSource_RefreshPack(object value) : base(value)
// {
// }
//}
}

14
BBWYB.Client/Views/WebB/WebB_KPI.xaml

@ -1,14 +0,0 @@
<Page x:Class="BBWYB.Client.Views.WebB.WebB_KPI"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BBWYB.Client.Views.WebB"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="WebB_KPI">
<Grid x:Name="grid">
</Grid>
</Page>

87
BBWYB.Client/Views/WebB/WebB_KPI.xaml.cs

@ -1,87 +0,0 @@
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.Mvvm.Messaging.Messages;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Windows;
using System.Windows.Controls;
namespace BBWYB.Client.Views.WebB
{
/// <summary>
/// WebB_KPI.xaml 的交互逻辑
/// </summary>
public partial class WebB_KPI : Page
{
private WebView2Manager w2m;
private bool isNavigated;
private GlobalContext globalContext;
public WebB_KPI()
{
InitializeComponent();
this.Loaded += WebB_KPI_Loaded; ;
this.Unloaded += WebB_KPI_Unloaded;
WeakReferenceMessenger.Default.Register<Message_WebBKPI_Refresh>(this, (o, x) =>
{
this.Dispatcher.Invoke(() =>
{
_ = w2m.wb2.ExecuteScriptAsync("window.location.reload();");
});
});
}
private void WebB_KPI_Unloaded(object sender, RoutedEventArgs e)
{
grid.Children.Remove(w2m.wb2);
w2m.Close();
WeakReferenceMessenger.Default.UnregisterAll(this);
}
private void WebB_KPI_Loaded(object sender, RoutedEventArgs e)
{
var sp = (App.Current as App).ServiceProvider;
using (var s = sp.CreateScope())
{
w2m = s.ServiceProvider.GetRequiredService<WebView2Manager>();
globalContext = s.ServiceProvider.GetRequiredService<GlobalContext>();
}
#if DEBUG
var url = "http://localhost:8080/#/performance";
var registerName = "webTestContext";
#else
var url = "http://qtbbwy.qiyue666.com/#/performance";
var registerName = "webContext";
#endif
w2m.CoreWebView2InitializationCompleted = (e) =>
{
w2m.wb2.CoreWebView2.AddHostObjectToScript(registerName, this.globalContext);
isNavigated = true;
w2m.wb2.CoreWebView2.Navigate(url);
};
w2m.Init("bbwyb_web");
w2m.wb2.SetValue(Grid.RowProperty, 1);
w2m.wb2.Margin = new Thickness(1, 0, 1, 0);
//grid.Children.Clear();
grid.Children.Add(w2m.wb2);
if (w2m.IsInitializationCompleted && !isNavigated)
{
w2m.wb2.CoreWebView2.Navigate(url);
//w2m.wb2.CoreWebView2.NavigateToString(content);
isNavigated = true;
}
}
}
public class Message_WebBKPI_Refresh : ValueChangedMessage<object>
{
public Message_WebBKPI_Refresh(object value) : base(value)
{
}
}
}

2
WebTest/App.xaml.cs

@ -25,7 +25,7 @@ namespace WebTest
string userToken = string.Empty;
//齐越山鸡
userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNTM1MzMwMzI4ODkyMTQ5NzYwIiwidGVhbUlkIjoiMTUxNjk3NDI1MDU0MjUwMTg4OCIsInNvblRlYW1JZHMiOiIxNDM2Mjg4NTAwMjM1MjQzNTIwIiwiZXhwIjoxNjk0NjY5NjkxfQ.cSwro-7bGwOu92YejH9JhMenTai7Mvf99i2paQCmxIw";
userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNTM1MzMwMzI4ODkyMTQ5NzYwIiwidGVhbUlkIjoiMTUxNjk3NDI1MDU0MjUwMTg4OCIsInNvblRlYW1JZHMiOiIxNDM2Mjg4NTAwMjM1MjQzNTIwIiwiZXhwIjoxNzI2MzAwNjY0fQ.hPSbgJEuTt0MLy_7YkSJX4rRG3drJAfso-5IS8ZlOkY";
gl.UserToken = userToken;

16
WebTest/MainWindow.xaml.cs

@ -27,7 +27,7 @@ namespace WebTest
private ShopService shopService;
#if DEBUG
private string registerName = "webTestContext";
private string registerName = "webTestContext";
#else
private string registerName = "webContext";
#endif
@ -87,7 +87,7 @@ private string registerName = "webContext";
shopService = s.ServiceProvider.GetRequiredService<ShopService>();
}
Login();
//Login();
w2m.CoreWebView2InitializationCompleted = (e) =>
{
w2m.wb2.CoreWebView2.PermissionRequested += (sender, args) =>
@ -103,7 +103,7 @@ private string registerName = "webContext";
w2m.wb2.Margin = new Thickness(1, 0, 1, 0);
grid.Children.Add(w2m.wb2);
//if (w2m.IsInitializationCompleted && !isNavigated)
//{
// w2m.wb2.CoreWebView2.Navigate(url);
@ -183,11 +183,11 @@ private string registerName = "webContext";
MessageBox.Show("地址不能为空", "提示");
return;
}
if (!txtUrl.Text.StartsWith("http"))
{
MessageBox.Show("地址需要携带协议头", "提示");
return;
}
//if (!txtUrl.Text.StartsWith("http"))
//{
// MessageBox.Show("地址需要携带协议头", "提示");
// return;
//}
w2m.wb2.CoreWebView2.Navigate(txtUrl.Text);
}
}

6
WebTest/WebView2Manager.cs

@ -26,6 +26,11 @@ namespace WebTest
}
}
private void CoreWebView2_WebResourceRequested(object? sender, CoreWebView2WebResourceRequestedEventArgs e)
{
Console.WriteLine($"{DateTime.Now} WebSroucesRequest {e.Request.Uri}");
}
public Action<CoreWebView2WebMessageReceivedEventArgs> OnWebMessageReceived;
public Action<CoreWebView2NavigationCompletedEventArgs> OnNavigationCompleted;
public Action<CoreWebView2InitializationCompletedEventArgs> CoreWebView2InitializationCompleted;
@ -43,6 +48,7 @@ namespace WebTest
private void Wb2_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
{
wb2.CoreWebView2.WebResourceRequested += CoreWebView2_WebResourceRequested;
CoreWebView2InitializationCompleted?.Invoke(e);
IsInitializationCompleted = true;
}

Loading…
Cancel
Save