This commit is contained in:
辉鸭蛋
2025-01-12 15:28:01 +08:00
parent e06527ce85
commit 1325962b93
6 changed files with 82 additions and 2 deletions

View File

@@ -42,6 +42,7 @@
<ItemGroup>
<PackageReference Include="AvalonEdit" Version="6.3.0.90" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="LiteDB" Version="5.0.21" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />

View File

@@ -135,5 +135,5 @@ https://learn.microsoft.com/zh-cn/windows/win32/cimwin32prov/win32-systemenclosu
public bool { get; set; } = TouchpadManager.HasTouchInput();
public bool 2 { get; set; } = TouchpadManager.HasTouchInput2();
// public bool 是否存在触控屏2 { get; set; } = TouchpadManager.HasTouchInput2();
}

View File

@@ -0,0 +1,28 @@
namespace BetterGenshinImpact.Model.TosUpload;
public class FileUploadItem
{
// 文件路径
public string? FilePath { get; set; }
// 文件名
public string? ObjectKey { get; set; }
// 上传ID+
public string? UploadId { get; set; }
// 上传状态
public string? Status { get; set; }
}
public enum UploadStatus
{
// 未上传
NotUpload,
// 上传中
Uploading,
// 上传成功
UploadSuccess,
}

View File

@@ -0,0 +1,10 @@
namespace BetterGenshinImpact.Model.TosUpload;
public class FolderUploadItem
{
// 文件路径
public string? FilePath { get; set; }
// 上传状态
public string? Status { get; set; }
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Diagnostics;
using BetterGenshinImpact.Core.Config;
using BetterGenshinImpact.Model;
using LiteDB;
namespace BetterGenshinImpact.Service;
public class DbLiteService : Singleton<DbLiteService>
{
public LiteDatabase UserDb { get; set; } = new(Global.Absolute(@"User\User.db"));
public void Upsert<T>(string collectionName,string uniqueProperty, T entity) where T : new()
{
var collection = UserDb.GetCollection<T>(collectionName);
var idProperty = typeof(T).GetProperty(uniqueProperty);
if (idProperty == null)
{
throw new ArgumentException("Entity must have an Id property");
}
var idValue = idProperty.GetValue(entity);
if (idValue == null)
{
throw new ArgumentException("Id property cannot be null");
}
var existingEntity = collection.FindOne(Query.EQ(uniqueProperty, new BsonValue(idValue)));
if (existingEntity != null)
{
collection.Update(entity);
Debug.WriteLine($"更新数据");
}
else
{
collection.Insert(entity);
Debug.WriteLine($"写入数据");
}
}
}

View File

@@ -130,7 +130,7 @@
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding IsUploadSuccess}" Value="True">
<Setter Property="Text" Value="成功" />
<Setter Property="Text" Value="已上传" />
<Setter Property="Foreground" Value="Green" />
</DataTrigger>
<DataTrigger Binding="{Binding IsUploading}" Value="True">