提供代码质量

This commit is contained in:
zsyg
2025-07-02 09:15:43 +08:00
committed by GitHub
parent 074e55fbbc
commit 1539c665f0
3 changed files with 23 additions and 6 deletions

View File

@@ -346,10 +346,16 @@ namespace AppStore
} }
public void UpdateDisplay() public void UpdateDisplay()
{
if (nameLabel != null)
{ {
nameLabel.Text = AppName; nameLabel.Text = AppName;
}
if (iconBox != null && AppIcon != null)
{
iconBox.Image = AppIcon; iconBox.Image = AppIcon;
} }
}
private void DownloadBtn_Click(object sender, EventArgs e) private void DownloadBtn_Click(object sender, EventArgs e)
{ {

View File

@@ -101,11 +101,12 @@ namespace AppStore
throw new Exception("无法获取下载文件夹路径"); throw new Exception("无法获取下载文件夹路径");
} }
downloadsDir = Marshal.PtrToStringUni(pathPtr); downloadsDir = Marshal.PtrToStringUni(pathPtr) ??
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads");
} }
catch catch
{ {
throw new Exception("无法确定下载文件夹位置,请手动指定下载路径"); downloadsDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads");
} }
finally finally
{ {
@@ -114,7 +115,15 @@ namespace AppStore
Marshal.FreeCoTaskMem(pathPtr); Marshal.FreeCoTaskMem(pathPtr);
} }
} }
if (!string.IsNullOrEmpty(downloadsDir))
{
Directory.CreateDirectory(downloadsDir); Directory.CreateDirectory(downloadsDir);
}
else
{
throw new Exception("无法确定下载文件夹位置");
}
@@ -322,7 +331,7 @@ namespace AppStore
try try
{ {
var process = currentProcess; var process = currentProcess;
if (process == null || process.HasExited || process.StartInfo == null) if (process?.StartInfo == null || process.HasExited)
{ {
item.Status = "已取消"; item.Status = "已取消";
DownloadProgressChanged?.Invoke(item); DownloadProgressChanged?.Invoke(item);

View File

@@ -42,6 +42,8 @@ namespace AppStore
try try
{ {
var dir = Path.GetDirectoryName(ThemeConfigPath); var dir = Path.GetDirectoryName(ThemeConfigPath);
if (dir == null) return;
if (!Directory.Exists(dir)) if (!Directory.Exists(dir))
{ {
Directory.CreateDirectory(dir); Directory.CreateDirectory(dir);