mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-25 10:05:49 +08:00
fix
This commit is contained in:
@@ -69,7 +69,7 @@ public class KeyMouseRecorderJsonLine
|
||||
StartTimeUnixTimestamp = (startTime - new DateTime(1970, 1, 1)).TotalNanoseconds.ToString("F0")
|
||||
};
|
||||
var infoJson = JsonSerializer.Serialize(Info, JsonOptions);
|
||||
File.WriteAllText(Path.Combine(path, "info.json"), infoJson);
|
||||
File.WriteAllText(Path.Combine(path, $"{folderName}.json"), infoJson);
|
||||
|
||||
_consumerTask = Task.Run(async () => await ConsumeEventsAsync(path));
|
||||
}
|
||||
|
||||
@@ -120,9 +120,9 @@
|
||||
</ListView.View>
|
||||
<ListBox.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Command="{Binding EditScriptCommand}"
|
||||
<!--<MenuItem Command="{Binding EditScriptCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"
|
||||
Header="修改名称" />
|
||||
Header="修改名称" />-->
|
||||
<MenuItem Command="{Binding DeleteScriptCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"
|
||||
Header="删除" />
|
||||
|
||||
@@ -36,7 +36,7 @@ public partial class KeyMouseRecordPageViewModel : ObservableObject, INavigation
|
||||
private readonly ISnackbarService _snackbarService;
|
||||
|
||||
public AllConfig Config { get; set; }
|
||||
|
||||
|
||||
string fileName = $"{DateTime.Now:yyyyMMddHH_mmssffff}";
|
||||
|
||||
public KeyMouseRecordPageViewModel(ISnackbarService snackbarService, IConfigService configService)
|
||||
@@ -92,6 +92,7 @@ public partial class KeyMouseRecordPageViewModel : ObservableObject, INavigation
|
||||
Toast.Warning("请先在启动页,启动截图器再使用本功能");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsRecording)
|
||||
{
|
||||
IsRecording = true;
|
||||
@@ -156,6 +157,7 @@ public partial class KeyMouseRecordPageViewModel : ObservableObject, INavigation
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var str = PromptDialog.Prompt("请输入要修改为的名称(实际就是文件名)", "修改名称");
|
||||
@@ -200,9 +202,26 @@ public partial class KeyMouseRecordPageViewModel : ObservableObject, INavigation
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
File.Delete(Path.Combine(scriptPath, item.Name));
|
||||
var path = new FileInfo(item.Path).Directory!.FullName;
|
||||
// 校验文件夹是否在 scriptPath 下
|
||||
if (!path.StartsWith(scriptPath))
|
||||
{
|
||||
_snackbarService.Show(
|
||||
"删除失败",
|
||||
$"{path} 删除失败,不在脚本目录下",
|
||||
ControlAppearance.Danger,
|
||||
null,
|
||||
TimeSpan.FromSeconds(3)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// 删除目录
|
||||
Directory.Delete(path, true);
|
||||
|
||||
_snackbarService.Show(
|
||||
"删除成功",
|
||||
$"{item.Name} 已经被删除",
|
||||
@@ -239,4 +258,4 @@ public partial class KeyMouseRecordPageViewModel : ObservableObject, INavigation
|
||||
Config.ScriptConfig.ScriptRepoHintDotVisible = false;
|
||||
ScriptRepoUpdater.Instance.OpenLocalRepoInWebView();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user