mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-25 03:09:54 +08:00
asf
This commit is contained in:
@@ -173,7 +173,7 @@ namespace System.Application.UI
|
||||
compositeDisposable.Add(ProxyService.Current.Dispose);
|
||||
compositeDisposable.Add(AuthService.Current.SaveEditNameAuthenticators);
|
||||
compositeDisposable.Add(SteamConnectService.Current.Dispose);
|
||||
compositeDisposable.Add(IArchiSteamFarmService.Instance.StopArchiSteamFarm);
|
||||
compositeDisposable.Add(IASFService.Instance.StopArchiSteamFarm);
|
||||
if (GeneralSettings.IsStartupAppMinimized.Value)
|
||||
{
|
||||
Program.IsMinimize = true;
|
||||
|
||||
+10
-10
@@ -19,7 +19,7 @@
|
||||
<TabControl TabStripPlacement="Left">
|
||||
<TabItem Header="ASF控制台">
|
||||
<Panel>
|
||||
<StackPanel Spacing="20" IsVisible="{ReflectionBinding Source={x:Static service:IArchiSteamFarmService.Instance},Path=!IsArchiSteamFarmRuning}"
|
||||
<StackPanel Spacing="20" IsVisible="{ReflectionBinding Source={x:Static service:IASFService.Instance},Path=!IsArchiSteamFarmRuning}"
|
||||
VerticalAlignment="Center">
|
||||
<StackPanel Orientation="Horizontal" Spacing="8" HorizontalAlignment="Center">
|
||||
<Ellipse Height="6" Width="6" Fill="#FF4F58" Margin="0 0 5 0" VerticalAlignment="Center"/>
|
||||
@@ -31,16 +31,16 @@
|
||||
HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<Grid IsVisible="{ReflectionBinding Source={x:Static service:IArchiSteamFarmService.Instance},Path=IsArchiSteamFarmRuning}"
|
||||
<Grid IsVisible="{ReflectionBinding Source={x:Static service:IASFService.Instance},Path=IsArchiSteamFarmRuning}"
|
||||
RowDefinitions="*,Auto">
|
||||
<TextBox x:Name="console" IsReadOnly="True" AcceptsReturn="True" TextWrapping="Wrap" Text="{ReflectionBinding Source={x:Static service:IArchiSteamFarmService.Instance},Path=ArchiSteamFarmOutText}"/>
|
||||
<TextBox x:Name="console" IsReadOnly="True" AcceptsReturn="True" TextWrapping="Wrap" Text="{ReflectionBinding Source={x:Static service:IASFService.Instance},Path=ArchiSteamFarmOutText}"/>
|
||||
<TextBox x:Name="CommandTextbox" Grid.Row="1" Watermark="输入指令后按下Enter执行"/>
|
||||
</Grid>
|
||||
</Panel>
|
||||
</TabItem>
|
||||
<TabItem Header="ASF Web UI">
|
||||
<Panel>
|
||||
<StackPanel Spacing="20" IsVisible="{ReflectionBinding Source={x:Static service:IArchiSteamFarmService.Instance},Path=!IsArchiSteamFarmRuning}"
|
||||
<StackPanel Spacing="20" IsVisible="{ReflectionBinding Source={x:Static service:IASFService.Instance},Path=!IsArchiSteamFarmRuning}"
|
||||
VerticalAlignment="Center">
|
||||
<StackPanel Orientation="Horizontal" Spacing="8" HorizontalAlignment="Center">
|
||||
<Ellipse Height="6" Width="6" Fill="#FF4F58" Margin="0 0 5 0" VerticalAlignment="Center"/>
|
||||
@@ -52,7 +52,7 @@
|
||||
HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<controls:WebView3 Url="{Binding WebUrl}" IsVisible="{ReflectionBinding Source={x:Static service:IArchiSteamFarmService.Instance},Path=IsArchiSteamFarmRuning}"/>
|
||||
<controls:WebView3 Url="{Binding WebUrl}" IsVisible="{ReflectionBinding Source={x:Static service:IASFService.Instance},Path=IsArchiSteamFarmRuning}"/>
|
||||
</Panel>
|
||||
</TabItem>
|
||||
|
||||
@@ -89,14 +89,14 @@
|
||||
|
||||
<WrapPanel>
|
||||
<TextBlock Text="ASF可执行文件路径:"/>
|
||||
<controls:ScrollingTextBlock x:Name="asfPath" Text="{ReflectionBinding Source={x:Static ms:ASFSettings.ArchiSteamFarmExePath},Path=Value,Mode=OneWay}" DockPanel.Dock="Right" IsVisible="{ReflectionBinding Source={x:Static service:IArchiSteamFarmService.Instance},Path=IsArchiSteamFarmExists,Mode=OneWay}"/>
|
||||
<controls:ScrollingTextBlock x:Name="asfPath" Text="{ReflectionBinding Source={x:Static ms:ASFSettings.ArchiSteamFarmExePath},Path=Value,Mode=OneWay}" DockPanel.Dock="Right" IsVisible="{ReflectionBinding Source={x:Static service:IASFService.Instance},Path=IsArchiSteamFarmExists,Mode=OneWay}"/>
|
||||
<controls:ScrollingTextBlock Text="{ReflectionBinding Path=Res.ASF_ExeNoExists,Source={x:Static resx:R.Current},Mode=OneWay}"
|
||||
IsVisible="{ReflectionBinding Source={x:Static service:IArchiSteamFarmService.Instance},Path=!IsArchiSteamFarmExists,Mode=OneWay}"/>
|
||||
IsVisible="{ReflectionBinding Source={x:Static service:IASFService.Instance},Path=!IsArchiSteamFarmExists,Mode=OneWay}"/>
|
||||
<!--<i:Interaction.Behaviors>
|
||||
<ia:DataTriggerBehavior Binding="{ReflectionBinding Source={x:Static service:IArchiSteamFarmService.Instance},Path=IsArchiSteamFarmExists,Mode=OneWay}" ComparisonCondition="Equal" Value="True">
|
||||
<ia:DataTriggerBehavior Binding="{ReflectionBinding Source={x:Static service:IASFService.Instance},Path=IsArchiSteamFarmExists,Mode=OneWay}" ComparisonCondition="Equal" Value="True">
|
||||
<ia:ChangePropertyAction TargetObject="{ReflectionBinding #asfPath}" PropertyName="Text" Value="{ReflectionBinding Source={x:Static ms:ASFSettings.ArchiSteamFarmExePath},Path=Value,Mode=OneWay}"/>
|
||||
</ia:DataTriggerBehavior>
|
||||
<ia:DataTriggerBehavior Binding="{ReflectionBinding Source={x:Static service:IArchiSteamFarmService.Instance},Path=IsArchiSteamFarmExists,Mode=OneWay}" ComparisonCondition="Equal" Value="False">
|
||||
<ia:DataTriggerBehavior Binding="{ReflectionBinding Source={x:Static service:IASFService.Instance},Path=IsArchiSteamFarmExists,Mode=OneWay}" ComparisonCondition="Equal" Value="False">
|
||||
<ia:ChangePropertyAction TargetObject="{ReflectionBinding #asfPath}" PropertyName="Text" Value="{ReflectionBinding Path=Res.ASF_ExeNoExists,Source={x:Static resx:R.Current},Mode=OneWay}"/>
|
||||
</ia:DataTriggerBehavior>
|
||||
</i:Interaction.Behaviors>-->
|
||||
@@ -110,7 +110,7 @@
|
||||
<StackPanel Spacing="10">
|
||||
<WrapPanel>
|
||||
<TextBlock Text="当前 ArchiSteamFarm 版本 : " VerticalAlignment="Center"></TextBlock>
|
||||
<TextBlock Text="{ReflectionBinding Source={x:Static service:IArchiSteamFarmService.Instance},Path=ArchiSteamFarmVersion}" VerticalAlignment="Center"></TextBlock>
|
||||
<TextBlock Text="{ReflectionBinding Source={x:Static service:IASFService.Instance},Path=ArchiSteamFarmVersion}" VerticalAlignment="Center"></TextBlock>
|
||||
</WrapPanel>
|
||||
<!--<TextBlock Text="最新 ArchiSteamFarm 版本 : " VerticalAlignment="Center"></TextBlock>
|
||||
<TextBlock Text="{ReflectionBinding Source={x:Static ms:ASFSettings.ArchiSteamFarmExePath},Path=Value,Mode=OneWay}" VerticalAlignment="Center"></TextBlock>-->
|
||||
|
||||
+4
-4
@@ -29,7 +29,7 @@ namespace System.Application.UI.Views.Pages
|
||||
{
|
||||
if (e.Key == Avalonia.Input.Key.Enter && !string.IsNullOrEmpty(commandTextbox.Text))
|
||||
{
|
||||
IArchiSteamFarmService.Instance.WirteLineCommand(commandTextbox.Text);
|
||||
IASFService.Instance.WirteLineCommand(commandTextbox.Text);
|
||||
commandTextbox.Text = "";
|
||||
}
|
||||
}
|
||||
@@ -46,15 +46,15 @@ namespace System.Application.UI.Views.Pages
|
||||
AllowMultiple = false,
|
||||
};
|
||||
|
||||
if (IArchiSteamFarmService.Instance.IsArchiSteamFarmExists)
|
||||
if (IASFService.Instance.IsArchiSteamFarmExists)
|
||||
{
|
||||
fileDialog.Directory = Path.GetDirectoryName(IArchiSteamFarmService.Instance.ArchiSteamFarmExePath);
|
||||
fileDialog.Directory = Path.GetDirectoryName(IASFService.Instance.ArchiSteamFarmExePath);
|
||||
}
|
||||
|
||||
var result = await fileDialog.ShowAsync(IDesktopAvaloniaAppService.Instance.MainWindow);
|
||||
if (result.Any_Nullable())
|
||||
{
|
||||
IArchiSteamFarmService.Instance.SetArchiSteamFarmExePath(result[0]);
|
||||
IASFService.Instance.SetArchiSteamFarmExePath(result[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,9 +116,9 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <returns></returns>
|
||||
public static IServiceCollection AddArchiSteamFarmService(this IServiceCollection services)
|
||||
public static IServiceCollection AddASFService(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<IArchiSteamFarmService, ArchiSteamFarmServiceImpl>();
|
||||
services.AddSingleton<IASFService, ASFServiceImpl>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -6,9 +6,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace System.Application.Services
|
||||
{
|
||||
public interface IArchiSteamFarmService
|
||||
public interface IASFService
|
||||
{
|
||||
public static IArchiSteamFarmService Instance => DI.Get<IArchiSteamFarmService>();
|
||||
public static IASFService Instance => DI.Get<IASFService>();
|
||||
|
||||
public string? ArchiSteamFarmExePath { get; }
|
||||
public string? ArchiSteamFarmConfigDirPath { get; }
|
||||
+2
-2
@@ -13,7 +13,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace System.Application.Services.Implementation
|
||||
{
|
||||
internal sealed class ArchiSteamFarmServiceImpl : ReactiveObject, IArchiSteamFarmService
|
||||
internal sealed class ASFServiceImpl : ReactiveObject, IASFService
|
||||
{
|
||||
readonly IDesktopPlatformService platformService;
|
||||
readonly IHttpService httpService;
|
||||
@@ -81,7 +81,7 @@ namespace System.Application.Services.Implementation
|
||||
private set => this.RaiseAndSetIfChanged(ref _IPCUrl, value);
|
||||
}
|
||||
|
||||
public ArchiSteamFarmServiceImpl(IDesktopPlatformService platform, IHttpService http, ICloudServiceClient client)
|
||||
public ASFServiceImpl(IDesktopPlatformService platform, IHttpService http, ICloudServiceClient client)
|
||||
{
|
||||
clientService = client;
|
||||
platformService = platform;
|
||||
@@ -409,7 +409,7 @@ namespace System.Application.Services
|
||||
|
||||
AuthService.AddOrUpdateSaveAuthenticators(new GAPAuthenticatorDTO
|
||||
{
|
||||
Name = name,
|
||||
Name = string.IsNullOrEmpty(name) ? "Steam (" + auth.AccountName + ")" : name,
|
||||
Value = auth,
|
||||
}, isLocal, password);
|
||||
return true;
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace System.Application.UI.ViewModels
|
||||
{
|
||||
public class ArchiSteamFarmPlusPageViewModel : TabItemViewModel
|
||||
{
|
||||
readonly IArchiSteamFarmService asfSerivce = DI.Get<IArchiSteamFarmService>();
|
||||
readonly IASFService asfSerivce = DI.Get<IASFService>();
|
||||
public override string Name
|
||||
{
|
||||
get => AppResources.ArchiSteamFarmPlus;
|
||||
@@ -29,14 +29,16 @@ namespace System.Application.UI.ViewModels
|
||||
|
||||
public void RunOrStopASF()
|
||||
{
|
||||
if (asfSerivce.IsArchiSteamFarmRuning)
|
||||
{
|
||||
asfSerivce.StopArchiSteamFarm();
|
||||
}
|
||||
else
|
||||
{
|
||||
asfSerivce.RunArchiSteamFarm();
|
||||
}
|
||||
//if (asfSerivce.IsArchiSteamFarmRuning)
|
||||
//{
|
||||
// asfSerivce.StopArchiSteamFarm();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// asfSerivce.RunArchiSteamFarm();
|
||||
//}
|
||||
|
||||
IArchiSteamFarmService.Instance.Start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,5 +72,16 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||
services.AddSingleton<IToastIntercept>(s => s.GetRequiredService<StartupToastIntercept>());
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加 asf 功能
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <returns></returns>
|
||||
public static IServiceCollection AddArchiSteamFarmService(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<IArchiSteamFarmService, ArchiSteamFarmServiceImpl>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using ReactiveUI;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace System.Application.Services
|
||||
{
|
||||
public interface IArchiSteamFarmService
|
||||
{
|
||||
public static IArchiSteamFarmService Instance => DI.Get<IArchiSteamFarmService>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 启动ASF
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
void Start(string[]? args = null);
|
||||
}
|
||||
}
|
||||
@@ -4,16 +4,18 @@ using System.Text;
|
||||
|
||||
namespace System.Application.Services.Implementation
|
||||
{
|
||||
public class ArchiSteamFarmServiceImpl
|
||||
public class ArchiSteamFarmServiceImpl : IArchiSteamFarmService
|
||||
{
|
||||
public void Init()
|
||||
public async void Start(string[]? args = null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
await ArchiSteamFarm.Program.Init(args).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Toast.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,6 +320,9 @@ namespace System.Application
|
||||
|
||||
// ASF Service
|
||||
services.AddArchiSteamFarmService();
|
||||
|
||||
// ASF Service
|
||||
services.AddASFService();
|
||||
#if StartupTrace
|
||||
StartupTrace.Restart("DI.ConfigureDemandServices.Steam");
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user