mirror of https://github.com/2dust/v2rayN
Add open the file location
parent
baef3b364b
commit
28e41dc621
|
@ -744,11 +744,11 @@ namespace v2rayN
|
|||
return Guid.TryParse(strSrc, out Guid g);
|
||||
}
|
||||
|
||||
public static void ProcessStart(string fileName)
|
||||
public static void ProcessStart(string fileName, string arguments = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(new ProcessStartInfo(fileName) { UseShellExecute = true });
|
||||
Process.Start(new ProcessStartInfo(fileName, arguments) { UseShellExecute = true });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -240,103 +240,103 @@ namespace v2rayN.Handler
|
|||
}
|
||||
}
|
||||
|
||||
public static int ImportOldGuiConfig(Config config, string fileName)
|
||||
{
|
||||
var result = Utils.LoadResource(fileName);
|
||||
if (Utils.IsNullOrEmpty(result))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
//public static int ImportOldGuiConfig(Config config, string fileName)
|
||||
//{
|
||||
// var result = Utils.LoadResource(fileName);
|
||||
// if (Utils.IsNullOrEmpty(result))
|
||||
// {
|
||||
// return -1;
|
||||
// }
|
||||
|
||||
var configOld = JsonUtils.Deserialize<ConfigOld>(result);
|
||||
if (configOld == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
// var configOld = JsonUtils.Deserialize<ConfigOld>(result);
|
||||
// if (configOld == null)
|
||||
// {
|
||||
// return -1;
|
||||
// }
|
||||
|
||||
var subItem = JsonUtils.Deserialize<List<SubItem>>(JsonUtils.Serialize(configOld.subItem));
|
||||
foreach (var it in subItem)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(it.id))
|
||||
{
|
||||
it.id = Utils.GetGUID(false);
|
||||
}
|
||||
SQLiteHelper.Instance.Replace(it);
|
||||
}
|
||||
// var subItem = JsonUtils.Deserialize<List<SubItem>>(JsonUtils.Serialize(configOld.subItem));
|
||||
// foreach (var it in subItem)
|
||||
// {
|
||||
// if (Utils.IsNullOrEmpty(it.id))
|
||||
// {
|
||||
// it.id = Utils.GetGUID(false);
|
||||
// }
|
||||
// SQLiteHelper.Instance.Replace(it);
|
||||
// }
|
||||
|
||||
var profileItems = JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(configOld.vmess));
|
||||
foreach (var it in profileItems)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(it.indexId))
|
||||
{
|
||||
it.indexId = Utils.GetGUID(false);
|
||||
}
|
||||
SQLiteHelper.Instance.Replace(it);
|
||||
}
|
||||
// var profileItems = JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(configOld.vmess));
|
||||
// foreach (var it in profileItems)
|
||||
// {
|
||||
// if (Utils.IsNullOrEmpty(it.indexId))
|
||||
// {
|
||||
// it.indexId = Utils.GetGUID(false);
|
||||
// }
|
||||
// SQLiteHelper.Instance.Replace(it);
|
||||
// }
|
||||
|
||||
foreach (var it in configOld.routings)
|
||||
{
|
||||
if (it.locked)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var routing = JsonUtils.Deserialize<RoutingItem>(JsonUtils.Serialize(it));
|
||||
foreach (var it2 in it.rules)
|
||||
{
|
||||
it2.id = Utils.GetGUID(false);
|
||||
}
|
||||
routing.ruleNum = it.rules.Count;
|
||||
routing.ruleSet = JsonUtils.Serialize(it.rules, false);
|
||||
// foreach (var it in configOld.routings)
|
||||
// {
|
||||
// if (it.locked)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// var routing = JsonUtils.Deserialize<RoutingItem>(JsonUtils.Serialize(it));
|
||||
// foreach (var it2 in it.rules)
|
||||
// {
|
||||
// it2.id = Utils.GetGUID(false);
|
||||
// }
|
||||
// routing.ruleNum = it.rules.Count;
|
||||
// routing.ruleSet = JsonUtils.Serialize(it.rules, false);
|
||||
|
||||
if (Utils.IsNullOrEmpty(routing.id))
|
||||
{
|
||||
routing.id = Utils.GetGUID(false);
|
||||
}
|
||||
SQLiteHelper.Instance.Replace(routing);
|
||||
}
|
||||
// if (Utils.IsNullOrEmpty(routing.id))
|
||||
// {
|
||||
// routing.id = Utils.GetGUID(false);
|
||||
// }
|
||||
// SQLiteHelper.Instance.Replace(routing);
|
||||
// }
|
||||
|
||||
config = JsonUtils.Deserialize<Config>(JsonUtils.Serialize(configOld));
|
||||
// config = JsonUtils.Deserialize<Config>(JsonUtils.Serialize(configOld));
|
||||
|
||||
if (config.coreBasicItem == null)
|
||||
{
|
||||
config.coreBasicItem = new()
|
||||
{
|
||||
logEnabled = configOld.logEnabled,
|
||||
loglevel = configOld.loglevel,
|
||||
muxEnabled = configOld.muxEnabled,
|
||||
};
|
||||
}
|
||||
// if (config.coreBasicItem == null)
|
||||
// {
|
||||
// config.coreBasicItem = new()
|
||||
// {
|
||||
// logEnabled = configOld.logEnabled,
|
||||
// loglevel = configOld.loglevel,
|
||||
// muxEnabled = configOld.muxEnabled,
|
||||
// };
|
||||
// }
|
||||
|
||||
if (config.routingBasicItem == null)
|
||||
{
|
||||
config.routingBasicItem = new()
|
||||
{
|
||||
enableRoutingAdvanced = configOld.enableRoutingAdvanced,
|
||||
domainStrategy = configOld.domainStrategy
|
||||
};
|
||||
}
|
||||
// if (config.routingBasicItem == null)
|
||||
// {
|
||||
// config.routingBasicItem = new()
|
||||
// {
|
||||
// enableRoutingAdvanced = configOld.enableRoutingAdvanced,
|
||||
// domainStrategy = configOld.domainStrategy
|
||||
// };
|
||||
// }
|
||||
|
||||
if (config.guiItem == null)
|
||||
{
|
||||
config.guiItem = new()
|
||||
{
|
||||
enableStatistics = configOld.enableStatistics,
|
||||
keepOlderDedupl = configOld.keepOlderDedupl,
|
||||
ignoreGeoUpdateCore = configOld.ignoreGeoUpdateCore,
|
||||
autoUpdateInterval = configOld.autoUpdateInterval,
|
||||
checkPreReleaseUpdate = configOld.checkPreReleaseUpdate,
|
||||
enableSecurityProtocolTls13 = configOld.enableSecurityProtocolTls13,
|
||||
trayMenuServersLimit = configOld.trayMenuServersLimit,
|
||||
};
|
||||
}
|
||||
// if (config.guiItem == null)
|
||||
// {
|
||||
// config.guiItem = new()
|
||||
// {
|
||||
// enableStatistics = configOld.enableStatistics,
|
||||
// keepOlderDedupl = configOld.keepOlderDedupl,
|
||||
// ignoreGeoUpdateCore = configOld.ignoreGeoUpdateCore,
|
||||
// autoUpdateInterval = configOld.autoUpdateInterval,
|
||||
// checkPreReleaseUpdate = configOld.checkPreReleaseUpdate,
|
||||
// enableSecurityProtocolTls13 = configOld.enableSecurityProtocolTls13,
|
||||
// trayMenuServersLimit = configOld.trayMenuServersLimit,
|
||||
// };
|
||||
// }
|
||||
|
||||
GetDefaultServer(config);
|
||||
GetDefaultRouting(config);
|
||||
SaveConfig(config);
|
||||
LoadConfig(ref config);
|
||||
// GetDefaultServer(config);
|
||||
// GetDefaultRouting(config);
|
||||
// SaveConfig(config);
|
||||
// LoadConfig(ref config);
|
||||
|
||||
return 0;
|
||||
}
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
#endregion ConfigHandler
|
||||
|
||||
|
|
|
@ -978,6 +978,15 @@ namespace v2rayN.Resx {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Open the storage location 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuOpenTheFileLocation {
|
||||
get {
|
||||
return ResourceManager.GetString("menuOpenTheFileLocation", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Option Setting 的本地化字符串。
|
||||
/// </summary>
|
||||
|
|
|
@ -1216,4 +1216,7 @@
|
|||
<data name="NeedRebootTips" xml:space="preserve">
|
||||
<value>Successful operation. Click the settings menu to reboot the app.</value>
|
||||
</data>
|
||||
<data name="menuOpenTheFileLocation" xml:space="preserve">
|
||||
<value>Open the storage location</value>
|
||||
</data>
|
||||
</root>
|
|
@ -1213,4 +1213,7 @@
|
|||
<data name="NeedRebootTips" xml:space="preserve">
|
||||
<value>操作成功。请点击设置菜单重启应用。</value>
|
||||
</data>
|
||||
<data name="menuOpenTheFileLocation" xml:space="preserve">
|
||||
<value>打开存储所在的位置</value>
|
||||
</data>
|
||||
</root>
|
|
@ -1186,4 +1186,7 @@
|
|||
<data name="NeedRebootTips" xml:space="preserve">
|
||||
<value>操作成功。 請點選設定選單重啟應用程式。</value>
|
||||
</data>
|
||||
<data name="menuOpenTheFileLocation" xml:space="preserve">
|
||||
<value>打開儲存所在的位置</value>
|
||||
</data>
|
||||
</root>
|
|
@ -143,7 +143,8 @@ namespace v2rayN.ViewModels
|
|||
public ReactiveCommand<Unit, Unit> GlobalHotkeySettingCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> RebootAsAdminCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> ClearServerStatisticsCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> ImportOldGuiConfigCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> OpenTheFileLocationCmd { get; }
|
||||
//public ReactiveCommand<Unit, Unit> ImportOldGuiConfigCmd { get; }
|
||||
|
||||
//CheckUpdate
|
||||
public ReactiveCommand<Unit, Unit> CheckUpdateNCmd { get; }
|
||||
|
@ -503,10 +504,14 @@ namespace v2rayN.ViewModels
|
|||
_statistics?.ClearAllServerStatistics();
|
||||
RefreshServers();
|
||||
});
|
||||
ImportOldGuiConfigCmd = ReactiveCommand.Create(() =>
|
||||
OpenTheFileLocationCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
ImportOldGuiConfig();
|
||||
Utils.ProcessStart("Explorer", $"/select,{Utils.GetConfigPath()}");
|
||||
});
|
||||
//ImportOldGuiConfigCmd = ReactiveCommand.Create(() =>
|
||||
//{
|
||||
// ImportOldGuiConfig();
|
||||
//});
|
||||
|
||||
//CheckUpdate
|
||||
CheckUpdateNCmd = ReactiveCommand.Create(() =>
|
||||
|
@ -1422,32 +1427,32 @@ namespace v2rayN.ViewModels
|
|||
catch { }
|
||||
}
|
||||
|
||||
private void ImportOldGuiConfig()
|
||||
{
|
||||
if (UI.OpenFileDialog(out string fileName,
|
||||
"guiNConfig|*.json|All|*.*") != true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Utils.IsNullOrEmpty(fileName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
//private void ImportOldGuiConfig()
|
||||
//{
|
||||
// if (UI.OpenFileDialog(out string fileName,
|
||||
// "guiNConfig|*.json|All|*.*") != true)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// if (Utils.IsNullOrEmpty(fileName))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
var ret = ConfigHandler.ImportOldGuiConfig(_config, fileName);
|
||||
if (ret == 0)
|
||||
{
|
||||
RefreshRoutingsMenu();
|
||||
InitSubscriptionView();
|
||||
RefreshServers();
|
||||
Reload();
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
}
|
||||
else
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationFailed);
|
||||
}
|
||||
}
|
||||
// var ret = ConfigHandler.ImportOldGuiConfig(_config, fileName);
|
||||
// if (ret == 0)
|
||||
// {
|
||||
// RefreshRoutingsMenu();
|
||||
// InitSubscriptionView();
|
||||
// RefreshServers();
|
||||
// Reload();
|
||||
// _noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _noticeHandler?.Enqueue(ResUI.OperationFailed);
|
||||
// }
|
||||
//}
|
||||
|
||||
#endregion Setting
|
||||
|
||||
|
|
|
@ -191,9 +191,13 @@
|
|||
Header="{x:Static resx:ResUI.menuClearServerStatistics}" />
|
||||
<Separator Margin="-40,5" />
|
||||
<MenuItem
|
||||
x:Name="menuOpenTheFileLocation"
|
||||
Height="{StaticResource MenuItemHeight}"
|
||||
Header="{x:Static resx:ResUI.menuOpenTheFileLocation}" />
|
||||
<!--<MenuItem
|
||||
x:Name="menuImportOldGuiConfig"
|
||||
Height="{StaticResource MenuItemHeight}"
|
||||
Header="{x:Static resx:ResUI.menuImportOldGuiConfig}" />
|
||||
Header="{x:Static resx:ResUI.menuImportOldGuiConfig}" />-->
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
<Separator />
|
||||
|
|
|
@ -138,7 +138,8 @@ namespace v2rayN.Views
|
|||
this.BindCommand(ViewModel, vm => vm.GlobalHotkeySettingCmd, v => v.menuGlobalHotkeySetting).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.RebootAsAdminCmd, v => v.menuRebootAsAdmin).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.ClearServerStatisticsCmd, v => v.menuClearServerStatistics).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.ImportOldGuiConfigCmd, v => v.menuImportOldGuiConfig).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.OpenTheFileLocationCmd, v => v.menuOpenTheFileLocation).DisposeWith(disposables);
|
||||
//this.BindCommand(ViewModel, vm => vm.ImportOldGuiConfigCmd, v => v.menuImportOldGuiConfig).DisposeWith(disposables);
|
||||
|
||||
//check update
|
||||
this.BindCommand(ViewModel, vm => vm.CheckUpdateNCmd, v => v.menuCheckUpdateN).DisposeWith(disposables);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<PackageReference Include="TaskScheduler" Version="2.11.0" />
|
||||
<PackageReference Include="ZXing.Net.Bindings.Windows.Compatibility" Version="0.16.12" />
|
||||
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
|
||||
<PackageReference Include="ReactiveUI.Validation" Version="3.1.7" />
|
||||
<PackageReference Include="ReactiveUI.Validation" Version="4.0.6" />
|
||||
<PackageReference Include="ReactiveUI.WPF" Version="20.0.1" />
|
||||
<PackageReference Include="Splat.NLog" Version="15.0.1" />
|
||||
</ItemGroup>
|
||||
|
|
Loading…
Reference in New Issue