Merge pull request #5 from jjw24/update_plugin_openurl_newbrowser

Wox.Plugin.URL- Open URL in new window browser
This commit is contained in:
Jeremy Wu
2019-08-20 07:38:09 +10:00
committed by GitHub
3 changed files with 33 additions and 11 deletions

View File

@@ -1,9 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Controls; using System.Windows.Controls;
using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage;
using Wox.Plugin.SharedCommands;
namespace Wox.Plugin.Url namespace Wox.Plugin.Url
{ {
@@ -79,15 +79,8 @@ namespace Wox.Plugin.Url
} }
try try
{ {
if (_settings.BrowserPath.Length == 0) raw.NewBrowserWindow(_settings.BrowserPath);
{
Process.Start(raw);
}
else
{
Process.Start(_settings.BrowserPath,raw);
}
return true; return true;
} }
catch(Exception ex) catch(Exception ex)

View File

@@ -0,0 +1,27 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace Wox.Plugin.SharedCommands
{
public static class SearchWeb
{
/// <summary> Opens search in a new browser. If no browser path is passed in then Chrome is used.
/// Leave browser path blank to use Chrome.
/// </summary>
public static void NewBrowserWindow(this string url, string browserPath)
{
var browserExecutableName = browserPath?
.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None)
.Last();
var browser = string.IsNullOrEmpty(browserExecutableName) ? "chrome" : browserPath;
// Internet Explorer will open url in new browser window, and does not take the --new-window parameter
var browserArguements = browserExecutableName == "iexplore.exe" ? url : "--new-window " + url;
Process.Start(browser, browserArguements);
}
}
}

View File

@@ -76,6 +76,7 @@
<Compile Include="Query.cs" /> <Compile Include="Query.cs" />
<Compile Include="Result.cs" /> <Compile Include="Result.cs" />
<Compile Include="ActionContext.cs" /> <Compile Include="ActionContext.cs" />
<Compile Include="SharedCommands\SearchWeb.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
@@ -84,6 +85,7 @@
<ItemGroup> <ItemGroup>
<Content Include="FodyWeavers.xml" /> <Content Include="FodyWeavers.xml" />
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.1.29.2\build\dotnet\Fody.targets" Condition="Exists('..\packages\Fody.1.29.2\build\dotnet\Fody.targets')" /> <Import Project="..\packages\Fody.1.29.2\build\dotnet\Fody.targets" Condition="Exists('..\packages\Fody.1.29.2\build\dotnet\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">