mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-28 05:56:52 +08:00
1
This commit is contained in:
@@ -241,67 +241,64 @@ namespace System.Application.Services
|
||||
}
|
||||
}
|
||||
|
||||
this.WhenAnyValue(v => v.ProxyScripts)
|
||||
.Subscribe(script => script?
|
||||
.Connect()
|
||||
.AutoRefresh(x => x.Enable)
|
||||
.WhenPropertyChanged(x => x.Enable, false)
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
if (EnableProxyScripts != null)
|
||||
{
|
||||
ProxySettings.ScriptsStatus.Value = EnableProxyScripts.Where(w => w?.LocalId > 0).Select(k => k.LocalId).ToList();
|
||||
}
|
||||
}));
|
||||
#endregion
|
||||
}
|
||||
public async void BasicsInfo()
|
||||
{
|
||||
var basicsInfo = await ICloudServiceClient.Instance.Script.Basics();
|
||||
if (basicsInfo.Code == ApiResponseCode.OK && basicsInfo.Content != null)
|
||||
{
|
||||
var basicsItem = ProxyScripts.Items.FirstOrDefault(x => x.Id == Guid.Parse("00000000-0000-0000-0000-000000000001"));
|
||||
if (basicsItem != null)
|
||||
{
|
||||
if (basicsItem.Version != basicsInfo.Content.Version && basicsInfo.Content.UpdateLink != null)
|
||||
{
|
||||
var index = ProxyScripts.Items.IndexOf(basicsItem);
|
||||
basicsItem.IsUpdate = true;
|
||||
basicsItem.UpdateLink = basicsInfo.Content.UpdateLink;
|
||||
basicsItem.NewVersion = basicsInfo.Content.Version;
|
||||
ProxyScripts.ReplaceAt(index, basicsItem);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (basicsInfo.Content.UpdateLink != null)
|
||||
{
|
||||
var jspath = await DI.Get<IScriptManagerService>().DownloadScript(basicsInfo.Content.UpdateLink);
|
||||
if (jspath.state)
|
||||
{
|
||||
var build = await DI.Get<IScriptManagerService>().AddScriptAsync(jspath.path, build: false, order: 1, deleteFile: true, pid: basicsInfo.Content.Id);
|
||||
if (build.state)
|
||||
{
|
||||
if (build.model != null)
|
||||
ProxyScripts.Insert(0, build.model);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void StartTiming()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
Thread.CurrentThread.IsBackground = true;
|
||||
while (ProxyStatus)
|
||||
{
|
||||
AccelerateTime = AccelerateTime.AddSeconds(1);
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.WhenAnyValue(v => v.ProxyScripts)
|
||||
.Subscribe(script => script?
|
||||
.Connect()
|
||||
.AutoRefresh(x => x.Enable)
|
||||
.WhenPropertyChanged(x => x.Enable, false)
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
if (EnableProxyScripts != null)
|
||||
{
|
||||
ProxySettings.ScriptsStatus.Value = EnableProxyScripts.Where(w => w?.LocalId > 0).Select(k => k.LocalId).ToList();
|
||||
}
|
||||
}));
|
||||
#endregion
|
||||
}
|
||||
public async void BasicsInfo()
|
||||
{
|
||||
var basicsInfo = await ICloudServiceClient.Instance.Script.Basics();
|
||||
if (basicsInfo.Code == ApiResponseCode.OK && basicsInfo.Content != null)
|
||||
{
|
||||
var basicsItem = ProxyScripts.Items.FirstOrDefault(x => x.Id == Guid.Parse("00000000-0000-0000-0000-000000000001"));
|
||||
if (basicsItem != null)
|
||||
{
|
||||
if (basicsItem.Version != basicsInfo.Content.Version)
|
||||
{
|
||||
var index = ProxyScripts.Items.IndexOf(basicsItem);
|
||||
basicsItem.IsUpdate = true;
|
||||
basicsItem.UpdateLink = basicsInfo.Content.UpdateLink;
|
||||
basicsItem.NewVersion = basicsInfo.Content.Version;
|
||||
ProxyScripts.ReplaceAt(index, basicsItem);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var jspath = await DI.Get<IScriptManagerService>().DownloadScript(basicsInfo.Content.UpdateLink);
|
||||
if (jspath.state)
|
||||
{
|
||||
var build = await DI.Get<IScriptManagerService>().AddScriptAsync(jspath.path, build: false, order: 1, deleteFile: true, pid: basicsInfo.Content.Id);
|
||||
if (build.state)
|
||||
{
|
||||
if (build.model != null)
|
||||
ProxyScripts.Insert(0, build.model);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void StartTiming()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
Thread.CurrentThread.IsBackground = true;
|
||||
while (ProxyStatus)
|
||||
{
|
||||
AccelerateTime = AccelerateTime.AddSeconds(1);
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace System.Application.Models
|
||||
[MPKey(1)]
|
||||
[N_JsonProperty("1")]
|
||||
[S_JsonProperty("1")]
|
||||
public string? Version { get; set; } = string.Empty;
|
||||
public string Version { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 更新地址
|
||||
@@ -26,7 +26,7 @@ namespace System.Application.Models
|
||||
[MPKey(2)]
|
||||
[N_JsonProperty("2")]
|
||||
[S_JsonProperty("2")]
|
||||
public string? UpdateLink { get; set; } = string.Empty;
|
||||
public string UpdateLink { get; set; } = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -35,7 +35,7 @@ namespace System.Application.Models
|
||||
[MPKey(3)]
|
||||
[N_JsonProperty("3")]
|
||||
[S_JsonProperty("3")]
|
||||
public string? Description { get; set; } = string.Empty;
|
||||
public string? Description { get; set; }
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user