set Constant env paths variables when PlugingSettings is set

This commit is contained in:
Jeremy 2022-10-25 21:54:00 +11:00
parent adf712ddd6
commit 4b0d17c81c
3 changed files with 31 additions and 28 deletions

View file

@ -1,4 +1,4 @@
using Droplex;
using Droplex;
using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Logger;
@ -89,10 +89,7 @@ namespace Flow.Launcher.Core.ExternalPlugins
selectedFile = GetFileFromDialog(msg, "Python|pythonw.exe");
if (!string.IsNullOrEmpty(selectedFile))
{
Constant.PythonPath = selectedFile;
pluginSettings.PythonFilePath = Constant.PythonPath;
}
pluginSettings.PythonFilePath = selectedFile;
break;
case AllowedLanguage.TypeScript:
@ -100,10 +97,7 @@ namespace Flow.Launcher.Core.ExternalPlugins
selectedFile = GetFileFromDialog(msg);
if (!string.IsNullOrEmpty(selectedFile))
{
Constant.NodePath = selectedFile;
pluginSettings.NodeFilePath = Constant.NodePath;
}
pluginSettings.NodeFilePath = selectedFile;
break;
default:
@ -121,11 +115,11 @@ namespace Flow.Launcher.Core.ExternalPlugins
switch (languageType)
{
case AllowedLanguage.Python when FilesFolders.FileExists(pluginSettings.PythonFilePath) && !string.IsNullOrEmpty(Constant.PythonPath):
case AllowedLanguage.Python when FilesFolders.FileExists(pluginSettings.PythonFilePath):
return SetPathForPluginPairs(pluginSettings.PythonFilePath, languageType);
case AllowedLanguage.TypeScript when FilesFolders.FileExists(pluginSettings.NodeFilePath) && !string.IsNullOrEmpty(Constant.NodePath):
case AllowedLanguage.JavaScript when FilesFolders.FileExists(pluginSettings.NodeFilePath) && !string.IsNullOrEmpty(Constant.NodePath):
case AllowedLanguage.TypeScript when FilesFolders.FileExists(pluginSettings.NodeFilePath):
case AllowedLanguage.JavaScript when FilesFolders.FileExists(pluginSettings.NodeFilePath):
return SetPathForPluginPairs(pluginSettings.NodeFilePath, languageType);
default:
@ -149,9 +143,8 @@ namespace Flow.Launcher.Core.ExternalPlugins
// Python 3.8.9 is used for Windows 7 compatibility
DroplexPackage.Drop(App.python_3_8_9_embeddable, pythonDirPath).Wait();
Constant.PythonPath = Path.Combine(pythonDirPath, PythonExecutable);
pluginSettings.PythonFilePath = Constant.PythonPath;
pluginSettings.PythonFilePath = Path.Combine(pythonDirPath, PythonExecutable);
break;
case AllowedLanguage.TypeScript:
@ -161,8 +154,7 @@ namespace Flow.Launcher.Core.ExternalPlugins
DroplexPackage.Drop(App.nodejs_16_18_0, nodeDirPath).Wait();
Constant.NodePath = Path.Combine(nodeDirPath, $"node-v16.18.0-win-x64\\{NodeExecutable}");
pluginSettings.NodeFilePath = Constant.NodePath;
pluginSettings.NodeFilePath = Path.Combine(nodeDirPath, $"node-v16.18.0-win-x64\\{NodeExecutable}");
break;
default:

View file

@ -5,9 +5,26 @@ namespace Flow.Launcher.Infrastructure.UserSettings
{
public class PluginsSettings : BaseModel
{
public string PythonFilePath { get; set; }
private string pythonFilePath;
public string PythonFilePath {
get { return pythonFilePath; }
set
{
pythonFilePath = value;
Constant.PythonPath = value;
}
}
public string NodeFilePath { get; set; }
private string nodeFilePath;
public string NodeFilePath
{
get { return nodeFilePath; }
set
{
nodeFilePath = value;
Constant.NodePath = value;
}
}
public Dictionary<string, Plugin> Plugins { get; set; } = new Dictionary<string, Plugin>();

View file

@ -1,4 +1,4 @@
using Droplex;
using Droplex;
using Flow.Launcher.Core.ExternalPlugins;
using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Core.Resource;
@ -77,10 +77,7 @@ namespace Flow.Launcher
"Python|pythonw.exe");
if (!string.IsNullOrEmpty(selectedFile))
{
Constant.PythonPath = selectedFile;
settings.PluginSettings.PythonFilePath = Constant.PythonPath;
}
settings.PluginSettings.PythonFilePath = selectedFile;
}
private void OnSelectNodeFilePathClick(object sender, RoutedEventArgs e)
@ -89,10 +86,7 @@ namespace Flow.Launcher
InternationalizationManager.Instance.GetTranslation("selectNodeExecutable"));
if (!string.IsNullOrEmpty(selectedFile))
{
Constant.NodePath = selectedFile;
settings.PluginSettings.NodeFilePath = Constant.NodePath;
}
settings.PluginSettings.NodeFilePath = selectedFile;
}
private void OnSelectFileManagerClick(object sender, RoutedEventArgs e)