Skip to content

Commit

Permalink
log opt
Browse files Browse the repository at this point in the history
  • Loading branch information
huiyadanli committed Sep 9, 2024
1 parent 4e6190a commit cb53c74
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions BetterGenshinImpact/Service/ScriptService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ public partial class ScriptService(HomePageViewModel homePageViewModel) : IScrip
{
private readonly ILogger<ScriptService> _logger = App.GetLogger<ScriptService>();

/// <summary>
/// TODO 合并到 RunMulti
/// </summary>
/// <param name="folderNameList"></param>
/// <param name="groupName"></param>
/// <returns></returns>
public async Task RunMultiJs(List<string> folderNameList, string? groupName = null)
{
// 重新加载脚本项目
Expand Down Expand Up @@ -79,6 +85,8 @@ public async Task RunMultiJs(List<string> folderNameList, string? groupName = nu

public async Task RunMulti(IEnumerable<ScriptGroupProject> projectList, string? groupName = null)
{
groupName ??= "默认";

var hasTimer = false;
var list = ReloadScriptProjects(projectList, ref hasTimer);

Expand All @@ -93,11 +101,14 @@ public async Task RunMulti(IEnumerable<ScriptGroupProject> projectList, string?
// 没启动时候,启动截图器
await homePageViewModel.OnStartTriggerAsync();

if (hasTimer)
if (!string.IsNullOrEmpty(groupName))
{
_logger.LogInformation("配置组 {Name} 包含实时任务操作调用", groupName ?? "默认");
if (hasTimer)
{
_logger.LogInformation("配置组 {Name} 包含实时任务操作调用", groupName);
}
_logger.LogInformation("配置组 {Name} 加载完成,共{Cnt}个脚本,开始执行", groupName, list.Count);
}
_logger.LogInformation("配置组 {Name} 加载完成,共{Cnt}个脚本,开始执行", groupName ?? "默认", list.Count);

var timerOperation = hasTimer ? DispatcherTimerOperationEnum.UseCacheImageWithTriggerEmpty : DispatcherTimerOperationEnum.UseSelfCaptureImage;

Expand Down Expand Up @@ -146,7 +157,10 @@ public async Task RunMulti(IEnumerable<ScriptGroupProject> projectList, string?
}
});

_logger.LogInformation("配置组 {Name} 执行结束", groupName);
if (!string.IsNullOrEmpty(groupName))
{
_logger.LogInformation("配置组 {Name} 执行结束", groupName);
}
}

private List<ScriptGroupProject> ReloadScriptProjects(IEnumerable<ScriptGroupProject> projectList, ref bool hasTimer)
Expand All @@ -162,7 +176,7 @@ private List<ScriptGroupProject> ReloadScriptProjects(IEnumerable<ScriptGroupPro
}
else if (project.Type == "KeyMouse")
{
var newProject = ScriptGroupProject.BuildKeyMouseProject(project.FolderName);
var newProject = ScriptGroupProject.BuildKeyMouseProject(project.Name);
CopyProjectProperties(project, newProject);
list.Add(newProject);
}
Expand Down

0 comments on commit cb53c74

Please sign in to comment.