问题描述
//WebViewHelper类usingCefSharp;usingCefSharp.Wpf;usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceYaMiClient{publicclassWebViewHelper{privatestaticChromiumWebBrowserwebBrowser;privatestaticobject_lock=newobject();privateWebViewHelper(){}publicstaticvoidSetInit(){if(Cef.IsInitialized)return;Cef.Initialize(newCefSettings(){PersistSessionCookies=true});}publicstaticvoidSetDispose(){Cef.Shutdown();}publicstaticChromiumWebBrowserGetWebBrowser(){if(webBrowser==null){lock(_lock){if(webBrowser==null){webBrowser=newChromiumWebBrowser();}}}returnwebBrowser;}publicstaticvoidSetAddress(stringaddress){if(webBrowser==null)GetWebBrowser();webBrowser.Address=address;}publicstaticvoidSetCookies(stringurl,stringdomain,Dictionary<string,string>cookies,DateTimedateTime){Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory,true);cookies.ToList().ForEach(c=>{Cookiecookie=newCookie();cookie.Creation=DateTime.Now;cookie.Domain="";cookie.Name=c.Key;cookie.Value=c.Value;cookie.Expires=dateTime;Task<bool>task=Cef.GetGlobalCookieManager().SetCookieAsync("http://123.57.7.202/yamiap",cookie);while(!task.IsCompleted){continue;}boolb=task.Result;});}}}
下面是加载的页面的代码usingSystem;usingSystem.Collections.Generic;usingSystem.Collections.ObjectModel;usingSystem.Linq;usingSystem.Text;usingSystem.Windows;usingSystem.Windows.Controls;usingSystem.Windows.Data;usingSystem.Windows.Documents;usingSystem.Windows.Input;usingSystem.Windows.Media;usingSystem.Windows.Media.Imaging;usingSystem.Windows.Navigation;usingSystem.Windows.Shapes;usingYaMiClient.Framework;usingYaMiClient.Models;namespaceYaMiClient.Views.WorkViews{[Screen(Name="WorkList")]///<summary>///WorkList.xaml的交互逻辑///</summary>publicpartialclassWorkList:ChildScreen{privateObservableCollection<NavigationModel>navigationSource;publicObservableCollection<NavigationModel>NavigationSource{get{if(navigationSource==null)navigationSource=newObservableCollection<NavigationModel>();returnnavigationSource;}set{SetProperty<ObservableCollection<NavigationModel>>(refnavigationSource,value,()=>this.NavigationSource);}}publicWorkList(){InitializeComponent();//保证窗体显示在上方。NavigationSource=newObservableCollection<NavigationModel>();NavigationSource.Add(newNavigationModel(){NavigationName="动态",Url="http://123.57.7.202/yamiapi/wechat/dynamic/alldongtai.jsp",NavigationImage="pack://application:,,,/Assets/WorkImage/Dynamic.png",IsWebBroswer=true});NavigationSource.Add(newNavigationModel(){NavigationName="日历",Url="http://123.57.7.202/yamiapi/wechat/calendar/calendarList.jsp",NavigationImage="pack://application:,,,/Assets/WorkImage/Calendar.png",IsWebBroswer=true});NavigationSource.Add(newNavigationModel(){NavigationName="任务",Url="http://123.57.7.202/yamiapi/wechat/task/myUnfinishedList.jsp",NavigationImage="pack://application:,,,/Assets/WorkImage/Task.png",IsWebBroswer=true});NavigationSource.Add(newNavigationModel(){NavigationName="通知",Url="http://123.57.7.202/yamiapi/wechat/notice/gu_dtzliebiao.jsp",NavigationImage="pack://application:,,,/Assets/WorkImage/Notice.png",IsWebBroswer=true});NavigationSource.Add(newNavigationModel(){NavigationName="群组",Url="http://123.57.7.202/yamiapi/wechat/group/aqzliebiao.jsp",NavigationImage="pack://application:,,,/Assets/WorkImage/Group.png",IsWebBroswer=true});NavigationSource.Add(newNavigationModel(){NavigationName="知识库",Url="http://123.57.7.202/yamiapi/wechat/repository/fileList.jsp",NavigationImage="pack://application:,,,/Assets/WorkImage/Knowledge.png",IsWebBroswer=true});NavigationSource.Add(newNavigationModel(){NavigationName="审批",Url="http://123.57.7.202/yamiapi/wechat/apply/fshenpi.jsp",NavigationImage="pack://application:,,,/Assets/WorkImage/Approval.png",IsWebBroswer=true});NavigationSource.Add(newNavigationModel(){NavigationName="工作报告",Url="http://123.57.7.202/yamiapi/wechat/workpaper/mySendList.jsp",NavigationImage="pack://application:,,,/Assets/WorkImage/WorkReport.png",IsWebBroswer=true});NavigationSource.Add(newNavigationModel(){NavigationName="资讯",Url="http://123.57.7.202/yamiapi/wechat/consultation/zixunall.jsp",NavigationImage="pack://application:,,,/Assets/WorkImage/Refer.png",IsWebBroswer=true});NavigationSource.Add(newNavigationModel(){NavigationName="打卡",Url="http://123.57.7.202/yamiapi/wechat/punchcard/byiji.jsp",NavigationImage="pack://application:,,,/Assets/WorkImage/PunchCard.png",IsWebBroswer=true});NavigationSource.Add(newNavigationModel(){NavigationName="聊天",Url="http://182.92.97.9/yamiweb/huanxin-webim2/index2.html#",NavigationImage="pack://application:,,,/Assets/WorkImage/PunchCard.png",IsWebBroswer=true});}publicoverridevoidOnActivity(){base.OnActivity();}privatevoidListBox_SelectionChanged(objectsender,SelectionChangedEventArgse){vartarget=senderasListBox;if(target==null)return;varitem=target.SelectedItemasNavigationModel;if(item==null)return;Dictionary<string,object>parameter=newDictionary<string,object>();parameter.Add("NavigationUri",item.Url);parameter.Add("Title",item.NavigationName);Activate("WorkDetail",parameter);}}}
主要就是用单例模式,实现web端已实现功能的直接嵌套,不知道为什么加了页面之后就一直闪烁
解决方案
解决方案二:
同问~~~有人知道么