mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge branch 'dev'
This commit is contained in:
commit
f325674d10
38 changed files with 365 additions and 80 deletions
|
|
@ -194,6 +194,7 @@ namespace Wox.Plugin.Folder
|
|||
{
|
||||
case ".exe":
|
||||
case ".bat":
|
||||
case ".msi":
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using NLog;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NLog.Targets;
|
||||
using System;
|
||||
|
|
@ -7,6 +7,7 @@ using System.IO;
|
|||
using System.Runtime.CompilerServices;
|
||||
using System.Security;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.UserSettings;
|
||||
|
||||
namespace Wox.Plugin.Program.Logger
|
||||
{
|
||||
|
|
@ -21,7 +22,7 @@ namespace Wox.Plugin.Program.Logger
|
|||
|
||||
static ProgramLogger()
|
||||
{
|
||||
var path = Path.Combine(Constant.DataDirectory, DirectoryName, Constant.Version);
|
||||
var path = Path.Combine(DataLocation.DataDirectory(), DirectoryName, Constant.Version);
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
|
|
|
|||
|
|
@ -83,6 +83,6 @@ Install Visual Studio 2017/2019
|
|||
|
||||
Documentation
|
||||
-------------
|
||||
- [Wiki](https://github.com/Wox-launcher/Wox/wiki)
|
||||
- [Wiki](https://github.com/jjw24/Wox/wiki)
|
||||
- Outdated doc: [WoX doc](http://doc.wox.one).
|
||||
- Just ask questions in [issues](https://github.com/Wox-launcher/Wox/issues) for now.
|
||||
- Just ask questions in [issues](https://github.com/jjw24/Wox/issues) for now.
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
param(
|
||||
[string]$config = "Release",
|
||||
[string]$solution
|
||||
[string]$solution,
|
||||
[string]$targetpath
|
||||
)
|
||||
Write-Host "Config: $config"
|
||||
|
||||
function Build-Version {
|
||||
if ([string]::IsNullOrEmpty($env:APPVEYOR_BUILD_VERSION)) {
|
||||
$v = "1.2.0"
|
||||
} else {
|
||||
if ([string]::IsNullOrEmpty($env:APPVEYOR_BUILD_VERSION)) {
|
||||
$v = (Get-Command ${TargetPath}).FileVersionInfo.FileVersion
|
||||
} else {
|
||||
$v = $env:APPVEYOR_BUILD_VERSION
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +74,7 @@ function Zip-Release ($path, $version, $output) {
|
|||
|
||||
$input = "$path\Output\Release"
|
||||
Write-Host "Input path: $input"
|
||||
$file = "$output\Wox-$version.zip"
|
||||
$file = "$output\Wox-JJW24-$version.zip"
|
||||
Write-Host "Filename: $file"
|
||||
|
||||
[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem")
|
||||
|
|
@ -92,7 +93,7 @@ function Pack-Squirrel-Installer ($path, $version, $output) {
|
|||
Write-Host "Input path: $input"
|
||||
Nuget pack $spec -Version $version -Properties Configuration=Release -BasePath $input -OutputDirectory $output
|
||||
|
||||
$nupkg = "$output\Wox.$version.nupkg"
|
||||
$nupkg = "$output\Wox-JJW24.$version.nupkg"
|
||||
Write-Host "nupkg path: $nupkg"
|
||||
$icon = "$path\Wox\Resources\app.ico"
|
||||
Write-Host "icon: $icon"
|
||||
|
|
@ -106,7 +107,7 @@ function Pack-Squirrel-Installer ($path, $version, $output) {
|
|||
Move-Item $temp\* $output -Force
|
||||
Remove-Item $temp
|
||||
|
||||
$file = "$output\Wox-$version.exe"
|
||||
$file = "$output\Wox-JJW24-$version.exe"
|
||||
Write-Host "Filename: $file"
|
||||
|
||||
Move-Item "$output\Setup.exe" $file -Force
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0"?>
|
||||
<package>
|
||||
<metadata>
|
||||
<id>Wox</id>
|
||||
<id>Wox-JJW24</id>
|
||||
<title>Wox</title>
|
||||
<version>$version$</version>
|
||||
<authors>happlebao</authors>
|
||||
<projectUrl>https://github.com/Wox-launcher/Wox</projectUrl>
|
||||
<iconUrl>https://raw.githubusercontent.com/Wox-launcher/Wox/master/Wox/Images/app.png</iconUrl>
|
||||
<authors>happlebao, Jeremy Wu</authors>
|
||||
<projectUrl>https://github.com/jjw24/Wox</projectUrl>
|
||||
<iconUrl>https://raw.githubusercontent.com/jjw24/Wox/master/Wox/Images/app.png</iconUrl>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<description>Wox - a launcher for windows</description>
|
||||
</metadata>
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
<metadata>
|
||||
<id>Wox.Plugin</id>
|
||||
<version>$version$</version>
|
||||
<authors>qianlifeng</authors>
|
||||
<licenseUrl>https://github.com/Wox-launcher/Wox/blob/master/LICENSE</licenseUrl>
|
||||
<projectUrl>https://github.com/Wox-launcher/Wox</projectUrl>
|
||||
<authors>qianlifeng, Jeremy Wu</authors>
|
||||
<licenseUrl>https://github.com/jjw24/Wox/blob/master/LICENSE</licenseUrl>
|
||||
<projectUrl>https://github.com/jjw24/Wox</projectUrl>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<description>Reference this library if you want to develop a wox plugin</description>
|
||||
<tags>wox</tags>
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ using System.Runtime.InteropServices;
|
|||
#if DEBUG
|
||||
|
||||
[assembly: AssemblyConfiguration("Debug")]
|
||||
[assembly: AssemblyDescription("Debug build, https://github.com/Wox-launcher/Wox")]
|
||||
[assembly: AssemblyDescription("Debug build, https://github.com/jjw24/Wox")]
|
||||
#else
|
||||
[assembly: AssemblyConfiguration("Release")]
|
||||
[assembly: AssemblyDescription("Release build, https://github.com/Wox-launcher/Wox")]
|
||||
[assembly: AssemblyDescription("Release build, https://github.com/jjw24/Wox")]
|
||||
#endif
|
||||
|
||||
[assembly: AssemblyCompany("Wox")]
|
||||
|
|
@ -17,5 +17,5 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: AssemblyVersion("1.2.0")]
|
||||
[assembly: AssemblyFileVersion("1.2.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.2.0")]
|
||||
[assembly: AssemblyInformationalVersion("1.2.0")]
|
||||
16
Wox.Core/Configuration/IPortable.cs
Normal file
16
Wox.Core/Configuration/IPortable.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
namespace Wox.Core.Configuration
|
||||
{
|
||||
public interface IPortable
|
||||
{
|
||||
void EnablePortableMode();
|
||||
void DisablePortableMode();
|
||||
void RemoveShortcuts();
|
||||
void RemoveUninstallerEntry();
|
||||
void CreateShortcuts();
|
||||
void CreateUninstallerEntry();
|
||||
void MoveUserDataFolder(string fromLocation, string toLocation);
|
||||
void VerifyUserDataAfterMove(string fromLocation, string toLocation);
|
||||
bool CanUpdatePortability();
|
||||
}
|
||||
}
|
||||
203
Wox.Core/Configuration/Portable.cs
Normal file
203
Wox.Core/Configuration/Portable.cs
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
using Microsoft.Win32;
|
||||
using Squirrel;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using Wox.Infrastructure.UserSettings;
|
||||
using Wox.Plugin.SharedCommands;
|
||||
|
||||
namespace Wox.Core.Configuration
|
||||
{
|
||||
public class Portable : IPortable
|
||||
{
|
||||
/// <summary>
|
||||
/// As at Squirrel.Windows version 1.5.2, UpdateManager needs to be disposed after finish
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private UpdateManager NewUpdateManager()
|
||||
{
|
||||
return new UpdateManager(string.Empty, Constant.Wox, Constant.RootDirectory);
|
||||
}
|
||||
|
||||
public void DisablePortableMode()
|
||||
{
|
||||
try
|
||||
{
|
||||
MoveUserDataFolder(DataLocation.PortableDataPath, DataLocation.RoamingDataPath);
|
||||
#if DEBUG
|
||||
// Create shortcuts and uninstaller are not required in debug mode,
|
||||
// otherwise will repoint the path of the actual installed production version to the debug version
|
||||
#else
|
||||
CreateShortcuts();
|
||||
CreateUninstallerEntry();
|
||||
#endif
|
||||
IndicateDeletion(DataLocation.PortableDataPath);
|
||||
|
||||
MessageBox.Show("Wox needs to restart to finish disabling portable mode, " +
|
||||
"after the restart your portable data profile will be deleted and roaming data profile kept");
|
||||
|
||||
UpdateManager.RestartApp();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#if !DEBUG
|
||||
Log.Exception("Portable", "Error occured while disabling portable mode", e);
|
||||
#endif
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void EnablePortableMode()
|
||||
{
|
||||
try
|
||||
{
|
||||
MoveUserDataFolder(DataLocation.RoamingDataPath, DataLocation.PortableDataPath);
|
||||
#if DEBUG
|
||||
// Remove shortcuts and uninstaller are not required in debug mode,
|
||||
// otherwise will delete the actual installed production version
|
||||
#else
|
||||
RemoveShortcuts();
|
||||
RemoveUninstallerEntry();
|
||||
#endif
|
||||
IndicateDeletion(DataLocation.RoamingDataPath);
|
||||
|
||||
MessageBox.Show("Wox needs to restart to finish enabling portable mode, " +
|
||||
"after the restart your roaming data profile will be deleted and portable data profile kept");
|
||||
|
||||
UpdateManager.RestartApp();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#if !DEBUG
|
||||
Log.Exception("Portable", "Error occured while enabling portable mode", e);
|
||||
#endif
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveShortcuts()
|
||||
{
|
||||
using (var portabilityUpdater = NewUpdateManager())
|
||||
{
|
||||
var exeName = Constant.Wox + ".exe";
|
||||
portabilityUpdater.RemoveShortcutsForExecutable(exeName, ShortcutLocation.StartMenu);
|
||||
portabilityUpdater.RemoveShortcutsForExecutable(exeName, ShortcutLocation.Desktop);
|
||||
portabilityUpdater.RemoveShortcutsForExecutable(exeName, ShortcutLocation.Startup);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveUninstallerEntry()
|
||||
{
|
||||
using (var portabilityUpdater = NewUpdateManager())
|
||||
{
|
||||
portabilityUpdater.RemoveUninstallerRegistryEntry();
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveUserDataFolder(string fromLocation, string toLocation)
|
||||
{
|
||||
FilesFolders.Copy(fromLocation, toLocation);
|
||||
VerifyUserDataAfterMove(fromLocation, toLocation);
|
||||
}
|
||||
|
||||
public void VerifyUserDataAfterMove(string fromLocation, string toLocation)
|
||||
{
|
||||
FilesFolders.VerifyBothFolderFilesEqual(fromLocation, toLocation);
|
||||
}
|
||||
|
||||
public void CreateShortcuts()
|
||||
{
|
||||
using (var portabilityUpdater = NewUpdateManager())
|
||||
{
|
||||
var exeName = Constant.Wox + ".exe";
|
||||
portabilityUpdater.CreateShortcutsForExecutable(exeName, ShortcutLocation.StartMenu, false);
|
||||
portabilityUpdater.CreateShortcutsForExecutable(exeName, ShortcutLocation.Desktop, false);
|
||||
portabilityUpdater.CreateShortcutsForExecutable(exeName, ShortcutLocation.Startup, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateUninstallerEntry()
|
||||
{
|
||||
var uninstallRegSubKey = @"Software\Microsoft\Windows\CurrentVersion\Uninstall";
|
||||
// NB: Sometimes the Uninstall key doesn't exist
|
||||
using (var parentKey =
|
||||
RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default)
|
||||
.CreateSubKey("Uninstall", RegistryKeyPermissionCheck.ReadWriteSubTree)) {; }
|
||||
|
||||
var key = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default)
|
||||
.CreateSubKey(uninstallRegSubKey + "\\" + Constant.Wox, RegistryKeyPermissionCheck.ReadWriteSubTree);
|
||||
key.SetValue("DisplayIcon", Constant.ApplicationDirectory + "\\app.ico", RegistryValueKind.String);
|
||||
|
||||
using (var portabilityUpdater = NewUpdateManager())
|
||||
{
|
||||
portabilityUpdater.CreateUninstallerRegistryEntry();
|
||||
}
|
||||
}
|
||||
|
||||
internal void IndicateDeletion(string filePathTodelete)
|
||||
{
|
||||
using (StreamWriter sw = File.CreateText(filePathTodelete + "\\" + DataLocation.DeletionIndicatorFile)){}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///This method should be run at first before all methods during start up and should be run before determining which data location
|
||||
///will be used for Wox.
|
||||
///</summary>
|
||||
public void PreStartCleanUpAfterPortabilityUpdate()
|
||||
{
|
||||
// Specify here so this method does not rely on other environment variables to initialise
|
||||
var portableDataPath = Path.Combine(Directory.GetParent(Assembly.GetExecutingAssembly().Location.NonNull()).ToString(), "UserData");
|
||||
var roamingDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Wox");
|
||||
|
||||
bool DataLocationPortableDeleteRequired = false;
|
||||
bool DataLocationRoamingDeleteRequired = false;
|
||||
|
||||
if ((roamingDataPath + "\\" + DataLocation.DeletionIndicatorFile).FileExits())
|
||||
DataLocationRoamingDeleteRequired = true;
|
||||
|
||||
if ((portableDataPath + "\\" + DataLocation.DeletionIndicatorFile).FileExits())
|
||||
DataLocationPortableDeleteRequired = true;
|
||||
|
||||
if (DataLocationRoamingDeleteRequired)
|
||||
{
|
||||
if(roamingDataPath.LocationExists())
|
||||
MessageBox.Show("Wox detected you restarted after enabling portable mode, " +
|
||||
"your roaming data profile will now be deleted");
|
||||
|
||||
FilesFolders.RemoveFolderIfExists(roamingDataPath);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(DataLocationPortableDeleteRequired)
|
||||
{
|
||||
MessageBox.Show("Wox detected you restarted after disabling portable mode, " +
|
||||
"your portable data profile will now be deleted");
|
||||
|
||||
FilesFolders.RemoveFolderIfExists(portableDataPath);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanUpdatePortability()
|
||||
{
|
||||
var roamingLocationExists = DataLocation.RoamingDataPath.LocationExists();
|
||||
var portableLocationExists = DataLocation.PortableDataPath.LocationExists();
|
||||
|
||||
if(roamingLocationExists && portableLocationExists)
|
||||
{
|
||||
MessageBox.Show(string.Format("Wox detected your user data exists both in {0} and " +
|
||||
"{1}. {2}{2}Please delete {1} in order to proceed. No changes have occured.",
|
||||
DataLocation.PortableDataPath, DataLocation.RoamingDataPath, Environment.NewLine));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ namespace Wox.Core.Plugin
|
|||
return;
|
||||
}
|
||||
|
||||
string pluginFolerPath = Infrastructure.Constant.PluginsDirectory;
|
||||
string pluginFolerPath = Infrastructure.UserSettings.DataLocation.PluginsDirectory;
|
||||
|
||||
string newPluginName = plugin.Name
|
||||
.Replace("/", "_")
|
||||
|
|
|
|||
|
|
@ -32,20 +32,20 @@ namespace Wox.Core.Plugin
|
|||
// todo happlebao, this should not be public, the indicator function should be embeded
|
||||
public static PluginsSettings Settings;
|
||||
private static List<PluginMetadata> _metadatas;
|
||||
private static readonly string[] Directories = { Constant.PreinstalledDirectory, Constant.PluginsDirectory };
|
||||
private static readonly string[] Directories = { Constant.PreinstalledDirectory, DataLocation.PluginsDirectory };
|
||||
|
||||
private static void ValidateUserDirectory()
|
||||
{
|
||||
if (!Directory.Exists(Constant.PluginsDirectory))
|
||||
if (!Directory.Exists(DataLocation.PluginsDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(Constant.PluginsDirectory);
|
||||
Directory.CreateDirectory(DataLocation.PluginsDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DeletePythonBinding()
|
||||
{
|
||||
const string binding = "wox.py";
|
||||
var directory = Constant.PluginsDirectory;
|
||||
var directory = DataLocation.PluginsDirectory;
|
||||
foreach (var subDirectory in Directory.GetDirectories(directory))
|
||||
{
|
||||
var path = Path.Combine(subDirectory, binding);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace Wox.Core.Resource
|
|||
private const string Folder = "Themes";
|
||||
private const string Extension = ".xaml";
|
||||
private string DirectoryPath => Path.Combine(Constant.ProgramDirectory, Folder);
|
||||
private string UserDirectoryPath => Path.Combine(Constant.DataDirectory, Folder);
|
||||
private string UserDirectoryPath => Path.Combine(DataLocation.DataDirectory(), Folder);
|
||||
|
||||
public Theme()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ using Wox.Infrastructure;
|
|||
using Wox.Infrastructure.Http;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using System.IO;
|
||||
using Wox.Infrastructure.UserSettings;
|
||||
|
||||
namespace Wox.Core
|
||||
{
|
||||
|
|
@ -80,13 +81,13 @@ namespace Wox.Core
|
|||
|
||||
await updateManager.ApplyReleases(newUpdateInfo);
|
||||
|
||||
if (Constant.IsPortableMode)
|
||||
if (DataLocation.PortableDataLocationInUse())
|
||||
{
|
||||
var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion.ToString()}\\{Constant.PortableFolderName}";
|
||||
FilesFolders.Copy(Constant.PortableDataPath, targetDestination);
|
||||
if (!FilesFolders.VerifyBothFolderFilesEqual(Constant.PortableDataPath, targetDestination))
|
||||
var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion.ToString()}\\{DataLocation.PortableFolderName}";
|
||||
FilesFolders.Copy(DataLocation.PortableDataPath, targetDestination);
|
||||
if (!FilesFolders.VerifyBothFolderFilesEqual(DataLocation.PortableDataPath, targetDestination))
|
||||
MessageBox.Show(string.Format("Wox was not able to move your user profile data to the new update version. Please manually" +
|
||||
"move your profile data folder from {0} to {1}", Constant.PortableDataPath, targetDestination));
|
||||
"move your profile data folder from {0} to {1}", DataLocation.PortableDataPath, targetDestination));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@
|
|||
<Compile Include="..\SolutionAssemblyInfo.cs">
|
||||
<Link>Properties\SolutionAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Configuration\IPortable.cs" />
|
||||
<Compile Include="Configuration\Portable.cs" />
|
||||
<Compile Include="Plugin\ExecutablePlugin.cs" />
|
||||
<Compile Include="Plugin\PluginsLoader.cs" />
|
||||
<Compile Include="Resource\LocalizationConverter.cs" />
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
|
@ -13,27 +12,11 @@ namespace Wox.Infrastructure
|
|||
private static readonly Assembly Assembly = Assembly.GetExecutingAssembly();
|
||||
public static readonly string ProgramDirectory = Directory.GetParent(Assembly.Location.NonNull()).ToString();
|
||||
public static readonly string ExecutablePath = Path.Combine(ProgramDirectory, Wox + ".exe");
|
||||
|
||||
public static bool IsPortableMode;
|
||||
public const string PortableFolderName = "UserData";
|
||||
public static string PortableDataPath = Path.Combine(ProgramDirectory, PortableFolderName);
|
||||
public static string DetermineDataDirectory()
|
||||
{
|
||||
if (Directory.Exists(PortableDataPath))
|
||||
{
|
||||
IsPortableMode = true;
|
||||
return PortableDataPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Wox);
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly string DataDirectory = DetermineDataDirectory();
|
||||
public static readonly string PluginsDirectory = Path.Combine(DataDirectory, Plugins);
|
||||
public static readonly string ApplicationDirectory = Directory.GetParent(ProgramDirectory).ToString();
|
||||
public static readonly string RootDirectory = Directory.GetParent(ApplicationDirectory).ToString();
|
||||
|
||||
public static readonly string PreinstalledDirectory = Path.Combine(ProgramDirectory, Plugins);
|
||||
public const string Issue = "https://github.com/Wox-launcher/Wox/issues/new";
|
||||
public const string Issue = "https://github.com/jjw24/Wox/issues/new";
|
||||
public static readonly string Version = FileVersionInfo.GetVersionInfo(Assembly.Location.NonNull()).ProductVersion;
|
||||
|
||||
public static readonly int ThumbnailSize = 64;
|
||||
|
|
@ -4,6 +4,7 @@ using System.Runtime.CompilerServices;
|
|||
using NLog;
|
||||
using NLog.Config;
|
||||
using NLog.Targets;
|
||||
using Wox.Infrastructure.UserSettings;
|
||||
|
||||
namespace Wox.Infrastructure.Logger
|
||||
{
|
||||
|
|
@ -15,7 +16,7 @@ namespace Wox.Infrastructure.Logger
|
|||
|
||||
static Log()
|
||||
{
|
||||
CurrentLogDirectory = Path.Combine(Constant.DataDirectory, DirectoryName, Constant.Version);
|
||||
CurrentLogDirectory = Path.Combine(DataLocation.DataDirectory(), DirectoryName, Constant.Version);
|
||||
if (!Directory.Exists(CurrentLogDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(CurrentLogDirectory);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.Runtime.Serialization;
|
|||
using System.Runtime.Serialization.Formatters;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using Wox.Infrastructure.UserSettings;
|
||||
|
||||
namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
|
|
@ -17,7 +18,7 @@ namespace Wox.Infrastructure.Storage
|
|||
public BinaryStorage(string filename)
|
||||
{
|
||||
const string directoryName = "Cache";
|
||||
var directoryPath = Path.Combine(Constant.DataDirectory, directoryName);
|
||||
var directoryPath = Path.Combine(DataLocation.DataDirectory(), directoryName);
|
||||
Helper.ValidateDirectory(directoryPath);
|
||||
|
||||
const string fileSuffix = ".cache";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.IO;
|
||||
using Wox.Infrastructure.UserSettings;
|
||||
|
||||
namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
|
|
@ -9,7 +10,7 @@ namespace Wox.Infrastructure.Storage
|
|||
// C# releated, add python releated below
|
||||
var dataType = typeof(T);
|
||||
var assemblyName = typeof(T).Assembly.GetName().Name;
|
||||
DirectoryPath = Path.Combine(Constant.DataDirectory, DirectoryName, Constant.Plugins, assemblyName);
|
||||
DirectoryPath = Path.Combine(DataLocation.DataDirectory(), DirectoryName, Constant.Plugins, assemblyName);
|
||||
Helper.ValidateDirectory(DirectoryPath);
|
||||
|
||||
FilePath = Path.Combine(DirectoryPath, $"{dataType.Name}{FileSuffix}");
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Wox.Infrastructure.UserSettings;
|
||||
|
||||
namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
|
|
@ -11,7 +12,7 @@ namespace Wox.Infrastructure.Storage
|
|||
{
|
||||
public WoxJsonStorage()
|
||||
{
|
||||
var directoryPath = Path.Combine(Constant.DataDirectory, DirectoryName);
|
||||
var directoryPath = Path.Combine(DataLocation.DataDirectory(), DirectoryName);
|
||||
Helper.ValidateDirectory(directoryPath);
|
||||
|
||||
var filename = typeof(T).Name;
|
||||
|
|
|
|||
34
Wox.Infrastructure/UserSettings/DataLocation.cs
Normal file
34
Wox.Infrastructure/UserSettings/DataLocation.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Wox.Infrastructure.UserSettings
|
||||
{
|
||||
public static class DataLocation
|
||||
{
|
||||
public const string PortableFolderName = "UserData";
|
||||
public const string DeletionIndicatorFile = ".dead";
|
||||
public static string PortableDataPath = Path.Combine(Constant.ProgramDirectory, PortableFolderName);
|
||||
public static string RoamingDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Constant.Wox);
|
||||
public static string DataDirectory()
|
||||
{
|
||||
if (PortableDataLocationInUse())
|
||||
return PortableDataPath;
|
||||
|
||||
return RoamingDataPath;
|
||||
}
|
||||
|
||||
public static bool PortableDataLocationInUse()
|
||||
{
|
||||
if (Directory.Exists(PortableDataPath) && !File.Exists(DeletionIndicatorFile))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static readonly string PluginsDirectory = Path.Combine(DataDirectory(), Constant.Plugins);
|
||||
}
|
||||
}
|
||||
|
|
@ -77,7 +77,8 @@
|
|||
<Compile Include="UserSettings\PluginHotkey.cs" />
|
||||
<Compile Include="UserSettings\PluginSettings.cs" />
|
||||
<Compile Include="UserSettings\Settings.cs" />
|
||||
<Compile Include="Wox.cs" />
|
||||
<Compile Include="UserSettings\DataLocation.cs" />
|
||||
<Compile Include="Constant.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Wox.Plugin\Wox.Plugin.csproj">
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace Wox.Plugin.SharedCommands
|
|||
throw e;
|
||||
#else
|
||||
MessageBox.Show(string.Format("Copying path {0} has failed, it will now be deleted for consistency", targetPath));
|
||||
RemoveFolder(targetPath);
|
||||
RemoveFolderIfExists(targetPath);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ namespace Wox.Plugin.SharedCommands
|
|||
|
||||
}
|
||||
|
||||
public static void RemoveFolder(this string path)
|
||||
public static void RemoveFolderIfExists(this string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -97,5 +97,15 @@ namespace Wox.Plugin.SharedCommands
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public static bool LocationExists(this string path)
|
||||
{
|
||||
return Directory.Exists(path);
|
||||
}
|
||||
|
||||
public static bool FileExits(this string filePath)
|
||||
{
|
||||
return File.Exists(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
<applicationSettings>
|
||||
<Wox.Properties.Settings>
|
||||
<setting name="GithubRepo" serializeAs="String">
|
||||
<value>https://github.com/Wox-launcher/Wox</value>
|
||||
<value>https://github.com/jjw24/Wox</value>
|
||||
</setting>
|
||||
</Wox.Properties.Settings>
|
||||
</applicationSettings>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
|||
using System.Timers;
|
||||
using System.Windows;
|
||||
using Wox.Core;
|
||||
using Wox.Core.Configuration;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Core.Resource;
|
||||
using Wox.Helper;
|
||||
|
|
@ -26,6 +27,7 @@ namespace Wox
|
|||
private MainViewModel _mainVM;
|
||||
private SettingWindowViewModel _settingsVM;
|
||||
private readonly Updater _updater = new Updater(Wox.Properties.Settings.Default.GithubRepo);
|
||||
private readonly Portable _portable = new Portable();
|
||||
private readonly Alphabet _alphabet = new Alphabet();
|
||||
private StringMatcher _stringMatcher;
|
||||
|
||||
|
|
@ -46,6 +48,8 @@ namespace Wox
|
|||
{
|
||||
Stopwatch.Normal("|App.OnStartup|Startup cost", () =>
|
||||
{
|
||||
_portable.PreStartCleanUpAfterPortabilityUpdate();
|
||||
|
||||
Log.Info("|App.OnStartup|Begin Wox startup ----------------------------------------------------");
|
||||
Log.Info($"|App.OnStartup|Runtime info:{ErrorReporting.RuntimeInfo()}");
|
||||
RegisterAppDomainExceptions();
|
||||
|
|
@ -53,7 +57,7 @@ namespace Wox
|
|||
|
||||
ImageLoader.Initialize();
|
||||
|
||||
_settingsVM = new SettingWindowViewModel(_updater);
|
||||
_settingsVM = new SettingWindowViewModel(_updater, _portable);
|
||||
_settings = _settingsVM.Settings;
|
||||
|
||||
_alphabet.Initialize(_settings);
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@
|
|||
<system:String x:Key="checkUpdatesFailed">Check updates failed, please check your connection and proxy settings to api.github.com.</system:String>
|
||||
<system:String x:Key="downloadUpdatesFailed">
|
||||
Download updates failed, please check your connection and proxy settings to github-cloud.s3.amazonaws.com,
|
||||
or go to https://github.com/Wox-launcher/Wox/releases to download updates manually.
|
||||
or go to https://github.com/jjw24/Wox/releases to download updates manually.
|
||||
</system:String>
|
||||
<system:String x:Key="releaseNotes">Release Notes:</system:String>
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@
|
|||
<system:String x:Key="checkUpdates">Vérifier les mises à jour</system:String>
|
||||
<system:String x:Key="newVersionTips">Nouvelle version {0} disponible, veuillez redémarrer Wox</system:String>
|
||||
<system:String x:Key="checkUpdatesFailed">Échec de la vérification de la mise à jour, vérifiez votre connexion et vos paramètres de configuration proxy pour pouvoir acceder à api.github.com.</system:String>
|
||||
<system:String x:Key="downloadUpdatesFailed">Échec du téléchargement de la mise à jour, vérifiez votre connexion et vos paramètres de configuration proxy pour pouvoir acceder à github-cloud.s3.amazonaws.com, ou téléchargez manuelement la mise à jour sur https://github.com/Wox-launcher/Wox/releases.</system:String>
|
||||
<system:String x:Key="downloadUpdatesFailed">Échec du téléchargement de la mise à jour, vérifiez votre connexion et vos paramètres de configuration proxy pour pouvoir acceder à github-cloud.s3.amazonaws.com, ou téléchargez manuelement la mise à jour sur https://github.com/jjw24/Wox/releases.</system:String>
|
||||
<system:String x:Key="releaseNotes">Notes de changement :</system:String>
|
||||
|
||||
<!--Action Keyword Setting Dialog-->
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@
|
|||
<system:String x:Key="checkUpdatesFailed">Ricerca aggiornamenti fallita, per favore controlla la tua connessione e le eventuali impostazioni proxy per api.github.com.</system:String>
|
||||
<system:String x:Key="downloadUpdatesFailed">
|
||||
Download degli aggiornamenti fallito, per favore controlla la tua connessione ed eventuali impostazioni proxy per github-cloud.s3.amazonaws.com,
|
||||
oppure vai su https://github.com/Wox-launcher/Wox/releases per scaricare gli aggiornamenti manualmente.
|
||||
oppure vai su https://github.com/jjw24/Wox/releases per scaricare gli aggiornamenti manualmente.
|
||||
</system:String>
|
||||
<system:String x:Key="releaseNotes">Note di rilascio:</system:String>
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@
|
|||
<system:String x:Key="checkUpdatesFailed">アップデートの確認に失敗しました、api.github.com への接続とプロキシ設定を確認してください。</system:String>
|
||||
<system:String x:Key="downloadUpdatesFailed">
|
||||
更新のダウンロードに失敗しました、github-cloud.s3.amazonaws.com への接続とプロキシ設定を確認するか、
|
||||
https://github.com/Wox-launcher/Wox/releases から手動でアップデートをダウンロードしてください。
|
||||
https://github.com/jjw24/Wox/releases から手動でアップデートをダウンロードしてください。
|
||||
</system:String>
|
||||
<system:String x:Key="releaseNotes">リリースノート:</system:String>
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@
|
|||
<system:String x:Key="checkUpdatesFailed">Oppdateringssjekk feilet, vennligst sjekk tilkoblingen og proxy-innstillene for api.github.com.</system:String>
|
||||
<system:String x:Key="downloadUpdatesFailed">
|
||||
Nedlastning av oppdateringer feilet, vennligst sjekk tilkoblingen og proxy-innstillene for github-cloud.s3.amazonaws.com,
|
||||
eller gå til https://github.com/Wox-launcher/Wox/releases for å laste ned oppdateringer manuelt.
|
||||
eller gå til https://github.com/jjw24/Wox/releases for å laste ned oppdateringer manuelt.
|
||||
</system:String>
|
||||
<system:String x:Key="releaseNotes">Versjonsmerknader:</system:String>
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@
|
|||
<system:String x:Key="checkUpdatesFailed">Falha ao procurar atualizações, confira sua conexão e configuração de proxy para api.github.com.</system:String>
|
||||
<system:String x:Key="downloadUpdatesFailed">
|
||||
Falha ao baixar atualizações, confira sua conexão e configuração de proxy para github-cloud.s3.amazonaws.com,
|
||||
ou acesse https://github.com/Wox-launcher/Wox/releases para baixar manualmente.
|
||||
ou acesse https://github.com/jjw24/Wox/releases para baixar manualmente.
|
||||
</system:String>
|
||||
<system:String x:Key="releaseNotes">Notas de Versão:</system:String>
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@
|
|||
<system:String x:Key="checkUpdatesFailed">Kontrola aktualizácií zlyhala, prosím, skontrolujte pripojenie na internet a nastavenie proxy k api.github.com.</system:String>
|
||||
<system:String x:Key="downloadUpdatesFailed">
|
||||
Sťahovanie aktualizácií zlyhalo, skontrolujte pripojenie na internet a nastavenie proxy k github-cloud.s3.amazonaws.com,
|
||||
alebo prejdite na https://github.com/Wox-launcher/Wox/releases pre manuálne stiahnutie aktualizácií.
|
||||
alebo prejdite na https://github.com/jjw24/Wox/releases pre manuálne stiahnutie aktualizácií.
|
||||
</system:String>
|
||||
<system:String x:Key="releaseNotes">Poznámky k vydaniu:</system:String>
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@
|
|||
<system:String x:Key="checkUpdatesFailed">Neuspešna provera ažuriranja, molim Vas proverite vašu vezu i podešavanja za proksi prema api.github.com.</system:String>
|
||||
<system:String x:Key="downloadUpdatesFailed">
|
||||
Neuspešno preuzimanje ažuriranja, molim Vas proverite vašu vezu i podešavanja za proksi prema github-cloud.s3.amazonaws.com,
|
||||
ili posetite https://github.com/Wox-launcher/Wox/releases da preuzmete ažuriranja ručno.
|
||||
ili posetite https://github.com/jjw24/Wox/releases da preuzmete ažuriranja ručno.
|
||||
</system:String>
|
||||
<system:String x:Key="releaseNotes">U novoj verziji:</system:String>
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@
|
|||
<system:String x:Key="checkUpdatesFailed">Güncelleme kontrolü başarısız oldu. Lütfen bağlantınız ve vekil sunucu ayarlarınızın api.github.com adresine ulaşabilir olduğunu kontrol edin.</system:String>
|
||||
<system:String x:Key="downloadUpdatesFailed">
|
||||
Güncellemenin yüklenmesi başarısız oldu. Lütfen bağlantınız ve vekil sunucu ayarlarınızın github-cloud.s3.amazonaws.com
|
||||
adresine ulaşabilir olduğunu kontrol edin ya da https://github.com/Wox-launcher/Wox/releases adresinden güncellemeyi elle indirin.
|
||||
adresine ulaşabilir olduğunu kontrol edin ya da https://github.com/jjw24/Wox/releases adresinden güncellemeyi elle indirin.
|
||||
</system:String>
|
||||
<system:String x:Key="releaseNotes">Sürüm Notları:</system:String>
|
||||
|
||||
|
|
|
|||
4
Wox/Properties/Settings.Designer.cs
generated
4
Wox/Properties/Settings.Designer.cs
generated
|
|
@ -1,4 +1,4 @@
|
|||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
|
|
@ -25,7 +25,7 @@ namespace Wox.Properties {
|
|||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("https://github.com/Wox-launcher/Wox")]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("https://github.com/jjw24/Wox")]
|
||||
public string GithubRepo {
|
||||
get {
|
||||
return ((string)(this["GithubRepo"]));
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="GithubRepo" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">https://github.com/Wox-launcher/Wox</Value>
|
||||
<Value Profile="(Default)">https://github.com/jjw24/Wox</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
|
|
@ -33,6 +33,9 @@
|
|||
<TabControl Height="auto" SelectedIndex="0">
|
||||
<TabItem Header="{DynamicResource general}">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<CheckBox Margin="10" IsChecked="{Binding PortableMode}">
|
||||
<TextBlock Text="Portable Mode" />
|
||||
</CheckBox>
|
||||
<CheckBox Margin="10" IsChecked="{Binding Settings.StartWoxOnSystemStartup}"
|
||||
Checked="OnAutoStartupChecked" Unchecked="OnAutoStartupUncheck">
|
||||
<TextBlock Text="{DynamicResource startWoxOnSystemStartup}" />
|
||||
|
|
@ -384,7 +387,7 @@
|
|||
<Run Text="{Binding Github, Mode=OneWay}" />
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Text="{DynamicResource version}" />
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Text="JJW24 Version" />
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding Version}" />
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Text="{DynamicResource releaseNotes}" />
|
||||
<TextBlock Grid.Row="3" Grid.Column="1">
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ using System.Windows.Controls;
|
|||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Wox.Core;
|
||||
using Wox.Core.Configuration;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Core.Resource;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Http;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using Wox.Infrastructure.UserSettings;
|
||||
using Wox.Plugin;
|
||||
|
|
@ -22,11 +22,13 @@ namespace Wox.ViewModel
|
|||
public class SettingWindowViewModel : BaseModel
|
||||
{
|
||||
private readonly Updater _updater;
|
||||
private readonly IPortable _portable;
|
||||
private readonly WoxJsonStorage<Settings> _storage;
|
||||
|
||||
public SettingWindowViewModel(Updater updater)
|
||||
public SettingWindowViewModel(Updater updater, IPortable portable)
|
||||
{
|
||||
_updater = updater;
|
||||
_portable = portable;
|
||||
_storage = new WoxJsonStorage<Settings>();
|
||||
Settings = _storage.Load();
|
||||
Settings.PropertyChanged += (s, e) =>
|
||||
|
|
@ -36,8 +38,6 @@ namespace Wox.ViewModel
|
|||
OnPropertyChanged(nameof(ActivatedTimes));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Settings Settings { get; set; }
|
||||
|
|
@ -47,6 +47,27 @@ namespace Wox.ViewModel
|
|||
await _updater.UpdateApp(false);
|
||||
}
|
||||
|
||||
// This is only required to set at startup. When portable mode enabled/disabled a restart is always required
|
||||
private bool _portableMode = DataLocation.PortableDataLocationInUse();
|
||||
public bool PortableMode
|
||||
{
|
||||
get { return _portableMode; }
|
||||
set
|
||||
{
|
||||
if (!_portable.CanUpdatePortability())
|
||||
return;
|
||||
|
||||
if (DataLocation.PortableDataLocationInUse())
|
||||
{
|
||||
_portable.DisablePortableMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
_portable.EnablePortableMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
_storage.Save();
|
||||
|
|
|
|||
|
|
@ -441,7 +441,7 @@
|
|||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>powershell.exe -NoProfile -ExecutionPolicy Bypass -File $(SolutionDir)Scripts\post_build.ps1 $(ConfigurationName) $(SolutionDir)</PostBuildEvent>
|
||||
<PostBuildEvent>powershell.exe -NoProfile -ExecutionPolicy Bypass -File $(SolutionDir)Scripts\post_build.ps1 $(ConfigurationName) $(SolutionDir) $(TargetPath)</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>taskkill /f /fi "IMAGENAME eq Wox.exe"</PreBuildEvent>
|
||||
|
|
|
|||
Loading…
Reference in a new issue