mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix issues
This commit is contained in:
@@ -49,7 +49,14 @@ internal sealed partial class ShellLinkInterop : IShellLinkInterop
|
|||||||
string target = Path.Combine(desktop, $"{SH.AppNameAndVersion.Format(runtimeOptions.Version)}.lnk");
|
string target = Path.Combine(desktop, $"{SH.AppNameAndVersion.Format(runtimeOptions.Version)}.lnk");
|
||||||
|
|
||||||
IPersistFile persistFile = (IPersistFile)shellLink;
|
IPersistFile persistFile = (IPersistFile)shellLink;
|
||||||
persistFile.Save(target, false);
|
try
|
||||||
|
{
|
||||||
|
persistFile.Save(target, false);
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3786,6 +3786,15 @@ namespace Snap.Hutao.Resource.Localization {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 保存游戏路径失败 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
internal static string ViewModelSettingSetGamePathDatabaseFailedTitle {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ViewModelSettingSetGamePathDatabaseFailedTitle", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 用户 [{0}] 添加成功 的本地化字符串。
|
/// 查找类似 用户 [{0}] 添加成功 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1415,6 +1415,9 @@
|
|||||||
<data name="ViewModelSettingSetDataFolderSuccess" xml:space="preserve">
|
<data name="ViewModelSettingSetDataFolderSuccess" xml:space="preserve">
|
||||||
<value>设置数据目录成功,重启以应用更改</value>
|
<value>设置数据目录成功,重启以应用更改</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ViewModelSettingSetGamePathDatabaseFailedTitle" xml:space="preserve">
|
||||||
|
<value>保存游戏路径失败</value>
|
||||||
|
</data>
|
||||||
<data name="ViewModelUserAdded" xml:space="preserve">
|
<data name="ViewModelUserAdded" xml:space="preserve">
|
||||||
<value>用户 [{0}] 添加成功</value>
|
<value>用户 [{0}] 添加成功</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -132,7 +132,10 @@ internal sealed partial class AnnouncementContentViewer : UserControl
|
|||||||
|
|
||||||
private void OnUnloaded(object sender, RoutedEventArgs e)
|
private void OnUnloaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
WebView.CoreWebView2.WebMessageReceived -= webMessageReceivedHandler;
|
if (WebView is { CoreWebView2: CoreWebView2 coreWebView2 })
|
||||||
|
{
|
||||||
|
coreWebView2.WebMessageReceived -= webMessageReceivedHandler;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async ValueTask LoadAnnouncementAsync()
|
private async ValueTask LoadAnnouncementAsync()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) DGP Studio. All rights reserved.
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
// Licensed under the MIT license.
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using Microsoft.Data.Sqlite;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.UI.Xaml.Controls;
|
using Microsoft.UI.Xaml.Controls;
|
||||||
using Microsoft.Windows.AppLifecycle;
|
using Microsoft.Windows.AppLifecycle;
|
||||||
@@ -126,7 +127,15 @@ internal sealed partial class SettingViewModel : Abstraction.ViewModel
|
|||||||
if (isOk)
|
if (isOk)
|
||||||
{
|
{
|
||||||
await taskContext.SwitchToMainThreadAsync();
|
await taskContext.SwitchToMainThreadAsync();
|
||||||
Options.GamePath = path;
|
try
|
||||||
|
{
|
||||||
|
Options.GamePath = path;
|
||||||
|
}
|
||||||
|
catch (SqliteException ex)
|
||||||
|
{
|
||||||
|
// 文件夹权限不足,无法写入数据库
|
||||||
|
infoBarService.Error(ex, SH.ViewModelSettingSetGamePathDatabaseFailedTitle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -375,14 +375,18 @@ internal class MiHoYoJSInterface
|
|||||||
await taskContext.SwitchToMainThreadAsync();
|
await taskContext.SwitchToMainThreadAsync();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return await webView.ExecuteScriptAsync(js);
|
if (webView is not null)
|
||||||
|
{
|
||||||
|
return await webView.ExecuteScriptAsync(js);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (COMException)
|
catch (COMException)
|
||||||
{
|
{
|
||||||
// COMException (0x8007139F): 组或资源的状态不是执行请求操作的正确状态。 (0x8007139F)
|
// COMException (0x8007139F): 组或资源的状态不是执行请求操作的正确状态。 (0x8007139F)
|
||||||
// webview is disposing or disposed
|
// webview is disposing or disposed
|
||||||
return string.Empty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnWebMessageReceived(CoreWebView2 webView2, CoreWebView2WebMessageReceivedEventArgs args)
|
private async void OnWebMessageReceived(CoreWebView2 webView2, CoreWebView2WebMessageReceivedEventArgs args)
|
||||||
|
|||||||
@@ -22,7 +22,17 @@ internal sealed partial class HomaGeetestClient
|
|||||||
{
|
{
|
||||||
string template = appOptions.GeetestCustomCompositeUrl;
|
string template = appOptions.GeetestCustomCompositeUrl;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(template) || !Uri.TryCreate(template.Format(gt, challenge), UriKind.Absolute, out Uri? uri))
|
string url;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
url = template.Format(gt, challenge);
|
||||||
|
}
|
||||||
|
catch (FormatException)
|
||||||
|
{
|
||||||
|
return GeetestResponse.InternalFailure;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(template) || !Uri.TryCreate(url, UriKind.Absolute, out Uri? uri))
|
||||||
{
|
{
|
||||||
return GeetestResponse.InternalFailure;
|
return GeetestResponse.InternalFailure;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,11 @@ internal static class HttpRequestMessageBuilderExtension
|
|||||||
logger.LogWarning(ex, RequestErrorMessage);
|
logger.LogWarning(ex, RequestErrorMessage);
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
catch (HttpContentSerializationException ex)
|
||||||
|
{
|
||||||
|
logger.LogWarning(ex, RequestErrorMessage);
|
||||||
|
return default;
|
||||||
|
}
|
||||||
catch (SocketException ex)
|
catch (SocketException ex)
|
||||||
{
|
{
|
||||||
logger.LogWarning(ex, RequestErrorMessage);
|
logger.LogWarning(ex, RequestErrorMessage);
|
||||||
|
|||||||
Reference in New Issue
Block a user