Skip to content

Commit

Permalink
#884 修复Win10下无法自定义新标签页背景图
Browse files Browse the repository at this point in the history
  • Loading branch information
ywmoyue committed Oct 26, 2024
1 parent 9fbbb09 commit d98113a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/BiliLite.UWP/Extensions/FileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,19 @@ public static async Task<StorageFile> GetExportFile(string fileTypeChoiceKey, st
var file = await savePicker.PickSaveFileAsync();
return file;
}

public static async Task<bool> CheckFileExist(this string path)
{
try
{
var file = await StorageFile.GetFileFromPathAsync(path);
return file != null;
}
catch (Exception)
{
// 如果文件不存在或者路径无效,将捕获异常
return false;
}
}
}
}
2 changes: 1 addition & 1 deletion src/BiliLite.UWP/Pages/NewPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private async void SetBackground()
}
else
{
if (!File.Exists(background))
if (!await background.CheckFileExist())
{
Notify.ShowMessageToast("背景图片不存在,请重新设置");
return;
Expand Down

0 comments on commit d98113a

Please sign in to comment.