From 0bc6706730093f87b3ad169819145ed7d3d712d5 Mon Sep 17 00:00:00 2001 From: shanji <18996038927@163.com> Date: Fri, 19 May 2023 13:34:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5webview2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BBWYB.Client/GlobalContext.cs | 4 ++++ BBWYB.Client/Models/User/User.cs | 4 +++- BBWYB.Client/ViewModels/MainViewModel.cs | 2 ++ BBWYB.Client/Views/WebB/WebB.xaml.cs | 2 -- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/BBWYB.Client/GlobalContext.cs b/BBWYB.Client/GlobalContext.cs index 28063f9..becd36d 100644 --- a/BBWYB.Client/GlobalContext.cs +++ b/BBWYB.Client/GlobalContext.cs @@ -2,9 +2,13 @@ using CommunityToolkit.Mvvm.ComponentModel; using Newtonsoft.Json; using System.Collections.Generic; +using System.Runtime.InteropServices; namespace BBWYB.Client { + + [ClassInterface(ClassInterfaceType.AutoDual)] + [ComVisible(true)] public class GlobalContext : ObservableObject { public GlobalContext() diff --git a/BBWYB.Client/Models/User/User.cs b/BBWYB.Client/Models/User/User.cs index edbe32d..94a623e 100644 --- a/BBWYB.Client/Models/User/User.cs +++ b/BBWYB.Client/Models/User/User.cs @@ -24,9 +24,11 @@ namespace BBWYB.Client.Models public IList DepartmentList { get; set; } /// - /// 店铺列表 (暂时只有刷单组才需要) + /// 店铺列表 /// public IList ShopList { get; set; } + public string Token { get; set; } + } } diff --git a/BBWYB.Client/ViewModels/MainViewModel.cs b/BBWYB.Client/ViewModels/MainViewModel.cs index 6555f5b..0f0ed53 100644 --- a/BBWYB.Client/ViewModels/MainViewModel.cs +++ b/BBWYB.Client/ViewModels/MainViewModel.cs @@ -4,6 +4,7 @@ using BBWYB.Client.Views.SelectShop; using BBWYB.Common.Extensions; using BBWYB.Common.Models; using CommunityToolkit.Mvvm.Input; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -139,6 +140,7 @@ namespace BBWYB.Client.ViewModels throw new Exception($"获取磨刀石用户信息失败 {mdsUserResponse.Msg}"); GlobalContext.User = mdsUserResponse.Data.Map(); + GlobalContext.User.Token = GlobalContext.UserToken; GlobalContext.User.SonDepartmentNames = string.Empty; if (mdsUserResponse.Data.SonDepartmentList != null && mdsUserResponse.Data.SonDepartmentList.Count > 0) GlobalContext.User.SonDepartmentNames = string.Join(',', mdsUserResponse.Data.SonDepartmentList.Select(sd => sd.DepartmentName)); diff --git a/BBWYB.Client/Views/WebB/WebB.xaml.cs b/BBWYB.Client/Views/WebB/WebB.xaml.cs index 1873c33..a4ae4c4 100644 --- a/BBWYB.Client/Views/WebB/WebB.xaml.cs +++ b/BBWYB.Client/Views/WebB/WebB.xaml.cs @@ -50,8 +50,6 @@ namespace BBWYB.Client.Views.WebB w2m.wb2.Margin = new Thickness(1, 0, 1, 0); grid.Children.Add(w2m.wb2); - - if (w2m.IsInitializationCompleted && !isNavigated) { w2m.wb2.CoreWebView2.Navigate(url);