mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-25 10:05:49 +08:00
init db
This commit is contained in:
@@ -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" />
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
28
BetterGenshinImpact/Model/TosUpload/FileUploadItem.cs
Normal file
28
BetterGenshinImpact/Model/TosUpload/FileUploadItem.cs
Normal 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,
|
||||
}
|
||||
10
BetterGenshinImpact/Model/TosUpload/FolderUploadItem.cs
Normal file
10
BetterGenshinImpact/Model/TosUpload/FolderUploadItem.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace BetterGenshinImpact.Model.TosUpload;
|
||||
|
||||
public class FolderUploadItem
|
||||
{
|
||||
// 文件路径
|
||||
public string? FilePath { get; set; }
|
||||
|
||||
// 上传状态
|
||||
public string? Status { get; set; }
|
||||
}
|
||||
41
BetterGenshinImpact/Service/DbLiteService.cs
Normal file
41
BetterGenshinImpact/Service/DbLiteService.cs
Normal 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($"写入数据");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user