12 changed files with 139 additions and 6 deletions
@ -0,0 +1,13 @@ |
|||||
|
<UserControl x:Class="齐越慧眼.UserControls.InfoControl" |
||||
|
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:齐越慧眼.UserControls" |
||||
|
mc:Ignorable="d" |
||||
|
d:DesignHeight="450" d:DesignWidth="800"> |
||||
|
|
||||
|
<Grid x:Name="grid" DockPanel.Dock="Bottom"> |
||||
|
|
||||
|
</Grid> |
||||
|
</UserControl> |
@ -0,0 +1,86 @@ |
|||||
|
using CefSharp; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
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 齐越慧眼.cefhelper; |
||||
|
|
||||
|
namespace 齐越慧眼.UserControls |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// InfoControl.xaml 的交互逻辑
|
||||
|
/// </summary>
|
||||
|
public partial class InfoControl : UserControl |
||||
|
{ |
||||
|
ExtChromiumBrowser web; |
||||
|
public InfoControl() |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
web = new ExtChromiumBrowser("nacollector://home/info" ) |
||||
|
{ |
||||
|
BrowserSettings = |
||||
|
{ |
||||
|
DefaultEncoding = "UTF-8", |
||||
|
Plugins= CefState.Enabled, |
||||
|
//关于跨域限制
|
||||
|
//WebSecurity = CefState.Disabled
|
||||
|
|
||||
|
}, |
||||
|
}; |
||||
|
|
||||
|
web.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true; |
||||
|
|
||||
|
web.JavascriptObjectRepository.Register("hyCoreModel", new ItemsAsyncJS(), BindingOptions.DefaultBinder); |
||||
|
|
||||
|
grid.Children.Add(web); |
||||
|
// web.ExecuteScriptAsyncWhenPageLoaded(@$"localStorage.setItem('user', '{{""token"":""{ApiHelper.JwtToken}""}}');window.getDatas(0);");
|
||||
|
web.FrameLoadStart += Web_FrameLoadStart; |
||||
|
web.StartNewWindow += Web_StartNewWindow; |
||||
|
grid.KeyDown += grid_KeyDown; |
||||
|
} |
||||
|
|
||||
|
private void Web_StartNewWindow(object sender, NewWindowEventArgs e) |
||||
|
{ |
||||
|
// WpfNoticeMsg.NoticeMessage.Show(e.Url);
|
||||
|
BrowerHelper.OpenUrl(e.Url); |
||||
|
} |
||||
|
|
||||
|
bool isInit = false; |
||||
|
|
||||
|
private void grid_KeyDown(object sender, KeyEventArgs e) |
||||
|
{ |
||||
|
if (e.Key == Key.F12) |
||||
|
{ |
||||
|
web.ShowDevTools(); |
||||
|
} |
||||
|
} |
||||
|
private void Web_FrameLoadStart(object sender, FrameLoadStartEventArgs e) |
||||
|
{ |
||||
|
if (isInit) |
||||
|
return; |
||||
|
|
||||
|
Application.Current.Dispatcher.Invoke(() => |
||||
|
{ |
||||
|
web.WebBrowser.GetDevToolsClient().DOMStorage.SetDOMStorageItemAsync(new CefSharp.DevTools.DOMStorage.StorageId() |
||||
|
{ |
||||
|
SecurityOrigin = "nacollector://home", |
||||
|
IsLocalStorage = true |
||||
|
}, "user", |
||||
|
Newtonsoft.Json.JsonConvert.SerializeObject(new { token = ApiHelper.JwtToken }) |
||||
|
); |
||||
|
|
||||
|
web.ExecuteScriptAsyncWhenPageLoaded(@$"window.getInfoData();"); |
||||
|
}); |
||||
|
isInit = true; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@ |
|||||
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>client</title><link href="/css/app.030d4c2f.css" rel="preload" as="style"><link href="/css/app.css" rel="preload" as="style"><link href="/css/chunk-vendors.09af4a6b.css" rel="preload" as="style"><link href="/css/chunk-vendors.css" rel="preload" as="style"><link href="/js/app.js" rel="preload" as="script"><link href="/js/chunk-vendors.js" rel="preload" as="script"><link href="/css/chunk-vendors.09af4a6b.css" rel="stylesheet"><link href="/css/chunk-vendors.css" rel="stylesheet"><link href="/css/app.030d4c2f.css" rel="stylesheet"><link href="/css/app.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but client doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.js"></script><script src="/js/app.js"></script></body></html> |
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>client</title><link href="/css/app.css" rel="preload" as="style"><link href="/css/app.fe8cfd8e.css" rel="preload" as="style"><link href="/css/chunk-vendors.09af4a6b.css" rel="preload" as="style"><link href="/css/chunk-vendors.css" rel="preload" as="style"><link href="/js/app.js" rel="preload" as="script"><link href="/js/chunk-vendors.js" rel="preload" as="script"><link href="/css/chunk-vendors.09af4a6b.css" rel="stylesheet"><link href="/css/chunk-vendors.css" rel="stylesheet"><link href="/css/app.fe8cfd8e.css" rel="stylesheet"><link href="/css/app.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but client doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.js"></script><script src="/js/app.js"></script></body></html> |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue