mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
@@ -55,18 +55,22 @@ namespace Wox.Core.Plugin
|
|||||||
{
|
{
|
||||||
ValidateUserDirectory();
|
ValidateUserDirectory();
|
||||||
|
|
||||||
// todo happlebao temp hack to let MainVM to register ResultsUpdated event
|
|
||||||
_metadatas = PluginConfig.Parse(Directories);
|
|
||||||
AllPlugins = PluginsLoader.CSharpPlugins(_metadatas).ToList();
|
|
||||||
}
|
}
|
||||||
public static void InitializePlugins(IPublicAPI api, PluginsSettings settings)
|
|
||||||
{
|
|
||||||
_settings = settings;
|
|
||||||
var plugins = PluginsLoader.PythonPlugins(_metadatas, _settings.PythonDirectory);
|
|
||||||
var executable_plugins = PluginsLoader.ExecutablePlugins(_metadatas);
|
|
||||||
AllPlugins = AllPlugins.Concat(plugins).Concat(executable_plugins).ToList();
|
|
||||||
_settings.UpdatePluginSettings(AllPlugins);
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// because InitializePlugins needs API, so LoadPlugins needs to be called first
|
||||||
|
/// todo happlebao The API should be removed
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="settings"></param>
|
||||||
|
public static void LoadPlugins(PluginsSettings settings)
|
||||||
|
{
|
||||||
|
_metadatas = PluginConfig.Parse(Directories);
|
||||||
|
_settings = settings;
|
||||||
|
AllPlugins = PluginsLoader.Plugins(_metadatas, _settings);
|
||||||
|
_settings.UpdatePluginSettings(AllPlugins);
|
||||||
|
}
|
||||||
|
public static void InitializePlugins(IPublicAPI api)
|
||||||
|
{
|
||||||
//load plugin i18n languages
|
//load plugin i18n languages
|
||||||
ResourceMerger.UpdatePluginLanguages();
|
ResourceMerger.UpdatePluginLanguages();
|
||||||
|
|
||||||
@@ -149,7 +153,7 @@ namespace Wox.Core.Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//happlebao todo prevent plugin initial when plugin is disabled
|
//happlebao todo dynamic release corresponding dll / exe / process
|
||||||
public static void DisablePlugin(PluginPair plugin)
|
public static void DisablePlugin(PluginPair plugin)
|
||||||
{
|
{
|
||||||
var actionKeywords = plugin.Metadata.ActionKeywords;
|
var actionKeywords = plugin.Metadata.ActionKeywords;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Wox.Core.UserSettings;
|
||||||
using Wox.Infrastructure.Exception;
|
using Wox.Infrastructure.Exception;
|
||||||
using Wox.Infrastructure.Logger;
|
using Wox.Infrastructure.Logger;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
@@ -15,6 +16,16 @@ namespace Wox.Core.Plugin
|
|||||||
public const string Python = "python";
|
public const string Python = "python";
|
||||||
public const string PythonExecutable = "pythonw.exe";
|
public const string PythonExecutable = "pythonw.exe";
|
||||||
|
|
||||||
|
public static List<PluginPair> Plugins(List<PluginMetadata> source, PluginsSettings settings)
|
||||||
|
{
|
||||||
|
var metadatas = source.Where(m => !settings.Plugins[m.ID].Disabled).ToList();
|
||||||
|
var csharpPlugins = CSharpPlugins(metadatas).ToList();
|
||||||
|
var pythonPlugins = PythonPlugins(metadatas, settings.PythonDirectory);
|
||||||
|
var executablePlugins = ExecutablePlugins(metadatas);
|
||||||
|
var plugins = csharpPlugins.Concat(pythonPlugins).Concat(executablePlugins).ToList();
|
||||||
|
return plugins;
|
||||||
|
}
|
||||||
|
|
||||||
public static IEnumerable<PluginPair> CSharpPlugins(List<PluginMetadata> source)
|
public static IEnumerable<PluginPair> CSharpPlugins(List<PluginMetadata> source)
|
||||||
{
|
{
|
||||||
var plugins = new List<PluginPair>();
|
var plugins = new List<PluginPair>();
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ using System.Diagnostics;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Wox.Core;
|
using Wox.Core;
|
||||||
using Wox.Core.Plugin;
|
using Wox.Core.Plugin;
|
||||||
|
using Wox.Core.UserSettings;
|
||||||
using Wox.Helper;
|
using Wox.Helper;
|
||||||
using Wox.Infrastructure.Image;
|
using Wox.Infrastructure.Image;
|
||||||
|
using Wox.Infrastructure.Storage;
|
||||||
using Wox.ViewModel;
|
using Wox.ViewModel;
|
||||||
using Stopwatch = Wox.Infrastructure.Stopwatch;
|
using Stopwatch = Wox.Infrastructure.Stopwatch;
|
||||||
|
|
||||||
@@ -38,11 +40,15 @@ namespace Wox
|
|||||||
|
|
||||||
ImageLoader.PreloadImages();
|
ImageLoader.PreloadImages();
|
||||||
|
|
||||||
var vm = new MainViewModel();
|
var storage = new JsonStrorage<Settings>();
|
||||||
var pluginsSettings = vm._settings.PluginSettings;
|
var settings = storage.Load();
|
||||||
var window = new MainWindow(vm._settings, vm);
|
|
||||||
API = new PublicAPIInstance(vm._settings, vm);
|
PluginManager.LoadPlugins(settings.PluginSettings);
|
||||||
PluginManager.InitializePlugins(API, pluginsSettings);
|
var vm = new MainViewModel(settings, storage);
|
||||||
|
var pluginsSettings = settings.PluginSettings;
|
||||||
|
var window = new MainWindow(settings, vm);
|
||||||
|
API = new PublicAPIInstance(settings, vm);
|
||||||
|
PluginManager.InitializePlugins(API);
|
||||||
|
|
||||||
RegisterExitEvents();
|
RegisterExitEvents();
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,7 @@ namespace Wox.ViewModel
|
|||||||
private readonly JsonStrorage<QueryHistory> _queryHistoryStorage;
|
private readonly JsonStrorage<QueryHistory> _queryHistoryStorage;
|
||||||
private readonly JsonStrorage<UserSelectedRecord> _userSelectedRecordStorage;
|
private readonly JsonStrorage<UserSelectedRecord> _userSelectedRecordStorage;
|
||||||
private readonly JsonStrorage<TopMostRecord> _topMostRecordStorage;
|
private readonly JsonStrorage<TopMostRecord> _topMostRecordStorage;
|
||||||
// todo happlebao this field should be private in the future
|
private readonly Settings _settings;
|
||||||
public readonly Settings _settings;
|
|
||||||
private readonly QueryHistory _queryHistory;
|
private readonly QueryHistory _queryHistory;
|
||||||
private readonly UserSelectedRecord _userSelectedRecord;
|
private readonly UserSelectedRecord _userSelectedRecord;
|
||||||
private readonly TopMostRecord _topMostRecord;
|
private readonly TopMostRecord _topMostRecord;
|
||||||
@@ -56,15 +55,15 @@ namespace Wox.ViewModel
|
|||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
|
|
||||||
public MainViewModel()
|
public MainViewModel(Settings settings, JsonStrorage<Settings> storage)
|
||||||
{
|
{
|
||||||
_saved = false;
|
_saved = false;
|
||||||
_queryTextBeforeLoadContextMenu = "";
|
_queryTextBeforeLoadContextMenu = "";
|
||||||
_queryText = "";
|
_queryText = "";
|
||||||
_lastQuery = new Query();
|
_lastQuery = new Query();
|
||||||
|
|
||||||
_settingsStorage = new JsonStrorage<Settings>();
|
_settingsStorage = storage;
|
||||||
_settings = _settingsStorage.Load();
|
_settings = settings;
|
||||||
|
|
||||||
// happlebao todo temp fix for instance code logic
|
// happlebao todo temp fix for instance code logic
|
||||||
HttpProxy.Instance.Settings = _settings;
|
HttpProxy.Instance.Settings = _settings;
|
||||||
|
|||||||
Reference in New Issue
Block a user