mirror of
https://github.com/zs-yg/kortapp-z.git
synced 2025-12-06 16:10:42 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24a352f67b | ||
|
|
9dfa777c6d | ||
|
|
30d1c0c8c6 | ||
|
|
efd2c615bc |
@@ -16,10 +16,13 @@
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="help.txt" />
|
||||
<None Include="resource\aria2c.exe">
|
||||
<None Include="resource\*.exe">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="img\png\WindowsCleaner.png">
|
||||
<None Include="img\png\*.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="img\jpg\*.jpg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="img\ico\icon.ico">
|
||||
|
||||
74
MainForm.cs
74
MainForm.cs
@@ -2,6 +2,7 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using AppStore;
|
||||
|
||||
namespace AppStore
|
||||
{
|
||||
@@ -9,6 +10,7 @@ namespace AppStore
|
||||
{
|
||||
private Button btnApps = null!;
|
||||
private Button btnDownloads = null!;
|
||||
private Button btnSettings = null!;
|
||||
private Panel contentPanel = null!;
|
||||
|
||||
private void InitializeComponent()
|
||||
@@ -32,7 +34,11 @@ namespace AppStore
|
||||
btnApps.Size = new Size(100, 30);
|
||||
btnApps.Location = new Point(20, 10);
|
||||
btnApps.Font = new Font("Microsoft YaHei", 9);
|
||||
btnApps.Click += (s, e) => ShowAppsView();
|
||||
btnApps.Click += (s, e) =>
|
||||
{
|
||||
Logger.Log("用户点击了'软件下载'按钮");
|
||||
ShowAppsView();
|
||||
};
|
||||
buttonPanel.Controls.Add(btnApps);
|
||||
|
||||
// 下载进度按钮
|
||||
@@ -41,21 +47,46 @@ namespace AppStore
|
||||
btnDownloads.Size = new Size(100, 30);
|
||||
btnDownloads.Location = new Point(140, 10);
|
||||
btnDownloads.Font = new Font("Microsoft YaHei", 9);
|
||||
btnDownloads.Click += (s, e) => ShowDownloadsView();
|
||||
btnDownloads.Click += (s, e) =>
|
||||
{
|
||||
Logger.Log("用户点击了'下载进度'按钮");
|
||||
ShowDownloadsView();
|
||||
};
|
||||
buttonPanel.Controls.Add(btnDownloads);
|
||||
|
||||
this.Controls.Add(buttonPanel);
|
||||
|
||||
// 设置按钮
|
||||
btnSettings = new Button
|
||||
{
|
||||
Text = "设置",
|
||||
Size = new Size(100, 30),
|
||||
Location = new Point(260, 10),
|
||||
Font = new Font("Microsoft YaHei", 9)
|
||||
};
|
||||
btnSettings.Click += (s, e) =>
|
||||
{
|
||||
Logger.Log("用户点击了'设置'按钮");
|
||||
ShowSettingsView();
|
||||
};
|
||||
buttonPanel.Controls.Add(btnSettings);
|
||||
|
||||
// 内容区域
|
||||
contentPanel = new Panel();
|
||||
contentPanel.Dock = DockStyle.Fill;
|
||||
contentPanel.Padding = new Padding(10); // 减少内边距
|
||||
contentPanel.Padding = new Padding(10);
|
||||
this.Controls.Add(contentPanel);
|
||||
|
||||
this.Controls.Add(buttonPanel);
|
||||
|
||||
// 默认显示软件下载视图
|
||||
ShowAppsView();
|
||||
}
|
||||
|
||||
private void ShowSettingsView()
|
||||
{
|
||||
var settingsForm = new SettingsForm();
|
||||
settingsForm.ShowDialog();
|
||||
}
|
||||
|
||||
private AppCard CreateAppCard(string appName, string downloadUrl, string iconPath)
|
||||
{
|
||||
AppCard card = new AppCard();
|
||||
@@ -65,10 +96,12 @@ namespace AppStore
|
||||
try
|
||||
{
|
||||
card.AppIcon = Image.FromFile(iconPath);
|
||||
Logger.Log($"成功创建应用卡片: {appName}, 图标路径: {iconPath}");
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
card.AppIcon = SystemIcons.Application.ToBitmap();
|
||||
Logger.LogError($"创建应用卡片时加载图标失败: {appName}, 使用默认图标", ex);
|
||||
}
|
||||
|
||||
card.UpdateDisplay();
|
||||
@@ -386,6 +419,31 @@ namespace AppStore
|
||||
"RIME",
|
||||
"https://objects.githubusercontent.com/github-production-release-asset-2e65be/3777237/08e5cfdc-492c-444a-80b3-f8d8caeb5a2a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250614%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250614T012552Z&X-Amz-Expires=300&X-Amz-Signature=9d6c9431a037a9e520d506c917b0286f904a538ee6f95063783939b4c9cf9307&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dweasel-0.17.4.0-installer.exe&response-content-type=application%2Foctet-stream",
|
||||
"img/png/RIME.png"));
|
||||
|
||||
flowPanel.Controls.Add(CreateAppCard(
|
||||
"PyDebloatX",
|
||||
"https://ghproxy.net/https://github.com/Teraskull/PyDebloatX/releases/download/1.12.0/PyDebloatX_setup.exe",
|
||||
"img/ico/PyDebloatX.ico"));
|
||||
|
||||
flowPanel.Controls.Add(CreateAppCard(
|
||||
"DropPoint",
|
||||
"https://ghproxy.net/https://github.com/GameGodS3/DropPoint/releases/download/v1.2.1/DropPoint-Setup-1.2.1.exe",
|
||||
"img/png/DropPoint.png"));
|
||||
|
||||
flowPanel.Controls.Add(CreateAppCard(
|
||||
"Dnest",
|
||||
"https://ghproxy.net/https://github.com/davidkane0526/Dnest/releases/download/V1.3.0/Dnest.exe",
|
||||
"img/png/Dnest.png"));
|
||||
|
||||
flowPanel.Controls.Add(CreateAppCard(
|
||||
"lockpass",
|
||||
"https://ghproxy.net/https://github.com/ftyszyx/lockpass/releases/download/v0.0.14/lockpass-0.0.14-win32-x64-setup.exe",
|
||||
"img/png/lockpass.png"));
|
||||
|
||||
flowPanel.Controls.Add(CreateAppCard(
|
||||
"WinMerge",
|
||||
"https://downloads.sourceforge.net/winmerge/WinMerge-2.16.48.2-x64-Setup.exe",
|
||||
"img/png/winmerge.png"));
|
||||
}
|
||||
|
||||
private FlowLayoutPanel downloadsFlowPanel = new FlowLayoutPanel();
|
||||
@@ -393,6 +451,7 @@ namespace AppStore
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
Logger.Log("应用程序启动");
|
||||
InitializeComponent();
|
||||
// 订阅下载管理器事件
|
||||
DownloadManager.Instance.DownloadAdded += OnDownloadAdded;
|
||||
@@ -429,6 +488,7 @@ namespace AppStore
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.Log($"添加新下载任务: {item.FileName}");
|
||||
downloadItems.Add(item);
|
||||
downloadsFlowPanel?.Controls.Add(item);
|
||||
}
|
||||
@@ -441,6 +501,7 @@ namespace AppStore
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.Log($"下载进度更新: {item.FileName}, 进度: {item.Progress}%");
|
||||
item.UpdateDisplay();
|
||||
}
|
||||
|
||||
@@ -452,6 +513,7 @@ namespace AppStore
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.Log($"下载完成: {item.FileName}, 状态: {item.Status}");
|
||||
item.UpdateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
50
SettingsForm.cs
Normal file
50
SettingsForm.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AppStore
|
||||
{
|
||||
public class SettingsForm : Form
|
||||
{
|
||||
private Button btnCleanLogs;
|
||||
|
||||
public SettingsForm()
|
||||
{
|
||||
this.Text = "设置";
|
||||
this.Size = new Size(400, 300);
|
||||
this.StartPosition = FormStartPosition.CenterParent;
|
||||
|
||||
btnCleanLogs = new Button();
|
||||
btnCleanLogs.Text = "清理日志";
|
||||
btnCleanLogs.Size = new Size(150, 40);
|
||||
btnCleanLogs.Location = new Point(120, 100);
|
||||
btnCleanLogs.Font = new Font("Microsoft YaHei", 10);
|
||||
btnCleanLogs.Click += (s, e) => CleanLogs();
|
||||
this.Controls.Add(btnCleanLogs);
|
||||
}
|
||||
|
||||
private void CleanLogs()
|
||||
{
|
||||
try
|
||||
{
|
||||
string logCleanerPath = Path.Combine("resource", "log_cleaner.exe");
|
||||
|
||||
if (File.Exists(logCleanerPath))
|
||||
{
|
||||
Process.Start(logCleanerPath);
|
||||
MessageBox.Show("日志清理程序已启动", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("日志清理程序未找到", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError("清理日志时出错", ex);
|
||||
MessageBox.Show($"清理日志时出错: {ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
img/ico/PyDebloatX.ico
Normal file
BIN
img/ico/PyDebloatX.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 104 KiB |
BIN
img/png/Dnest.png
Normal file
BIN
img/png/Dnest.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.8 KiB |
BIN
img/png/DropPoint.png
Normal file
BIN
img/png/DropPoint.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
BIN
img/png/Winmerge.png
Normal file
BIN
img/png/Winmerge.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
BIN
img/png/lockpass.png
Normal file
BIN
img/png/lockpass.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
41
log_cleaner.cpp
Normal file
41
log_cleaner.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
#include <chrono>
|
||||
namespace fs = std::filesystem;
|
||||
int main() {
|
||||
try {
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
// 定义日志目录路径
|
||||
fs::path logDir = "logs";
|
||||
size_t deletedCount = 0;
|
||||
size_t errorCount = 0;
|
||||
// 检查目录是否存在
|
||||
if (fs::exists(logDir) && fs::is_directory(logDir)) {
|
||||
// 遍历并删除所有日志文件
|
||||
for (const auto& entry : fs::directory_iterator(logDir)) {
|
||||
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++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::cout << "日志目录不存在,无需清理" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
|
||||
std::cout << "日志清理完成: " << std::endl;
|
||||
std::cout << "删除文件数: " << deletedCount << std::endl;
|
||||
std::cout << "错误数: " << errorCount << std::endl;
|
||||
std::cout << "耗时: " << duration.count() << " 毫秒" << std::endl;
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << "发生错误: " << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
48
logger.cs
Normal file
48
logger.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
namespace AppStore
|
||||
{
|
||||
public static class Logger
|
||||
{
|
||||
private static readonly string LogsDirectory = "logs";
|
||||
private static readonly object LockObject = new object();
|
||||
static Logger()
|
||||
{
|
||||
// 确保logs目录存在
|
||||
if (!Directory.Exists(LogsDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(LogsDirectory);
|
||||
}
|
||||
}
|
||||
public static void Log(string message)
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
try
|
||||
{
|
||||
string fileName = $"{DateTime.Now:yyyyMMddHHmmss}.log";
|
||||
string filePath = Path.Combine(LogsDirectory, fileName);
|
||||
using (StreamWriter writer = new StreamWriter(filePath, true, Encoding.UTF8))
|
||||
{
|
||||
writer.WriteLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] {message}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 日志记录失败时输出到控制台
|
||||
Console.WriteLine($"日志记录失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void LogError(string message, Exception? ex = null)
|
||||
{
|
||||
string errorMessage = $"ERROR: {message}";
|
||||
if (ex != null)
|
||||
{
|
||||
errorMessage += $"\nException: {ex}\nStackTrace: {ex.StackTrace}";
|
||||
}
|
||||
Log(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
resource/log_cleaner.exe
Normal file
BIN
resource/log_cleaner.exe
Normal file
Binary file not shown.
Reference in New Issue
Block a user