mirror of
https://github.com/2dust/v2rayN.git
synced 2026-02-28 05:03:02 +00:00
feat: add Start browser menu (launch Edge with proxy on Windows)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
b5800f7dfc
commit
1d6da1f391
8 changed files with 83 additions and 1 deletions
11
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
11
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
|
|
@ -1,4 +1,4 @@
|
|||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
|
|
@ -1473,6 +1473,15 @@ namespace ServiceLib.Resx {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Start browser 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuStartBrowser {
|
||||
get {
|
||||
return ResourceManager.GetString("menuStartBrowser", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Backup to remote (WebDAV) 的本地化字符串。
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -423,6 +423,9 @@
|
|||
<data name="menuReload" xml:space="preserve">
|
||||
<value>Reload</value>
|
||||
</data>
|
||||
<data name="menuStartBrowser" xml:space="preserve">
|
||||
<value>Start browser</value>
|
||||
</data>
|
||||
<data name="menuRoutingSetting" xml:space="preserve">
|
||||
<value>Routing Setting</value>
|
||||
</data>
|
||||
|
|
|
|||
|
|
@ -423,6 +423,9 @@
|
|||
<data name="menuReload" xml:space="preserve">
|
||||
<value>重启服务</value>
|
||||
</data>
|
||||
<data name="menuStartBrowser" xml:space="preserve">
|
||||
<value>启动浏览器</value>
|
||||
</data>
|
||||
<data name="menuRoutingSetting" xml:space="preserve">
|
||||
<value>路由设置</value>
|
||||
</data>
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ public class MainWindowViewModel : MyReactiveObject
|
|||
|
||||
public ReactiveCommand<Unit, Unit> ReloadCmd { get; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> StartBrowserCmd { get; }
|
||||
|
||||
[Reactive]
|
||||
public bool BlReloadEnabled { get; set; }
|
||||
|
||||
|
|
@ -207,6 +209,11 @@ public class MainWindowViewModel : MyReactiveObject
|
|||
await Reload();
|
||||
});
|
||||
|
||||
StartBrowserCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await StartBrowser();
|
||||
});
|
||||
|
||||
RegionalPresetDefaultCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await ApplyRegionalPreset(EPresetType.Default);
|
||||
|
|
@ -520,6 +527,42 @@ public class MainWindowViewModel : MyReactiveObject
|
|||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task StartBrowser()
|
||||
{
|
||||
if (!Utils.IsWindows())
|
||||
{
|
||||
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||
await Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var v2rayNPath = Utils.StartupPath();
|
||||
var port = AppManager.Instance.GetLocalPort(EInboundProtocol.socks);
|
||||
var edgeDataDir = Path.Combine(v2rayNPath, "edge-data");
|
||||
|
||||
var process = new System.Diagnostics.Process
|
||||
{
|
||||
StartInfo = new System.Diagnostics.ProcessStartInfo
|
||||
{
|
||||
FileName = "msedge.exe",
|
||||
Arguments = $"--user-data-dir=\"{edgeDataDir}\" --proxy-server=127.0.0.1:{port} https://www.google.com/",
|
||||
WorkingDirectory = v2rayNPath,
|
||||
UseShellExecute = true
|
||||
}
|
||||
};
|
||||
process.Start();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog("StartBrowser", ex);
|
||||
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||
}
|
||||
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
#endregion Setting
|
||||
|
||||
#region core job
|
||||
|
|
|
|||
|
|
@ -97,6 +97,11 @@
|
|||
|
||||
<MenuItem x:Name="menuReload" Header="{x:Static resx:ResUI.menuReload}" />
|
||||
|
||||
<MenuItem
|
||||
x:Name="menuStartBrowser"
|
||||
Header="{x:Static resx:ResUI.menuStartBrowser}"
|
||||
IsVisible="{Binding BlIsWindows}" />
|
||||
|
||||
<MenuItem x:Name="menuPromotion" Header="{x:Static resx:ResUI.menuPromotion}" />
|
||||
|
||||
<MenuItem x:Name="menuClose" Header="{x:Static resx:ResUI.menuExit}" />
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
|||
|
||||
this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables);
|
||||
this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.StartBrowserCmd, v => v.menuStartBrowser).DisposeWith(disposables);
|
||||
|
||||
switch (_config.UiItem.MainGirdOrientation)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -268,6 +268,23 @@
|
|||
</MenuItem>
|
||||
</Menu>
|
||||
<Separator />
|
||||
<Menu Margin="0,1" Style="{StaticResource ToolbarMenu}">
|
||||
<MenuItem
|
||||
x:Name="menuStartBrowser"
|
||||
Padding="{StaticResource MarginLeftRight8}"
|
||||
AutomationProperties.Name="{x:Static resx:ResUI.menuStartBrowser}">
|
||||
<MenuItem.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon
|
||||
Margin="{StaticResource MarginRight8}"
|
||||
VerticalAlignment="Center"
|
||||
Kind="OpenInBrowser" />
|
||||
<TextBlock Text="{x:Static resx:ResUI.menuStartBrowser}" />
|
||||
</StackPanel>
|
||||
</MenuItem.Header>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
<Separator />
|
||||
<Menu Margin="0,1" Style="{StaticResource ToolbarMenu}">
|
||||
<MenuItem
|
||||
x:Name="menuPromotion"
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ public partial class MainWindow
|
|||
|
||||
this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables);
|
||||
this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.StartBrowserCmd, v => v.menuStartBrowser).DisposeWith(disposables);
|
||||
|
||||
switch (_config.UiItem.MainGirdOrientation)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue