110,534
社区成员
发帖
与我相关
我的任务
分享
//WebViewHelper类
using CefSharp;
using CefSharp.Wpf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace YaMiClient
{
public class WebViewHelper
{
private static ChromiumWebBrowser webBrowser;
private static object _lock = new object();
private WebViewHelper()
{
}
public static void SetInit()
{
if (Cef.IsInitialized)
return;
Cef.Initialize(new CefSettings() { PersistSessionCookies = true});
}
public static void SetDispose()
{
Cef.Shutdown();
}
public static ChromiumWebBrowser GetWebBrowser()
{
if(webBrowser==null)
{
lock(_lock)
{
if(webBrowser==null)
{
webBrowser = new ChromiumWebBrowser();
}
}
}
return webBrowser;
}
public static void SetAddress(string address)
{
if (webBrowser == null)
GetWebBrowser();
webBrowser.Address = address;
}
public static void SetCookies(string url, string domain, Dictionary<string, string> cookies, DateTime dateTime)
{
Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true);
cookies.ToList().ForEach(c =>
{
Cookie cookie = new Cookie();
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;
}
bool b = task.Result;
});
}
}
}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
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.Navigation;
using System.Windows.Shapes;
using YaMiClient.Framework;
using YaMiClient.Models;
namespace YaMiClient.Views.WorkViews
{
[Screen(Name="WorkList")]
/// <summary>
/// WorkList.xaml 的交互逻辑
/// </summary>
public partial class WorkList : ChildScreen
{
private ObservableCollection<NavigationModel> navigationSource;
public ObservableCollection<NavigationModel> NavigationSource
{
get
{
if (navigationSource == null)
navigationSource = new ObservableCollection<NavigationModel>();
return navigationSource;
}
set
{
SetProperty<ObservableCollection<NavigationModel>>(ref navigationSource, value, () => this.NavigationSource);
}
}
public WorkList()
{
InitializeComponent();
//保证窗体显示在上方。
NavigationSource = new ObservableCollection<NavigationModel>();
NavigationSource.Add(new NavigationModel() { NavigationName = "动态", Url = "http://123.57.7.202/yamiapi/wechat/dynamic/alldongtai.jsp", NavigationImage = "pack://application:,,,/Assets/WorkImage/Dynamic.png", IsWebBroswer = true });
NavigationSource.Add(new NavigationModel() { NavigationName = "日历", Url = "http://123.57.7.202/yamiapi/wechat/calendar/calendarList.jsp", NavigationImage = "pack://application:,,,/Assets/WorkImage/Calendar.png", IsWebBroswer = true });
NavigationSource.Add(new NavigationModel() { NavigationName = "任务", Url = "http://123.57.7.202/yamiapi/wechat/task/myUnfinishedList.jsp", NavigationImage = "pack://application:,,,/Assets/WorkImage/Task.png", IsWebBroswer = true });
NavigationSource.Add(new NavigationModel() { NavigationName = "通知", Url = "http://123.57.7.202/yamiapi/wechat/notice/gu_dtzliebiao.jsp", NavigationImage = "pack://application:,,,/Assets/WorkImage/Notice.png" ,IsWebBroswer = true });
NavigationSource.Add(new NavigationModel() { NavigationName = "群组", Url = "http://123.57.7.202/yamiapi/wechat/group/aqzliebiao.jsp", NavigationImage = "pack://application:,,,/Assets/WorkImage/Group.png", IsWebBroswer = true });
NavigationSource.Add(new NavigationModel() { NavigationName = "知识库", Url = "http://123.57.7.202/yamiapi/wechat/repository/fileList.jsp", NavigationImage = "pack://application:,,,/Assets/WorkImage/Knowledge.png", IsWebBroswer = true });
NavigationSource.Add(new NavigationModel() { NavigationName = "审批", Url = "http://123.57.7.202/yamiapi/wechat/apply/fshenpi.jsp", NavigationImage = "pack://application:,,,/Assets/WorkImage/Approval.png",IsWebBroswer = true });
NavigationSource.Add(new NavigationModel() { NavigationName = "工作报告", Url = "http://123.57.7.202/yamiapi/wechat/workpaper/mySendList.jsp", NavigationImage = "pack://application:,,,/Assets/WorkImage/WorkReport.png", IsWebBroswer = true });
NavigationSource.Add(new NavigationModel() { NavigationName = "资讯", Url = "http://123.57.7.202/yamiapi/wechat/consultation/zixunall.jsp", NavigationImage = "pack://application:,,,/Assets/WorkImage/Refer.png", IsWebBroswer = true });
NavigationSource.Add(new NavigationModel() { NavigationName = "打卡", Url = "http://123.57.7.202/yamiapi/wechat/punchcard/byiji.jsp", NavigationImage = "pack://application:,,,/Assets/WorkImage/PunchCard.png", IsWebBroswer = true });
NavigationSource.Add(new NavigationModel() { NavigationName = "聊天", Url = "http://182.92.97.9/yamiweb/huanxin-webim2/index2.html#", NavigationImage = "pack://application:,,,/Assets/WorkImage/PunchCard.png", IsWebBroswer = true });
}
public override void OnActivity()
{
base.OnActivity();
}
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var target = sender as ListBox;
if (target == null)
return;
var item = target.SelectedItem as NavigationModel;
if (item == null)
return;
Dictionary<string,object> parameter=new Dictionary<string,object>();
parameter.Add("NavigationUri",item.Url);
parameter.Add("Title", item.NavigationName);
Activate("WorkDetail", parameter);
}
}
}