mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-25 10:05:49 +08:00
++
This commit is contained in:
@@ -105,7 +105,7 @@ public class TosClientHelper
|
||||
|
||||
var fileUploadItem = new FileUploadItem
|
||||
{
|
||||
Id = objectKey,
|
||||
Id = localFileName,
|
||||
FilePath = localFileName,
|
||||
ObjectKey = objectKey,
|
||||
Status = UploadStatus.Uploading.ToString()
|
||||
@@ -164,7 +164,7 @@ public class TosClientHelper
|
||||
|
||||
var fileUploadItem = new FileUploadItem
|
||||
{
|
||||
Id = objectKey,
|
||||
Id = localFileName,
|
||||
FilePath = localFileName,
|
||||
ObjectKey = objectKey,
|
||||
Status = UploadStatus.Uploading.ToString()
|
||||
@@ -172,7 +172,7 @@ public class TosClientHelper
|
||||
|
||||
// 检查是否有未完成的上传
|
||||
var collection = _dbService.UserDb.GetCollection<FileUploadItem>("FileUploads");
|
||||
var existingItem = collection.FindById(objectKey);
|
||||
var existingItem = collection.FindById(localFileName);
|
||||
if (existingItem?.UploadId != null)
|
||||
{
|
||||
uploadID = existingItem.UploadId;
|
||||
@@ -382,7 +382,7 @@ public class TosClientHelper
|
||||
|
||||
var fileUploadItem = new FileUploadItem
|
||||
{
|
||||
Id = objectKey,
|
||||
Id = localFileName,
|
||||
FilePath = localFileName,
|
||||
ObjectKey = objectKey,
|
||||
UploadId = uploadID,
|
||||
|
||||
@@ -9,6 +9,7 @@ using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.Helpers.Upload;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.RegularExpressions;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -74,6 +75,22 @@ public partial class KeyMouseScriptItem : ObservableObject
|
||||
"", "任务一", "任务二", "任务三", "任务四", "任务五",
|
||||
"任务六", "任务七", "任务八", "任务九"
|
||||
];
|
||||
|
||||
public bool CanDelete
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsUploading)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (IsUploadSuccess || IsPartiallyUploaded)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private string FormatSpeed(double bytesPerSecond)
|
||||
{
|
||||
@@ -125,9 +142,27 @@ public partial class KeyMouseScriptItem : ObservableObject
|
||||
{
|
||||
try
|
||||
{
|
||||
var remotePath = GetRemotePath(file);
|
||||
var fileUploadItem = collection.FindById(remotePath);
|
||||
// var remotePath = GetRemotePath(file);
|
||||
|
||||
var fileUploadItem = collection.FindById(file);
|
||||
// var fileUploadItem = collection.FindOne(Query.EQ("FilePath", file));
|
||||
|
||||
if (fileUploadItem == null)
|
||||
{
|
||||
allFilesUploaded = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 取出 ObjectKey 中的 SelectedTask
|
||||
// 匹配 "任务一" 到 "任务九" 的正则表达式
|
||||
string pattern = @"任务[一二三四五六七八九]";
|
||||
string text = "这是任务一的内容,任务二的内容...";
|
||||
Match match = Regex.Match(fileUploadItem.ObjectKey, pattern);
|
||||
if (match.Success)
|
||||
{
|
||||
SelectedTask = match.Value; // 例如: "任务一"
|
||||
}
|
||||
|
||||
if (fileUploadItem?.Status == UploadStatus.UploadSuccess.ToString())
|
||||
{
|
||||
hasUploadedFiles = true;
|
||||
@@ -170,9 +205,9 @@ public partial class KeyMouseScriptItem : ObservableObject
|
||||
// 提前验证用户信息,避免开始上传后才发现问题
|
||||
_ = GetRemotePath(Path);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
await MessageBox.ErrorAsync("请先设置用户名和UID");
|
||||
await MessageBox.ErrorAsync(e.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -310,6 +345,8 @@ public partial class KeyMouseScriptItem : ObservableObject
|
||||
|
||||
await Task.Delay(100);
|
||||
}
|
||||
// 刷新上传状态
|
||||
InitializeUploadStatus();
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
@@ -320,9 +357,9 @@ public partial class KeyMouseScriptItem : ObservableObject
|
||||
// 提前验证用户信息,避免开始上传后才发现问题
|
||||
_ = GetRemotePath(Path);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
await MessageBox.ErrorAsync("请先设置用户名和UID");
|
||||
await MessageBox.ErrorAsync(e.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -363,7 +400,7 @@ public partial class KeyMouseScriptItem : ObservableObject
|
||||
tosClient.DeleteObject(remotePath);
|
||||
|
||||
// 删除数据库中的记录
|
||||
collection.Delete(remotePath);
|
||||
collection.Delete(file);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -375,6 +412,8 @@ public partial class KeyMouseScriptItem : ObservableObject
|
||||
// 重置上传状态
|
||||
IsUploadSuccess = false;
|
||||
UploadProgress = 0;
|
||||
|
||||
InitializeUploadStatus();
|
||||
_logger.LogDebug($"{dirName} 删除完成");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
10
BetterGenshinImpact/Model/TosUpload/KmItem.cs
Normal file
10
BetterGenshinImpact/Model/TosUpload/KmItem.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace BetterGenshinImpact.Model.TosUpload;
|
||||
|
||||
public class KmItem
|
||||
{
|
||||
// 与 目录名 相同
|
||||
public string? Id { get; set; }
|
||||
|
||||
// selectedTask
|
||||
public string? SelectedTask { get; set; }
|
||||
}
|
||||
@@ -39,11 +39,11 @@
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
|
||||
<ui:TextBlock Grid.Column="0"
|
||||
FontTypography="BodyStrong"
|
||||
Text="键鼠录制回放功能" />
|
||||
|
||||
|
||||
<ui:TextBlock Grid.Column="1"
|
||||
Margin="12,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
@@ -61,14 +61,14 @@
|
||||
<ColumnDefinition Width="200" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
|
||||
<ui:TextBlock Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
Text="用户名:" />
|
||||
<ui:TextBox Grid.Column="1"
|
||||
PlaceholderText="请输入用户名"
|
||||
Text="{Binding Config.CommonConfig.UserName, Mode=TwoWay}" />
|
||||
|
||||
|
||||
<ui:TextBlock Grid.Column="3"
|
||||
VerticalAlignment="Center"
|
||||
Text="UID:" />
|
||||
@@ -104,7 +104,7 @@
|
||||
Icon="{ui:SymbolIcon Stop24}"
|
||||
IsEnabled="{Binding IsRecording}" />
|
||||
<Separator Width="20" Opacity="0" />
|
||||
<ui:ToggleSwitch
|
||||
<ui:ToggleSwitch
|
||||
Content="主界面切换识别"
|
||||
IsChecked="{Binding Config.RecordConfig.PaimonSwitchEnabled, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
@@ -170,14 +170,14 @@
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn Width="{Binding ElementName=Col4, Path=ActualWidth}"
|
||||
<GridViewColumn Width="{Binding ElementName=Col4, Path=ActualWidth}"
|
||||
Header="上传操作">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ui:Button x:Name="UploadButton"
|
||||
Command="{Binding UploadCommand}"
|
||||
Visibility="{Binding IsUploading, Converter={StaticResource BooleanToVisibilityRevertConverter}}">
|
||||
Command="{Binding UploadCommand}"
|
||||
Visibility="{Binding IsUploading, Converter={StaticResource BooleanToVisibilityRevertConverter}}">
|
||||
<ui:Button.Style>
|
||||
<Style TargetType="ui:Button" BasedOn="{StaticResource {x:Type ui:Button}}">
|
||||
<Setter Property="Content" Value="上传" />
|
||||
@@ -191,19 +191,39 @@
|
||||
</Style>
|
||||
</ui:Button.Style>
|
||||
</ui:Button>
|
||||
|
||||
|
||||
<ui:Button Command="{Binding StopUploadCommand}"
|
||||
Content="停止"
|
||||
Icon="{ui:SymbolIcon Stop24}"
|
||||
Visibility="{Binding IsUploading, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
|
||||
Content="停止"
|
||||
Icon="{ui:SymbolIcon Stop24}"
|
||||
Visibility="{Binding IsUploading, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
|
||||
<ui:Button Command="{Binding DeleteUploadedFilesCommand}"
|
||||
Content="撤销上传"
|
||||
Icon="{ui:SymbolIcon Delete24}"
|
||||
Margin="5,0,0,0">
|
||||
Content="撤销上传"
|
||||
Icon="{ui:SymbolIcon Delete24}"
|
||||
Margin="5,0,0,0">
|
||||
<ui:Button.Style>
|
||||
<Style TargetType="ui:Button" BasedOn="{StaticResource {x:Type ui:Button}}">
|
||||
<Style.Triggers>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsUploading}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="IsEnabled" Value="False" />
|
||||
</MultiDataTrigger>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsUploading}" Value="False" />
|
||||
<Condition Binding="{Binding IsUploadSuccess}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="IsEnabled" Value="True" />
|
||||
</MultiDataTrigger>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsUploading}" Value="False" />
|
||||
<Condition Binding="{Binding IsPartiallyUploaded}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="IsEnabled" Value="True" />
|
||||
</MultiDataTrigger>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsUploading}" Value="False" />
|
||||
@@ -216,9 +236,9 @@
|
||||
</Style>
|
||||
</ui:Button.Style>
|
||||
</ui:Button>
|
||||
|
||||
|
||||
<ui:TextBlock Margin="5,0,0,0"
|
||||
VerticalAlignment="Center">
|
||||
VerticalAlignment="Center">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Style.Triggers>
|
||||
|
||||
Reference in New Issue
Block a user