parent
14372d1e00
commit
36ba0eadd5
42
App.xaml.cs
42
App.xaml.cs
|
|
@ -1,4 +1,6 @@
|
|||
using System.IO;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using HeBianGu.Base.WpfBase;
|
||||
|
|
@ -6,14 +8,10 @@ using HeBianGu.Control.Guide;
|
|||
using HeBianGu.Control.ThemeSet;
|
||||
using HeBianGu.General.WpfControlLib;
|
||||
using HeBianGu.Service.Mvp;
|
||||
using HeBianGu.Systems.About;
|
||||
using HeBianGu.Systems.Identity;
|
||||
using HeBianGu.Systems.Setting;
|
||||
using Hopetry.Services;
|
||||
using SystemSetting = FileUploader.Models.SystemSetting;
|
||||
using System.Configuration;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace HeBianGu.App.Disk
|
||||
{
|
||||
|
|
@ -27,6 +25,7 @@ namespace HeBianGu.App.Disk
|
|||
return new ShellWindow();
|
||||
}
|
||||
|
||||
|
||||
protected override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
base.ConfigureServices(services);
|
||||
|
|
@ -46,8 +45,12 @@ namespace HeBianGu.App.Disk
|
|||
{
|
||||
setting.TaskCount = 3;
|
||||
}
|
||||
|
||||
//minioService.MirrorAsync1(bucketName, setting.SyncDir, setting.TaskCount);
|
||||
minioService.RealTimeListen(bucketName, setting.SyncDir);
|
||||
if (SyncSetting.Instance.IsOn)
|
||||
{
|
||||
minioService.RealTimeListen(bucketName, setting.SyncDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +137,11 @@ namespace HeBianGu.App.Disk
|
|||
protected override void Configure(IApplicationBuilder app)
|
||||
{
|
||||
base.Configure(app);
|
||||
app.UseSetting(x => { x.Settings.Add(MySetting.Instance); });
|
||||
app.UseSetting(x =>
|
||||
{
|
||||
x.Settings.Add(MySetting.Instance);
|
||||
x.Settings.Add(SyncSetting.Instance);
|
||||
});
|
||||
app.UseStyle();
|
||||
//app.UseSettingDefault();
|
||||
// Do:设置默认主题
|
||||
|
|
@ -158,7 +165,26 @@ namespace HeBianGu.App.Disk
|
|||
}
|
||||
}
|
||||
|
||||
[Displayer(Name = "关机设置", GroupName = "是否关机")]
|
||||
|
||||
[Displayer(Name = "同步设置", GroupName = "通用设置")]
|
||||
public class SyncSetting : LazySettingInstance<SyncSetting>
|
||||
{
|
||||
private bool _ison;
|
||||
|
||||
[DefaultValue(false)]
|
||||
[Display(Name = "自动同步")]
|
||||
public bool IsOn
|
||||
{
|
||||
get { return _ison; }
|
||||
set
|
||||
{
|
||||
_ison = value;
|
||||
RaisePropertyChanged("IsOn");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Displayer(Name = "关机设置", GroupName = "通用设置")]
|
||||
public class MySetting : LazySettingInstance<MySetting>
|
||||
{
|
||||
private bool _ison;
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ public class SyncViewModel : MvcViewModelBase
|
|||
_serializerService.Save("./settings.xml", _setting);
|
||||
}
|
||||
|
||||
private async Task<object> SyncDataQuick()
|
||||
private async Task SyncDataQuick()
|
||||
{
|
||||
return _minioService.MirrorAsync1(_minioService._bucketName, SyncDir, _taskCount);
|
||||
await Task.Run(async () => await _minioService.MirrorAsync1(_minioService._bucketName, SyncDir, _taskCount));
|
||||
}
|
||||
|
||||
protected override void Loaded(string args)
|
||||
|
|
@ -87,7 +87,7 @@ public class SyncViewModel : MvcViewModelBase
|
|||
|
||||
public RelayCommand SyncData { get; set; }
|
||||
public RelayCommand ComboBox_SelectionChanged { get; set; }
|
||||
public RelayCommand OpenTargetDirCommand { get; set; }
|
||||
public RelayCommand OpenTargetDirCommand { get; set; }
|
||||
|
||||
|
||||
public class RelayCommand : ICommand
|
||||
|
|
@ -114,7 +114,6 @@ public class SyncViewModel : MvcViewModelBase
|
|||
|
||||
private async Task Button_OpenTargetDir()
|
||||
{
|
||||
|
||||
// 验证目录是否存在
|
||||
if (!Directory.Exists(SyncDir))
|
||||
{
|
||||
|
|
@ -128,16 +127,17 @@ public class SyncViewModel : MvcViewModelBase
|
|||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "explorer.exe",
|
||||
Arguments = $"\"{SyncDir}\"", // 处理路径中的空格
|
||||
Arguments = $"\"{SyncDir}\"", // 处理路径中的空格
|
||||
UseShellExecute = true
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"打开失败:{ex.Message}", "错误",
|
||||
MessageBox.Show($"打开失败:{ex.Message}", "错误",
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ButtonBase_OnClick()
|
||||
{
|
||||
CommonOpenFileDialog dialog = new CommonOpenFileDialog
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
/*
|
||||
{
|
||||
/*{
|
||||
"Minio": {
|
||||
"Endpoint": "123.132.248.154:9107",
|
||||
"AccessKey": "oZNgo25pNXnKFV9oKGh4",
|
||||
|
|
@ -14,4 +13,4 @@
|
|||
"SecretKey": "XHlrNeCHK0xf8y2Fo0K5OKyDeaI2ItfEsFbzQPFk",
|
||||
"BucketName": "demo"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue