Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lindexi_gd
Uno
提交
65a7cf3c
U
Uno
项目概览
lindexi_gd
/
Uno
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
Uno
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
65a7cf3c
编写于
3月 24, 2023
作者:
M
Martin Zikmund
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: Adjusting iOS/macOS buildability
上级
27973ca4
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
95 addition
and
133 deletion
+95
-133
src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/WebView2Tests/WebView2SampleBehavior.cs
..._UI_Xaml_Controls/WebView2Tests/WebView2SampleBehavior.cs
+1
-1
src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/WebView2Tests/WebView2_AnchorNavigation.xaml.cs
..._Controls/WebView2Tests/WebView2_AnchorNavigation.xaml.cs
+4
-3
src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/WebView2Tests/WebView2_JavascriptInvoke.xaml.cs
..._Controls/WebView2Tests/WebView2_JavascriptInvoke.xaml.cs
+26
-24
src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/WebView2Tests/WebView2_WithHeaders.xaml.cs
..._Xaml_Controls/WebView2Tests/WebView2_WithHeaders.xaml.cs
+1
-1
src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2.legacy.cs
...o.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2.legacy.cs
+0
-67
src/Uno.UI/UI/Xaml/Controls/WebView/Native/Android/NativeWebViewWrapper.Android.cs
...ls/WebView/Native/Android/NativeWebViewWrapper.Android.cs
+0
-0
src/Uno.UI/UI/Xaml/Controls/WebView/Native/INativeWebView.cs
src/Uno.UI/UI/Xaml/Controls/WebView/Native/INativeWebView.cs
+1
-1
src/Uno.UI/UI/Xaml/Controls/WebView/Native/iOSmacOS/UnoWKWebView.iOSmacOS.cs
...Controls/WebView/Native/iOSmacOS/UnoWKWebView.iOSmacOS.cs
+27
-20
src/Uno.UI/UI/Xaml/Controls/WebView/Native/iOSmacOS/WebViewNavigationDelegate.iOSmacOS.cs
...iew/Native/iOSmacOS/WebViewNavigationDelegate.iOSmacOS.cs
+35
-16
未找到文件。
src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/WebView2Tests/WebView2SampleBehavior.cs
浏览文件 @
65a7cf3c
...
...
@@ -25,7 +25,7 @@ namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
var
uriString
=
e
.
NewValue
?.
ToString
();
if
(!
string
.
IsNullOrEmpty
(
uriString
))
{
(
d
as
WebView2Uno
).
Navigate
(
new
Uri
(
uriString
,
UriKind
.
Absolute
)
);
(
(
WebView2Uno
)
d
).
Source
=
new
Uri
(
uriString
,
UriKind
.
Absolute
);
}
}
}
...
...
src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/WebView2Tests/WebView2_AnchorNavigation.xaml.cs
浏览文件 @
65a7cf3c
...
...
@@ -12,9 +12,10 @@ namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
InitializeComponent
();
#if HAS_UNO
webView
.
Navigate
(
new
Uri
(
"https://nv-assets.azurewebsites.net/tests/docs/WebView2_NavigateToAnchor.html"
));
webView
.
NavigationStarting
+=
WebView2_NavigationStarting
;
webView
.
NavigationCompleted
+=
WebView2_NavigationCompleted
;
//TODO:MZ:
//webView.Navigate(new Uri("https://nv-assets.azurewebsites.net/tests/docs/WebView2_NavigateToAnchor.html"));
//webView.NavigationStarting += WebView2_NavigationStarting;
//webView.NavigationCompleted += WebView2_NavigationCompleted;
#endif
}
...
...
src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/WebView2Tests/WebView2_JavascriptInvoke.xaml.cs
浏览文件 @
65a7cf3c
using
Uno.UI.Samples.Controls
;
using
System
;
using
Windows.UI.Xaml
;
using
Windows.UI.Core
;
using
System
;
using
System.Threading
;
using
Windows.UI.Xaml.Controls
;
using
System.Threading.Tasks
;
using
SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
;
using
Uno.UI.Samples.Controls
;
using
Windows.UI.Core
;
using
Windows.UI.Xaml
;
using
Windows.UI.Xaml.Controls
;
namespace
SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
{
...
...
@@ -16,28 +16,30 @@ namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
public
WebView2_JavascriptInvoke
()
{
this
.
InitializeComponent
();
MyButton
.
Click
+=
MyButton_OnClick
;
}
//TODO:MZ:
// MyButton.Click += MyButton_OnClick;
//}
private
void
MyButton_OnClick
(
object
sender
,
RoutedEventArgs
e
)
{
var
t
=
Dispatcher
.
RunAsync
(
CoreDispatcherPriority
.
Normal
,
async
()
=>
await
InvokeScriptAsync
(
MyWebView2
,
CancellationToken
.
None
,
GetReloadJavascript
(),
new
string
[]
{
""
})
);
}
public
static
async
Task
<
string
>
InvokeScriptAsync
(
Microsoft
.
UI
.
Xaml
.
Controls
.
WebView2
webView
,
CancellationToken
ct
,
string
script
,
string
[]
arguments
)
{
return
await
webView
.
InvokeScriptAsync
(
script
,
arguments
).
AsTask
(
ct
);
//private void MyButton_OnClick(object sender, RoutedEventArgs e)
//{
// var t = Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
// async () => await InvokeScriptAsync(MyWebView2, CancellationToken.None, GetReloadJavascript(), new string[] { "" })
// );
//}
//public static async Task<string> InvokeScriptAsync(Microsoft.UI.Xaml.Controls.WebView2 webView, CancellationToken ct, string script, string[] arguments)
//{
//
// //return await webView.CoreWebView2.ExecuteScriptAsync(script, arguments).AsTask(ct);
}
private
static
string
GetReloadJavascript
()
{
#if XAMARIN_IOS
return
"location.reload(true);"
;
#else
return
"window.location.reload()"
;
#endif
}
//
private static string GetReloadJavascript()
//
{
//
#if XAMARIN_IOS
//
return "location.reload(true);";
//
#else
//
return "window.location.reload()";
//
#endif
//
}
#endif
}
}
src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/WebView2Tests/WebView2_WithHeaders.xaml.cs
浏览文件 @
65a7cf3c
...
...
@@ -28,7 +28,7 @@ namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
};
request
.
Headers
.
Add
(
"HELLO"
,
"TESTTEST, TEST2"
);
request
.
Headers
.
Add
(
"HELLO2"
,
"TEST111"
);
MyWebView2
.
NavigateWithHttpRequestMessage
(
request
);
MyWebView2
.
CoreWebView2
.
NavigateWithHttpRequestMessage
(
request
);
}
#endif
}
...
...
src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2.legacy.cs
已删除
100644 → 0
浏览文件 @
27973ca4
//#if __WASM__ || __MACOS__
//#pragma warning disable CS0067, CS0414
//#endif
//#if XAMARIN || __WASM__ || __SKIA__
//using Windows.Foundation;
//using Windows.UI.Xaml.Controls;
//using System;
//using System.Collections.Generic;
//using System.Diagnostics.CodeAnalysis;
//using System.Linq;
//using System.Net.Http;
//using System.Text;
//using System.Threading;
//using System.Threading.Tasks;
//using Uno.Extensions;
//using Uno;
//namespace Windows.UI.Xaml.Controls
//{
//#if __WASM__ || __SKIA__
// [NotImplemented]
//#endif
// internal partial class WebView : Control
// {
// private object _internalSource;
// private string _invokeScriptResponse = string.Empty;
// internal void Navigate(Uri uri)
// {
// _owner.SetInternalSource(uri ?? BlankUri);
// }
// //
// // Summary:
// // Loads the specified HTML content as a new document.
// //
// // Parameters:
// // text:
// // The HTML content to display in t he WebView control.
// internal void NavigateToString(string text)
// {
// _owner.SetInternalSource(text ?? "");
// }
// private void SetInternalSource(object source)
// {
// _internalSource = source;
// _owner.UpdateFromInternalSource();
// }
// internal void OnUnsupportedUriSchemeIdentified(WebViewUnsupportedUriSchemeIdentifiedEventArgs args)
// {
// UnsupportedUriSchemeIdentified?.Invoke(_owner, args);
// }
// }
//}
//#endif
src/Uno.UI/UI/Xaml/Controls/WebView/Native/Android/NativeWebViewWrapper.cs
→
src/Uno.UI/UI/Xaml/Controls/WebView/Native/Android/NativeWebViewWrapper.
Android.
cs
浏览文件 @
65a7cf3c
文件已移动
src/Uno.UI/UI/Xaml/Controls/WebView/Native/INativeWebView.cs
浏览文件 @
65a7cf3c
...
...
@@ -3,7 +3,7 @@ using System.Net.Http;
namespace
Uno.UI.Xaml.Controls
;
internal
interface
INativeWebView
internal
partial
interface
INativeWebView
{
void
GoBack
();
void
GoForward
();
...
...
src/Uno.UI/UI/Xaml/Controls/WebView/Native/iOSmacOS/UnoWKWebView.iOSmacOS.cs
浏览文件 @
65a7cf3c
...
...
@@ -5,7 +5,6 @@ using WebKit;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Uno.Extensions
;
using
Uno.UI.Extensions
;
using
Uno.Foundation.Logging
;
using
Windows.Web
;
using
System.IO
;
...
...
@@ -84,7 +83,7 @@ public partial class UnoWKWebView : WKWebView, INativeWebView
public
void
ProcessNavigation
(
string
html
)
=>
throw
new
NotImplementedException
();
public
void
ProcessNavigation
(
HttpRequestMessage
httpRequestMessage
)
=>
throw
new
NotImplementedException
();
public
void
RegisterNavigationEvents
(
CoreWebView2
coreWebView
)
void
INativeWebView
.
SetOwner
(
CoreWebView2
coreWebView
)
{
_coreWebView
=
coreWebView
;
...
...
@@ -174,7 +173,9 @@ public partial class UnoWKWebView : WKWebView, INativeWebView
if
(
UIKit
.
UIApplication
.
SharedApplication
.
CanOpenUrl
(
target
))
{
UIKit
.
UIApplication
.
SharedApplication
.
OpenUrl
(
target
);
_coreWebView
.
OnComplete
(
target
,
isSuccessful
:
true
,
status
:
WebErrorStatus
.
Unknown
);
// TODO:MZ:
_coreWebView
.
RaiseNavigationCompleted
();
//_coreWebView.OnComplete(target, isSuccessful: true, status: WebErrorStatus.Unknown);
}
#else
if
(
target
!=
null
&&
NSWorkspace
.
SharedWorkspace
.
UrlForApplication
(
new
NSUrl
(
target
.
AbsoluteUri
))
!=
null
)
...
...
@@ -185,11 +186,13 @@ public partial class UnoWKWebView : WKWebView, INativeWebView
#endif
else
{
_coreWebView
.
OnNavigationFailed
(
new
WebViewNavigationFailedEventArgs
()
{
Uri
=
target
,
WebErrorStatus
=
WebErrorStatus
.
Unknown
});
// TODO:MZ:
_coreWebView
.
RaiseNavigationCompleted
();
//_coreWebView.OnNavigationFailed(new WebViewNavigationFailedEventArgs()
//{
// Uri = target,
// WebErrorStatus = WebErrorStatus.Unknown
//});
}
}
}
...
...
@@ -373,16 +376,18 @@ public partial class UnoWKWebView : WKWebView, INativeWebView
}
else
{
uri
=
webView
.
Url
?.
ToUri
()
??
_coreWebView
.
Source
;
uri
=
webView
.
Url
?.
ToUri
()
??
new
Uri
(
_coreWebView
.
Source
);
// TODO:MZ: What if Source is invalid URI?
}
_coreWebView
.
OnNavigationFailed
(
new
WebViewNavigationFailedEventArgs
()
{
Uri
=
uri
,
WebErrorStatus
=
status
});
//TODO:MZ:
_coreWebView
.
RaiseNavigationCompleted
();
//_coreWebView.OnNavigationFailed(new WebViewNavigationFailedEventArgs()
//{
// Uri = uri,
// WebErrorStatus = status
//});
_coreWebView
.
OnComplete
(
uri
,
false
,
status
);
//
_coreWebView.OnComplete(uri, false, status);
}
_isCancelling
=
false
;
...
...
@@ -472,11 +477,13 @@ public partial class UnoWKWebView : WKWebView, INativeWebView
this
.
Log
().
Error
(
$"The uri [
{
uri
}
] is invalid."
);
}
_coreWebView
.
RaiseNavigationFailed
(
new
WebViewNavigationFailedEventArgs
()
{
Uri
=
uri
,
WebErrorStatus
=
WebErrorStatus
.
UnexpectedClientError
});
// TODO:MZ:
_coreWebView
.
RaiseNavigationCompleted
();
//_coreWebView.RaiseNavigationFailed(new WebViewNavigationFailedEventArgs()
//{
// Uri = uri,
// WebErrorStatus = WebErrorStatus.UnexpectedClientError
//});
}
}
...
...
src/Uno.UI/UI/Xaml/Controls/WebView/Native/iOSmacOS/WebViewNavigationDelegate.iOSmacOS.cs
浏览文件 @
65a7cf3c
using
System
;
using
System.Collections.Generic
;
using
CoreGraphics
;
using
Foundation
;
using
System
;
using
WebKit
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Uno.Extensions
;
using
Uno.Foundation.Logging
;
using
Windows.Web
;
using
System.IO
;
using
System.Linq
;
using
Windows.ApplicationModel.Resources
;
using
Uno.UI.Xaml.Controls
;
using
System.Net.Http
;
using
Microsoft.Web.WebView2.Core
;
using
Uno.UI.Extensions
;
#if __IOS__
using
UIKit
;
#else
using
AppKit
;
#endif
namespace
Windows.UI.Xaml.Controls
;
...
...
@@ -299,20 +317,21 @@ internal class WebViewNavigationDelegate : WKNavigationDelegate
#endif
}
internal
void
OnComplete
(
Uri
uri
,
bool
isSuccessful
,
WebErrorStatus
status
)
{
var
args
=
new
WebViewNavigationCompletedEventArgs
()
{
IsSuccess
=
isSuccessful
,
Uri
=
uri
??
Source
,
WebErrorStatus
=
status
};
CanGoBack
=
_nativeWebView
.
CanGoBack
;
CanGoForward
=
_nativeWebView
.
CanGoForward
;
NavigationCompleted
?.
Invoke
(
_owner
,
args
);
}
//internal void OnComplete(Uri uri, bool isSuccessful, WebErrorStatus status)
//{
// // TODO:MZ:
// //var args = new WebViewNavigationCompletedEventArgs()
// //{
// // IsSuccess = isSuccessful,
// // Uri = uri ?? Source,
// // WebErrorStatus = status
// //};
// //CanGoBack = _nativeWebView.CanGoBack;
// //CanGoForward = _nativeWebView.CanGoForward;
// //NavigationCompleted?.Invoke(_owner, args);
//}
internal
void
OnNavigationStarting
(
WebViewNavigationStartingEventArgs
args
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录