mirror of
https://github.com/zs-yg/kortapp-z.git
synced 2025-12-07 00:20:43 +08:00
Compare commits
9 Commits
v0.9.8-bet
...
v1.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b27d2e1dc | ||
|
|
0f578d56d4 | ||
|
|
d36a367147 | ||
|
|
2c8ce29b3d | ||
|
|
efe7d16f96 | ||
|
|
a5b60d7079 | ||
|
|
f8192063a4 | ||
|
|
cd1abd3e33 | ||
|
|
cc577948b7 |
63
AboutForm.cs
63
AboutForm.cs
@@ -50,16 +50,75 @@ namespace AppStore
|
|||||||
|
|
||||||
// 初始化并添加应用信息
|
// 初始化并添加应用信息
|
||||||
infoLabel = new Label();
|
infoLabel = new Label();
|
||||||
infoLabel.Text = "kortapp-z\n版本: 0.9.8\n一个简单、开源的应用商店\nkortapp-z是完全免费的基于.NET8和C++的软件";
|
infoLabel.Text = "kortapp-z\n版本: 1.0.1\n作者: zs-yg\n一个简单、开源的应用商店\nkortapp-z是完全免费\n基于.NET8和C++的软件";
|
||||||
infoLabel.Font = new Font("Microsoft YaHei", 12);
|
infoLabel.Font = new Font("Microsoft YaHei", 12);
|
||||||
infoLabel.AutoSize = false;
|
infoLabel.AutoSize = false;
|
||||||
infoLabel.Width = 300;
|
infoLabel.Width = 300;
|
||||||
infoLabel.Height = 100;
|
infoLabel.Height = 130; // 增加高度确保文字完整显示
|
||||||
infoLabel.TextAlign = ContentAlignment.MiddleCenter;
|
infoLabel.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
infoLabel.Anchor = AnchorStyles.None;
|
infoLabel.Anchor = AnchorStyles.None;
|
||||||
mainLayout.Controls.Add(infoLabel, 0, 1);
|
mainLayout.Controls.Add(infoLabel, 0, 1);
|
||||||
|
|
||||||
|
// 调整主布局为3行
|
||||||
|
mainLayout.RowCount = 3;
|
||||||
|
mainLayout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
|
||||||
|
mainLayout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
|
||||||
|
mainLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
|
||||||
|
|
||||||
|
// 在底部添加GitHub链接区域
|
||||||
|
TableLayoutPanel githubPanel = new TableLayoutPanel();
|
||||||
|
githubPanel.Dock = DockStyle.Bottom;
|
||||||
|
githubPanel.Height = 60;
|
||||||
|
githubPanel.ColumnCount = 3;
|
||||||
|
githubPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
|
||||||
|
githubPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
|
||||||
|
githubPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
|
||||||
|
githubPanel.RowCount = 1;
|
||||||
|
githubPanel.Padding = new Padding(10);
|
||||||
|
|
||||||
|
// 添加GitHub图标
|
||||||
|
PictureBox githubIcon = new PictureBox();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
githubIcon.Image = Image.FromFile("img/jpg/github.jpg");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError($"无法加载GitHub图标: {ex.Message}");
|
||||||
|
githubIcon.Image = SystemIcons.Application.ToBitmap();
|
||||||
|
}
|
||||||
|
githubIcon.SizeMode = PictureBoxSizeMode.Zoom;
|
||||||
|
githubIcon.Width = 30;
|
||||||
|
githubIcon.Height = 30;
|
||||||
|
githubIcon.Cursor = Cursors.Hand;
|
||||||
|
githubIcon.Click += (s, e) => {
|
||||||
|
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = "https://github.com/zs-yg/kortapp-z",
|
||||||
|
UseShellExecute = true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 添加文字说明
|
||||||
|
Label githubLabel = new Label();
|
||||||
|
githubLabel.Text = "🤗🤗🤗开源地址 🌟 欢迎点star和提交pr 🚀";
|
||||||
|
githubLabel.Font = new Font("Microsoft YaHei", 10);
|
||||||
|
githubLabel.AutoSize = true;
|
||||||
|
githubLabel.Margin = new Padding(10, 0, 0, 0);
|
||||||
|
|
||||||
|
// 创建包含图标和文字的面板
|
||||||
|
Panel linkPanel = new Panel();
|
||||||
|
linkPanel.AutoSize = true;
|
||||||
|
linkPanel.Controls.Add(githubIcon);
|
||||||
|
linkPanel.Controls.Add(githubLabel);
|
||||||
|
githubIcon.Location = new Point(0, 0);
|
||||||
|
githubLabel.Location = new Point(githubIcon.Width + 10, 5);
|
||||||
|
|
||||||
|
// 将链接面板添加到中间列
|
||||||
|
githubPanel.Controls.Add(linkPanel, 1, 0);
|
||||||
|
|
||||||
this.Controls.Add(mainLayout);
|
this.Controls.Add(mainLayout);
|
||||||
|
this.Controls.Add(githubPanel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ namespace AppStore
|
|||||||
public string AppName { get; set; } = string.Empty;
|
public string AppName { get; set; } = string.Empty;
|
||||||
public Image AppIcon { get; set; } = SystemIcons.Application.ToBitmap();
|
public Image AppIcon { get; set; } = SystemIcons.Application.ToBitmap();
|
||||||
public string DownloadUrl { get; set; } = string.Empty;
|
public string DownloadUrl { get; set; } = string.Empty;
|
||||||
|
public bool ShowDownloadButton { get; set; } = true;
|
||||||
|
|
||||||
public AppCard()
|
public AppCard()
|
||||||
{
|
{
|
||||||
@@ -88,6 +89,7 @@ namespace AppStore
|
|||||||
|
|
||||||
downloadBtn.Click += DownloadBtn_Click;
|
downloadBtn.Click += DownloadBtn_Click;
|
||||||
this.Controls.Add(downloadBtn);
|
this.Controls.Add(downloadBtn);
|
||||||
|
downloadBtn.Visible = ShowDownloadButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -25,7 +25,10 @@
|
|||||||
<None Include="img\jpg\*.jpg">
|
<None Include="img\jpg\*.jpg">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Include="img\ico\icon.ico">
|
<None Include="img\resource\png\*.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="img\ico\*.ico">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
260
MainForm.cs
260
MainForm.cs
@@ -2,6 +2,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.IO;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Diagnostics;
|
||||||
using AppStore;
|
using AppStore;
|
||||||
|
|
||||||
namespace AppStore
|
namespace AppStore
|
||||||
@@ -11,6 +16,106 @@ namespace AppStore
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class MainForm : Form
|
public class MainForm : Form
|
||||||
{
|
{
|
||||||
|
private static readonly string CacheDir = Path.Combine(
|
||||||
|
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||||
|
"zsyg", "kortapp-z", ".cache");
|
||||||
|
|
||||||
|
private class AppPositionCache
|
||||||
|
{
|
||||||
|
public string AppName { get; set; } = string.Empty;
|
||||||
|
public int X { get; set; }
|
||||||
|
public int Y { get; set; }
|
||||||
|
public DateTime LastUpdated { get; set; } = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetPositionCacheFilePath(string appName)
|
||||||
|
{
|
||||||
|
using var md5 = MD5.Create();
|
||||||
|
var hash = md5.ComputeHash(Encoding.UTF8.GetBytes(appName));
|
||||||
|
var fileName = BitConverter.ToString(hash).Replace("-", "").ToLower() + ".json";
|
||||||
|
return Path.Combine(CacheDir, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void EnsureCacheDirectory()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(CacheDir))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(CacheDir);
|
||||||
|
Logger.Log($"已创建缓存目录: {CacheDir}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError($"创建缓存目录失败: {CacheDir}", ex);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool TryReadPositionCache(string appName, out AppPositionCache? cacheData)
|
||||||
|
{
|
||||||
|
cacheData = null;
|
||||||
|
var cacheFile = GetPositionCacheFilePath(appName);
|
||||||
|
|
||||||
|
if (!File.Exists(cacheFile))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var json = File.ReadAllText(cacheFile);
|
||||||
|
cacheData = JsonSerializer.Deserialize<AppPositionCache>(json);
|
||||||
|
return cacheData != null;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WritePositionCache(string appName, Point position)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
EnsureCacheDirectory();
|
||||||
|
var cacheFile = GetPositionCacheFilePath(appName);
|
||||||
|
|
||||||
|
var cacheData = new AppPositionCache
|
||||||
|
{
|
||||||
|
AppName = appName,
|
||||||
|
X = position.X,
|
||||||
|
Y = position.Y,
|
||||||
|
LastUpdated = DateTime.Now
|
||||||
|
};
|
||||||
|
|
||||||
|
var json = JsonSerializer.Serialize(cacheData);
|
||||||
|
File.WriteAllText(cacheFile, json);
|
||||||
|
Logger.Log($"已保存位置缓存: {appName} ({position.X}, {position.Y})");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError($"保存位置缓存失败: {appName}", ex);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsPositionCacheValid(AppPositionCache cacheData)
|
||||||
|
{
|
||||||
|
// 缓存有效期设为7天
|
||||||
|
return (DateTime.Now - cacheData.LastUpdated).TotalDays <= 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SaveAllCardPositions(FlowLayoutPanel flowPanel)
|
||||||
|
{
|
||||||
|
foreach (Control control in flowPanel.Controls)
|
||||||
|
{
|
||||||
|
if (control is AppCard card)
|
||||||
|
{
|
||||||
|
WritePositionCache(card.AppName, control.Location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 软件下载按钮
|
// 软件下载按钮
|
||||||
private Button btnApps = null!;
|
private Button btnApps = null!;
|
||||||
// 下载进度按钮
|
// 下载进度按钮
|
||||||
@@ -41,6 +146,9 @@ namespace AppStore
|
|||||||
buttonPanel.Height = 70;
|
buttonPanel.Height = 70;
|
||||||
buttonPanel.BackColor = Color.FromArgb(240, 240, 240);
|
buttonPanel.BackColor = Color.FromArgb(240, 240, 240);
|
||||||
buttonPanel.Padding = new Padding(10, 15, 10, 0);
|
buttonPanel.Padding = new Padding(10, 15, 10, 0);
|
||||||
|
buttonPanel.AutoScroll = true;
|
||||||
|
buttonPanel.AutoSize = true;
|
||||||
|
buttonPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||||
|
|
||||||
// 导航按钮样式
|
// 导航按钮样式
|
||||||
Action<Button> styleButton = (Button btn) => {
|
Action<Button> styleButton = (Button btn) => {
|
||||||
@@ -108,6 +216,17 @@ namespace AppStore
|
|||||||
};
|
};
|
||||||
buttonPanel.Controls.Add(btnAbout);
|
buttonPanel.Controls.Add(btnAbout);
|
||||||
|
|
||||||
|
// 内置工具按钮
|
||||||
|
var btnTools = new Button();
|
||||||
|
btnTools.Text = "内置工具";
|
||||||
|
btnTools.Location = new Point(590, 0);
|
||||||
|
styleButton(btnTools);
|
||||||
|
btnTools.Click += (s, e) => {
|
||||||
|
Logger.Log("用户点击了'内置工具'按钮");
|
||||||
|
ShowToolsView();
|
||||||
|
};
|
||||||
|
buttonPanel.Controls.Add(btnTools);
|
||||||
|
|
||||||
// 现代化内容区域
|
// 现代化内容区域
|
||||||
contentPanel = new Panel();
|
contentPanel = new Panel();
|
||||||
contentPanel.Dock = DockStyle.Fill;
|
contentPanel.Dock = DockStyle.Fill;
|
||||||
@@ -139,6 +258,58 @@ namespace AppStore
|
|||||||
contentPanel.Controls.Add(settingsControl);
|
contentPanel.Controls.Add(settingsControl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ShowToolsView()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
contentPanel.Controls.Clear();
|
||||||
|
|
||||||
|
var flowPanel = new FlowLayoutPanel();
|
||||||
|
flowPanel.Dock = DockStyle.Fill;
|
||||||
|
flowPanel.AutoScroll = true;
|
||||||
|
flowPanel.WrapContents = false;
|
||||||
|
flowPanel.FlowDirection = FlowDirection.LeftToRight;
|
||||||
|
contentPanel.Controls.Add(flowPanel);
|
||||||
|
|
||||||
|
// 系统清理卡片
|
||||||
|
var cleanerCard = new ToolCard();
|
||||||
|
cleanerCard.ToolName = "系统清理";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
cleanerCard.ToolIcon = Image.FromFile("img/resource/png/system_cleaner.png");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
cleanerCard.ToolIcon = SystemIcons.Shield.ToBitmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanerCard.UpdateDisplay();
|
||||||
|
cleanerCard.ToolCardClicked += (s, e) => {
|
||||||
|
try {
|
||||||
|
string toolPath = Path.Combine(Application.StartupPath, "resource", "system_cleaner.exe");
|
||||||
|
if (File.Exists(toolPath)) {
|
||||||
|
Process.Start(toolPath);
|
||||||
|
} else {
|
||||||
|
MessageBox.Show("系统清理工具未找到,请确保已正确安装", "错误",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
MessageBox.Show($"启动清理工具失败: {ex.Message}", "错误",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
flowPanel.Controls.Add(cleanerCard);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError("显示内置工具视图时出错", ex);
|
||||||
|
MessageBox.Show("加载内置工具时发生错误,请重试", "错误",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
ShowAppsView(); // 回退到默认视图
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ShowAboutView()
|
private void ShowAboutView()
|
||||||
{
|
{
|
||||||
contentPanel.Controls.Clear();
|
contentPanel.Controls.Clear();
|
||||||
@@ -164,10 +335,8 @@ namespace AppStore
|
|||||||
{
|
{
|
||||||
// 创建新的应用卡片实例
|
// 创建新的应用卡片实例
|
||||||
AppCard card = new AppCard();
|
AppCard card = new AppCard();
|
||||||
|
card.AppName = appName;
|
||||||
// 设置卡片基本属性
|
card.DownloadUrl = downloadUrl;
|
||||||
card.AppName = appName; // 设置显示的应用名称
|
|
||||||
card.DownloadUrl = downloadUrl; // 设置下载链接地址
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -189,23 +358,61 @@ namespace AppStore
|
|||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowAppsView()
|
private async void ShowAppsView()
|
||||||
{
|
{
|
||||||
contentPanel.Controls.Clear();
|
contentPanel.Controls.Clear();
|
||||||
|
|
||||||
// 使用FlowLayoutPanel来组织应用卡片
|
// 同步创建并添加FlowLayoutPanel
|
||||||
FlowLayoutPanel flowPanel = new FlowLayoutPanel();
|
FlowLayoutPanel flowPanel = new FlowLayoutPanel();
|
||||||
flowPanel.Dock = DockStyle.Fill;
|
flowPanel.Dock = DockStyle.Fill;
|
||||||
flowPanel.AutoScroll = true;
|
flowPanel.AutoScroll = true;
|
||||||
flowPanel.Padding = new Padding(15, 50, 15, 15); // 恢复原有内边距
|
flowPanel.Padding = new Padding(15, 50, 15, 15);
|
||||||
flowPanel.WrapContents = true;
|
flowPanel.WrapContents = true;
|
||||||
flowPanel.Margin = new Padding(0);
|
flowPanel.Margin = new Padding(0);
|
||||||
flowPanel.AutoSize = true;
|
flowPanel.AutoSize = true;
|
||||||
flowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
flowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||||
flowPanel.AutoScrollMinSize = new Size(0, 999999); // 增加滑动距离
|
flowPanel.AutoScrollMinSize = new Size(0, 3350);
|
||||||
contentPanel.Controls.Add(flowPanel);
|
contentPanel.Controls.Add(flowPanel);
|
||||||
|
|
||||||
// 添加所有应用卡片
|
// 添加窗体关闭事件处理
|
||||||
|
this.FormClosing += (sender, e) => {
|
||||||
|
SaveAllCardPositions(flowPanel);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 确保控件已创建
|
||||||
|
await Task.Delay(100);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 异步添加卡片
|
||||||
|
await Task.Run(() => {
|
||||||
|
if (flowPanel.IsHandleCreated)
|
||||||
|
{
|
||||||
|
flowPanel.Invoke((MethodInvoker)delegate {
|
||||||
|
AddAllAppCards(flowPanel);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError("渲染应用卡片时出错", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddAllAppCards(FlowLayoutPanel flowPanel)
|
||||||
|
{
|
||||||
|
flowPanel.Dock = DockStyle.Fill;
|
||||||
|
flowPanel.AutoScroll = true;
|
||||||
|
flowPanel.Padding = new Padding(15, 50, 15, 15);
|
||||||
|
flowPanel.WrapContents = true;
|
||||||
|
flowPanel.Margin = new Padding(0);
|
||||||
|
flowPanel.AutoSize = true;
|
||||||
|
flowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||||
|
flowPanel.AutoScrollMinSize = new Size(0, 3350);
|
||||||
|
contentPanel.Controls.Add(flowPanel);
|
||||||
|
|
||||||
|
// 添加所有应用卡片并恢复位置
|
||||||
|
|
||||||
|
|
||||||
flowPanel.Controls.Add(CreateAppCard(
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
@@ -228,6 +435,11 @@ namespace AppStore
|
|||||||
"https://ghproxy.net/https://github.com/zs-yg/package/releases/download/v0.7/NeatDM_setup.exe",
|
"https://ghproxy.net/https://github.com/zs-yg/package/releases/download/v0.7/NeatDM_setup.exe",
|
||||||
"img/jpg/NDM.jpg"));
|
"img/jpg/NDM.jpg"));
|
||||||
|
|
||||||
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
|
"youtube-dl",
|
||||||
|
"https://ghproxy.net/https://github.com/ytdl-org/youtube-dl/releases/download/2021.12.17/youtube-dl.exe",
|
||||||
|
""));
|
||||||
|
|
||||||
flowPanel.Controls.Add(CreateAppCard(
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
"python3.8",
|
"python3.8",
|
||||||
"https://www.python.org/ftp/python/3.8.0/python-3.8.0-amd64.exe",
|
"https://www.python.org/ftp/python/3.8.0/python-3.8.0-amd64.exe",
|
||||||
@@ -298,6 +510,11 @@ namespace AppStore
|
|||||||
"https://ghproxy.net/https://github.com/OpenListTeam/OpenList/releases/download/beta/openlist-windows-amd64.zip",
|
"https://ghproxy.net/https://github.com/OpenListTeam/OpenList/releases/download/beta/openlist-windows-amd64.zip",
|
||||||
"img/png/openlist.png"));
|
"img/png/openlist.png"));
|
||||||
|
|
||||||
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
|
"SpaceSniffer",
|
||||||
|
"https://ghproxy.net/https://github.com/zs-yg/package/releases/download/v0.8/SpaceSniffer.exe",
|
||||||
|
"img/png/SpaceSniffer.png"));
|
||||||
|
|
||||||
flowPanel.Controls.Add(CreateAppCard(
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
"OpenSpeedy",
|
"OpenSpeedy",
|
||||||
"https://ghproxy.net/https://github.com/game1024/OpenSpeedy/releases/download/v1.7.1/OpenSpeedy-v1.7.1.zip",
|
"https://ghproxy.net/https://github.com/game1024/OpenSpeedy/releases/download/v1.7.1/OpenSpeedy-v1.7.1.zip",
|
||||||
@@ -338,11 +555,36 @@ namespace AppStore
|
|||||||
"https://ghproxy.net/https://github.com/peazip/PeaZip/releases/download/10.4.0/peazip-10.4.0.WIN64.exe",
|
"https://ghproxy.net/https://github.com/peazip/PeaZip/releases/download/10.4.0/peazip-10.4.0.WIN64.exe",
|
||||||
"img/jpg/peazip.jpg"));
|
"img/jpg/peazip.jpg"));
|
||||||
|
|
||||||
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
|
"nanazip",
|
||||||
|
"https://ghproxy.net/https://github.com/M2Team/NanaZip/releases/download/5.0.1263.0/NanaZip_5.0.1263.0_DebugSymbols.zip",
|
||||||
|
"img/png/nanazip.png"));
|
||||||
|
|
||||||
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
|
"PCL2",
|
||||||
|
"https://ghproxy.net/https://github.com/zs-yg/package/releases/download/v0.9/Plain.Craft.Launcher.2.exe",
|
||||||
|
"img/jpg/pcl2.jpg"));
|
||||||
|
|
||||||
flowPanel.Controls.Add(CreateAppCard(
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
"GreenShot",
|
"GreenShot",
|
||||||
"https://objects.githubusercontent.com/github-production-release-asset-2e65be/36756917/239aedb0-7d29-11e7-9f9c-d36ec4466ade?X-Amz-Algorithm=AWS4-HMAC-SSHA256&X-Amz-Credential=releaseassetproduction%2F20250613%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250613T041723Z&X-Amz-Expires=300&X-Amz-Signature=be1ef88a68bbc7065af5111809d11de881022933b44f6d961eb6bd6e6b7e60a8&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3DGreenshot-INSTALLER-1.2.10.6-RELEASE.exe&response-content-type=application%2Foctet-stream",
|
"https://objects.githubusercontent.com/github-production-release-asset-2e65be/36756917/239aedb0-7d29-11e7-9f9c-d36ec4466ade?X-Amz-Algorithm=AWS4-HMAC-SSHA256&X-Amz-Credential=releaseassetproduction%2F20250613%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250613T041723Z&X-Amz-Expires=300&X-Amz-Signature=be1ef88a68bbc7065af5111809d11de881022933b44f6d961eb6bd6e6b7e60a8&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3DGreenshot-INSTALLER-1.2.10.6-RELEASE.exe&response-content-type=application%2Foctet-stream",
|
||||||
"img/png/greenshot-logo.png"));
|
"img/png/greenshot-logo.png"));
|
||||||
|
|
||||||
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
|
"DWMBlurGlass",
|
||||||
|
"https://ghproxy.net/https://github.com/Maplespe/DWMBlurGlass/releases/download/2.3.1r/DWMBlurGlass_2.3.1_x64.zip",
|
||||||
|
"img/png/DWMBlurGlass.png"));
|
||||||
|
|
||||||
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
|
"Umi-OCR",
|
||||||
|
"https://ghproxy.net/https://github.com/hiroi-sora/Umi-OCR/releases/download/v2.1.5/Umi-OCR_Paddle_v2.1.5.7z.exe",
|
||||||
|
"img/png/Umi-OCR.png"));
|
||||||
|
|
||||||
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
|
"frp",
|
||||||
|
"https://github.com/fatedier/frp/releases/download/v0.62.1/frp_0.62.1_windows_amd64.zip",
|
||||||
|
""));
|
||||||
|
|
||||||
flowPanel.Controls.Add(CreateAppCard(
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
"VLC Media Player",
|
"VLC Media Player",
|
||||||
"https://mirrors.ustc.edu.cn/videolan-ftp/vlc/3.0.21/win64/vlc-3.0.21-win64.exe",
|
"https://mirrors.ustc.edu.cn/videolan-ftp/vlc/3.0.21/win64/vlc-3.0.21-win64.exe",
|
||||||
|
|||||||
77
ToolCard.cs
Normal file
77
ToolCard.cs
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace AppStore
|
||||||
|
{
|
||||||
|
public class ToolCard : UserControl
|
||||||
|
{
|
||||||
|
private PictureBox iconBox = new PictureBox();
|
||||||
|
private Label nameLabel = new Label();
|
||||||
|
|
||||||
|
public string ToolName { get; set; } = string.Empty;
|
||||||
|
public Image ToolIcon { get; set; } = SystemIcons.Shield.ToBitmap();
|
||||||
|
|
||||||
|
// 自定义点击事件初始化为空委托
|
||||||
|
public event EventHandler ToolCardClicked = delegate {};
|
||||||
|
|
||||||
|
public ToolCard()
|
||||||
|
{
|
||||||
|
// 启用双缓冲
|
||||||
|
this.SetStyle(ControlStyles.OptimizedDoubleBuffer |
|
||||||
|
ControlStyles.ResizeRedraw, true);
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.Size = new Size(240, 220);
|
||||||
|
this.BackColor = Color.White;
|
||||||
|
this.Padding = new Padding(5);
|
||||||
|
this.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
|
||||||
|
// 工具图标
|
||||||
|
iconBox = new PictureBox();
|
||||||
|
iconBox.Size = new Size(80, 80);
|
||||||
|
iconBox.Location = new Point((Width - 80) / 2, 15);
|
||||||
|
iconBox.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||||
|
this.Controls.Add(iconBox);
|
||||||
|
|
||||||
|
// 工具名称
|
||||||
|
nameLabel = new Label();
|
||||||
|
nameLabel.AutoSize = false;
|
||||||
|
nameLabel.Size = new Size(Width - 20, 30);
|
||||||
|
nameLabel.Location = new Point(10, 100);
|
||||||
|
nameLabel.Font = new Font("Microsoft YaHei", 10, FontStyle.Bold);
|
||||||
|
nameLabel.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
this.Controls.Add(nameLabel);
|
||||||
|
|
||||||
|
// 打开按钮
|
||||||
|
var openButton = new Button();
|
||||||
|
openButton.Text = "打开工具";
|
||||||
|
openButton.Size = new Size(100, 30);
|
||||||
|
openButton.Location = new Point((Width - 100) / 2, 140);
|
||||||
|
openButton.BackColor = Color.FromArgb(0, 120, 215);
|
||||||
|
openButton.ForeColor = Color.White;
|
||||||
|
openButton.FlatStyle = FlatStyle.Flat;
|
||||||
|
openButton.FlatAppearance.BorderSize = 0;
|
||||||
|
openButton.Cursor = Cursors.Hand;
|
||||||
|
// 按钮点击直接触发ToolCardClicked事件
|
||||||
|
openButton.Click += (s, e) => {
|
||||||
|
ToolCardClicked?.Invoke(this, e);
|
||||||
|
};
|
||||||
|
this.Controls.Add(openButton);
|
||||||
|
|
||||||
|
// 设置按钮悬停效果
|
||||||
|
openButton.BackColor = Color.FromArgb(0, 120, 215);
|
||||||
|
openButton.FlatAppearance.MouseOverBackColor = Color.FromArgb(0, 100, 180);
|
||||||
|
openButton.FlatAppearance.MouseDownBackColor = Color.FromArgb(0, 80, 160);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateDisplay()
|
||||||
|
{
|
||||||
|
nameLabel.Text = ToolName;
|
||||||
|
iconBox.Image = ToolIcon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
del.bat
2
del.bat
@@ -1,4 +1,2 @@
|
|||||||
rmdir bin /s /q
|
rmdir bin /s /q
|
||||||
rmdir obj /s /q
|
rmdir obj /s /q
|
||||||
rmdir logs /s /q
|
|
||||||
mkdir logs
|
|
||||||
BIN
img/jpg/github.jpg
Normal file
BIN
img/jpg/github.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.7 KiB |
BIN
img/png/DWMBlurGlass.png
Normal file
BIN
img/png/DWMBlurGlass.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 475 B |
BIN
img/png/SpaceSniffer.png
Normal file
BIN
img/png/SpaceSniffer.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
BIN
img/png/Umi-OCR.png
Normal file
BIN
img/png/Umi-OCR.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 94 KiB |
BIN
img/png/nanazip.png
Normal file
BIN
img/png/nanazip.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
BIN
img/resource/png/system_cleaner.png
Normal file
BIN
img/resource/png/system_cleaner.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 644 KiB |
@@ -9,7 +9,23 @@ int main() {
|
|||||||
auto start = std::chrono::high_resolution_clock::now();
|
auto start = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
// 定义日志目录路径
|
// 定义日志目录路径
|
||||||
fs::path logDir = "logs";
|
fs::path logDir;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Windows系统获取AppData路径
|
||||||
|
char* appData = nullptr;
|
||||||
|
size_t len = 0;
|
||||||
|
if (_dupenv_s(&appData, &len, "APPDATA") == 0 && appData != nullptr) {
|
||||||
|
logDir = fs::path(appData) / "zsyg" / "kortapp-z" / ".logs";
|
||||||
|
free(appData);
|
||||||
|
} else {
|
||||||
|
std::cerr << "无法获取APPDATA环境变量" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// 非Windows系统使用默认路径
|
||||||
|
logDir = fs::path(getenv("HOME")) / ".zsyg" / "kortapp-z" / ".logs";
|
||||||
|
#endif
|
||||||
size_t deletedCount = 0;
|
size_t deletedCount = 0;
|
||||||
size_t errorCount = 0;
|
size_t errorCount = 0;
|
||||||
|
|
||||||
|
|||||||
23
logger.cs
23
logger.cs
@@ -1,20 +1,33 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace AppStore
|
namespace AppStore
|
||||||
{
|
{
|
||||||
public static class Logger
|
public static class Logger
|
||||||
{
|
{
|
||||||
private static readonly string LogsDirectory = "logs";
|
private static readonly string LogsDirectory = Path.Combine(
|
||||||
|
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||||
|
"zsyg", "kortapp-z", ".logs");
|
||||||
private static readonly object LockObject = new object();
|
private static readonly object LockObject = new object();
|
||||||
|
|
||||||
static Logger()
|
static Logger()
|
||||||
{
|
{
|
||||||
// 确保logs目录存在
|
try
|
||||||
if (!Directory.Exists(LogsDirectory))
|
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(LogsDirectory);
|
// 确保logs目录存在
|
||||||
|
if (!Directory.Exists(LogsDirectory))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(LogsDirectory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"无法创建日志目录: {LogsDirectory}, 错误: {ex.Message}");
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Log(string message)
|
public static void Log(string message)
|
||||||
{
|
{
|
||||||
lock (LockObject)
|
lock (LockObject)
|
||||||
@@ -23,6 +36,7 @@ namespace AppStore
|
|||||||
{
|
{
|
||||||
string fileName = $"{DateTime.Now:yyyyMMddHHmmss}.log";
|
string fileName = $"{DateTime.Now:yyyyMMddHHmmss}.log";
|
||||||
string filePath = Path.Combine(LogsDirectory, fileName);
|
string filePath = Path.Combine(LogsDirectory, fileName);
|
||||||
|
|
||||||
using (StreamWriter writer = new StreamWriter(filePath, true, Encoding.UTF8))
|
using (StreamWriter writer = new StreamWriter(filePath, true, Encoding.UTF8))
|
||||||
{
|
{
|
||||||
writer.WriteLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] {message}");
|
writer.WriteLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] {message}");
|
||||||
@@ -35,6 +49,7 @@ namespace AppStore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LogError(string message, Exception? ex = null)
|
public static void LogError(string message, Exception? ex = null)
|
||||||
{
|
{
|
||||||
string errorMessage = $"ERROR: {message}";
|
string errorMessage = $"ERROR: {message}";
|
||||||
|
|||||||
Binary file not shown.
BIN
resource/system_cleaner.exe
Normal file
BIN
resource/system_cleaner.exe
Normal file
Binary file not shown.
96
tools/system_cleaner.cpp
Normal file
96
tools/system_cleaner.cpp
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <chrono>
|
||||||
|
#include <vector>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
bool IsAdmin() {
|
||||||
|
BOOL isAdmin = FALSE;
|
||||||
|
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
|
||||||
|
PSID AdminGroup;
|
||||||
|
|
||||||
|
if (AllocateAndInitializeSid(&NtAuthority, 2,
|
||||||
|
SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS,
|
||||||
|
0, 0, 0, 0, 0, 0, &AdminGroup)) {
|
||||||
|
if (!CheckTokenMembership(NULL, AdminGroup, &isAdmin)) {
|
||||||
|
isAdmin = FALSE;
|
||||||
|
}
|
||||||
|
FreeSid(AdminGroup);
|
||||||
|
}
|
||||||
|
return isAdmin == TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CleanDirectory(const fs::path& dir, size_t& deletedCount, size_t& errorCount) {
|
||||||
|
if (!fs::exists(dir)) {
|
||||||
|
std::cout << "目录不存在: " << dir << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& entry : fs::directory_iterator(dir)) {
|
||||||
|
try {
|
||||||
|
if (fs::is_regular_file(entry)) {
|
||||||
|
fs::remove(entry);
|
||||||
|
deletedCount++;
|
||||||
|
}
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
std::cerr << "删除文件失败: " << entry.path() << " - " << e.what() << std::endl;
|
||||||
|
errorCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
try {
|
||||||
|
if (!IsAdmin()) {
|
||||||
|
std::cerr << "请以管理员身份运行此程序以清理所有目录" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto start = std::chrono::high_resolution_clock::now();
|
||||||
|
size_t totalDeleted = 0;
|
||||||
|
size_t totalErrors = 0;
|
||||||
|
|
||||||
|
// 定义要清理的目录列表
|
||||||
|
std::vector<fs::path> directories = {
|
||||||
|
"C:\\Windows\\Temp",
|
||||||
|
fs::path(std::getenv("USERPROFILE")) / "AppData" / "Local" / "Temp",
|
||||||
|
"C:\\Windows\\SoftwareDistribution\\Download",
|
||||||
|
"C:\\Windows\\Logs",
|
||||||
|
"C:\\Windows\\Minidump"
|
||||||
|
};
|
||||||
|
|
||||||
|
// 只有管理员才能清理Prefetch目录
|
||||||
|
if (IsAdmin()) {
|
||||||
|
directories.push_back("C:\\Windows\\Prefetch");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 清理每个目录
|
||||||
|
for (const auto& dir : directories) {
|
||||||
|
size_t dirDeleted = 0;
|
||||||
|
size_t dirErrors = 0;
|
||||||
|
|
||||||
|
std::cout << "正在清理: " << dir << std::endl;
|
||||||
|
CleanDirectory(dir, dirDeleted, dirErrors);
|
||||||
|
|
||||||
|
totalDeleted += dirDeleted;
|
||||||
|
totalErrors += dirErrors;
|
||||||
|
|
||||||
|
std::cout << "已删除 " << dirDeleted << " 个文件" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto end = std::chrono::high_resolution_clock::now();
|
||||||
|
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
|
||||||
|
|
||||||
|
std::cout << "\n清理完成:" << std::endl;
|
||||||
|
std::cout << "总共删除文件数: " << totalDeleted << std::endl;
|
||||||
|
std::cout << "总共错误数: " << totalErrors << std::endl;
|
||||||
|
std::cout << "耗时: " << duration.count() << " 毫秒" << std::endl;
|
||||||
|
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
std::cerr << "发生错误: " << e.what() << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user