diff --git a/BBWYB.Client/GlobalContext.cs b/BBWYB.Client/GlobalContext.cs index 2176586..c018495 100644 --- a/BBWYB.Client/GlobalContext.cs +++ b/BBWYB.Client/GlobalContext.cs @@ -20,7 +20,7 @@ namespace BBWYB.Client { public GlobalContext() { - BBWYBApiVersion = "10025"; + BBWYBApiVersion = "10026"; } private User user; diff --git a/BBWYB.Client/ViewModels/MainViewModel.cs b/BBWYB.Client/ViewModels/MainViewModel.cs index 0343adb..8e7c996 100644 --- a/BBWYB.Client/ViewModels/MainViewModel.cs +++ b/BBWYB.Client/ViewModels/MainViewModel.cs @@ -111,7 +111,7 @@ namespace BBWYB.Client.ViewModels ChildList = new List() { new MenuModel(){ Name="订单列表Bata",Url="/Views/WebB/WebB.xaml" }, - //new MenuModel(){ Name="团队配置",Url="/Views/Setting/TeamSetting.xaml" } + new MenuModel(){ Name="绩效考核",Url="/Views/WebB/WebB_KPI.xaml" } } }); MenuList.Add(new MenuModel() diff --git a/BBWYB.Client/Views/WebB/WebB.xaml.cs b/BBWYB.Client/Views/WebB/WebB.xaml.cs index 9c39e7f..b365133 100644 --- a/BBWYB.Client/Views/WebB/WebB.xaml.cs +++ b/BBWYB.Client/Views/WebB/WebB.xaml.cs @@ -1,10 +1,6 @@ -using BBWYB.Client.APIServices; -using CommunityToolkit.Mvvm.Messaging; +using CommunityToolkit.Mvvm.Messaging; using CommunityToolkit.Mvvm.Messaging.Messages; using Microsoft.Extensions.DependencyInjection; -using System.Collections.Generic; -using System.IO; -using System.Reflection; using System.Windows; using System.Windows.Controls; @@ -18,9 +14,6 @@ namespace BBWYB.Client.Views.WebB private WebView2Manager w2m; private bool isNavigated; - private IList managerDepartment; - private MdsApiService mdsApiService; - private ShopService shopService; private GlobalContext globalContext; public WebB() @@ -61,20 +54,20 @@ namespace BBWYB.Client.Views.WebB { w2m = s.ServiceProvider.GetRequiredService(); globalContext = s.ServiceProvider.GetRequiredService(); - mdsApiService = s.ServiceProvider.GetRequiredService(); - shopService = s.ServiceProvider.GetRequiredService(); } #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("webContext", this.globalContext); + w2m.wb2.CoreWebView2.AddHostObjectToScript(registerName, this.globalContext); isNavigated = true; w2m.wb2.CoreWebView2.Navigate(url); }; diff --git a/BBWYB.Client/Views/WebB/WebB_KPI.xaml b/BBWYB.Client/Views/WebB/WebB_KPI.xaml new file mode 100644 index 0000000..261dbfd --- /dev/null +++ b/BBWYB.Client/Views/WebB/WebB_KPI.xaml @@ -0,0 +1,14 @@ + + + + + + diff --git a/BBWYB.Client/Views/WebB/WebB_KPI.xaml.cs b/BBWYB.Client/Views/WebB/WebB_KPI.xaml.cs new file mode 100644 index 0000000..da0813d --- /dev/null +++ b/BBWYB.Client/Views/WebB/WebB_KPI.xaml.cs @@ -0,0 +1,87 @@ +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 +{ + /// + /// WebB_KPI.xaml 的交互逻辑 + /// + 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(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(); + globalContext = s.ServiceProvider.GetRequiredService(); + } + +#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 + { + public Message_WebBKPI_Refresh(object value) : base(value) + { + } + } +}