mirror of
https://github.com/denglihong2007/CRSim
synced 2026-08-13 04:55:43 +08:00
feat: #203 添加插件市场
This commit is contained in:
@@ -1,16 +1,41 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CRSim.Core.Abstractions;
|
||||
using CRSim.Core.Enums;
|
||||
using Downloader;
|
||||
|
||||
namespace CRSim.Core.Models.Plugin;
|
||||
public partial class PluginInfo : ObservableRecipient
|
||||
{
|
||||
//private DownloadProgress? _downloadProgress;
|
||||
//private bool _isAvailableOnMarket = false;
|
||||
public DownloadService? DownloadService;
|
||||
|
||||
[ObservableProperty]
|
||||
private int _downloadProgress = 0;
|
||||
|
||||
public bool IsAvailableOnMarket => IPluginService.OnlinePlugins.Any(x => x.Manifest.Id == Manifest.Id);
|
||||
|
||||
public bool IsUpdateAvailable
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsAvailableOnMarket)
|
||||
{
|
||||
if(IPluginService.OnlinePlugins.Where(x => x.Manifest.Id == Manifest.Id).FirstOrDefault() is PluginInfo onlinePlugin)
|
||||
{
|
||||
return onlinePlugin.Manifest.Version != Manifest.Version;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private PluginManifest _manifest = new();
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _restartRequired = false;
|
||||
|
||||
public PluginLoadStatus LoadStatus { get; internal set; } = PluginLoadStatus.NotLoaded;
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get
|
||||
@@ -32,6 +57,7 @@ public partial class PluginInfo : ObservableRecipient
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string PluginFolderPath { get; internal set; } = "";
|
||||
public string RealIconPath { get; set; } = "";
|
||||
public bool IsUninstalling
|
||||
@@ -45,17 +71,18 @@ public partial class PluginInfo : ObservableRecipient
|
||||
var path = Path.Combine(PluginFolderPath, ".uninstall");
|
||||
if (value)
|
||||
{
|
||||
RestartRequired = true;
|
||||
File.WriteAllText(path, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
RestartRequired = false;
|
||||
File.Delete(path);
|
||||
}
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
public Exception? Exception { get; internal set; }
|
||||
//private bool _isUpdateAvailable = false;
|
||||
|
||||
[ObservableProperty]
|
||||
private StyleInfo? styleInfo;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace CRSim.Core.Models.Plugin;
|
||||
|
||||
@@ -11,50 +12,54 @@ public class PluginManifest
|
||||
/// 入口程序集。加载插件时,将在此入口程序集中搜索插件类。
|
||||
/// </summary>
|
||||
/// <example>MyPlugin.dll</example>
|
||||
[JsonPropertyName("entranceAssembly")]
|
||||
public string EntranceAssembly { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 插件显示名称。
|
||||
/// </summary>
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 插件ID。
|
||||
/// </summary>
|
||||
[JsonPropertyName("id")]
|
||||
public string Id { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 插件图标路径。默认为icon.png。
|
||||
/// </summary>
|
||||
public string Icon { get; set; } = "icon.png";
|
||||
|
||||
/// <summary>
|
||||
/// 插件自述。
|
||||
/// </summary>
|
||||
[JsonPropertyName("description")]
|
||||
public string Description { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 项目 Url
|
||||
/// </summary>
|
||||
[JsonPropertyName("url")]
|
||||
public string? Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 插件版本
|
||||
/// </summary>
|
||||
[JsonPropertyName("version")]
|
||||
public string Version { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 插件目标 CRSim 版本
|
||||
/// </summary>
|
||||
[JsonPropertyName("apiVersion")]
|
||||
public string ApiVersion { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 插件作者
|
||||
/// </summary>
|
||||
[JsonPropertyName("author")]
|
||||
public string Author { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 插件类型
|
||||
/// </summary>
|
||||
[JsonPropertyName("type")]
|
||||
public string Type { get; set; } = "";
|
||||
}
|
||||
Reference in New Issue
Block a user