mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-03-30 10:19:51 +08:00
更新了 `BetterGenshinImpact.csproj` 文件中的 `WPF-UI.Violeta` 包版本,从 `3.0.5.21` 升级到 `3.0.5.23`。 在 `RepoWebBridge.cs` 文件中,注释掉了检查本地 `repo.json` 文件是否存在的代码,并直接调用 `ScriptRepoUpdater.Instance.UpdateCenterRepo()` 方法更新仓库。更新后的异常信息也进行了修改。 在 `MapPathingPage.xaml` 文件中,删除了 `ui:TreeListView` 控件的 `behavior:RightClickSelectBehavior.Enabled` 属性。 在 `ScriptControlPage.xaml` 文件中,添加了一个新的 `RowDefinition`,并在 `Grid` 中添加了一个新的 `ui:Button`,用于执行连续脚本组的命令。 在 `ScriptControlViewModel.cs` 文件中,添加了 `System.Windows.Media` 的引用。 在 `ScriptControlViewModel.cs` 文件中,添加了一个新的异步方法 `OnStartMultiScriptGroupAsync`,用于显示一个包含全选按钮和配置组复选框的对话框,并执行选中的脚本组。
74 lines
2.2 KiB
C#
74 lines
2.2 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Security.Policy;
|
|
using System.Threading.Tasks;
|
|
using BetterGenshinImpact.ViewModel.Message;
|
|
using CommunityToolkit.Mvvm.Messaging;
|
|
|
|
namespace BetterGenshinImpact.Core.Script.WebView;
|
|
|
|
/// <summary>
|
|
/// 给 WebView 提供的桥接类
|
|
/// 用于调用 C# 方法
|
|
/// </summary>
|
|
[ClassInterface(ClassInterfaceType.AutoDual)]
|
|
[ComVisible(true)]
|
|
public class RepoWebBridge
|
|
{
|
|
public async Task<string> GetRepoJson()
|
|
{
|
|
try
|
|
{
|
|
// var needUpdate = false;
|
|
// string? localRepoJsonPath = null;
|
|
// if (Directory.Exists(ScriptRepoUpdater.CenterRepoPath))
|
|
// {
|
|
// localRepoJsonPath = Directory.GetFiles(ScriptRepoUpdater.CenterRepoPath, "repo.json", SearchOption.AllDirectories).FirstOrDefault();
|
|
// if (localRepoJsonPath is null)
|
|
// {
|
|
// needUpdate = true;
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// needUpdate = true;
|
|
// }
|
|
//
|
|
// if (needUpdate)
|
|
// {
|
|
// await ScriptRepoUpdater.Instance.UpdateCenterRepo();
|
|
// }
|
|
|
|
await ScriptRepoUpdater.Instance.UpdateCenterRepo();
|
|
|
|
var localRepoJsonPath = Directory.GetFiles(ScriptRepoUpdater.CenterRepoPath, "repo.json", SearchOption.AllDirectories).FirstOrDefault();
|
|
if (localRepoJsonPath is null)
|
|
{
|
|
throw new Exception("repo.json 不存在,可能是更新仓库信息失败!");
|
|
}
|
|
var json = await File.ReadAllTextAsync(localRepoJsonPath);
|
|
return json;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
await MessageBox.ShowAsync(e.Message, "获取仓库信息失败!");
|
|
return "";
|
|
}
|
|
}
|
|
|
|
public async void ImportUri(string url)
|
|
{
|
|
try
|
|
{
|
|
await ScriptRepoUpdater.Instance.ImportScriptFromUri(url, false);
|
|
WeakReferenceMessenger.Default.Send(new RefreshDataMessage("Refresh"));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
await MessageBox.ShowAsync(e.Message, "订阅脚本链接失败!");
|
|
}
|
|
}
|
|
}
|