Skip to content

Commit 28e41dc

Browse files
committed
Add open the file location
1 parent baef3b3 commit 28e41dc

File tree

10 files changed

+159
-131
lines changed

10 files changed

+159
-131
lines changed

v2rayN/v2rayN/Common/Utils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,11 +744,11 @@ public static bool IsGuidByParse(string strSrc)
744744
return Guid.TryParse(strSrc, out Guid g);
745745
}
746746

747-
public static void ProcessStart(string fileName)
747+
public static void ProcessStart(string fileName, string arguments = "")
748748
{
749749
try
750750
{
751-
Process.Start(new ProcessStartInfo(fileName) { UseShellExecute = true });
751+
Process.Start(new ProcessStartInfo(fileName, arguments) { UseShellExecute = true });
752752
}
753753
catch (Exception ex)
754754
{

v2rayN/v2rayN/Handler/ConfigHandler.cs

Lines changed: 97 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -240,103 +240,103 @@ private static void ToJsonFile(Config config)
240240
}
241241
}
242242

243-
public static int ImportOldGuiConfig(Config config, string fileName)
244-
{
245-
var result = Utils.LoadResource(fileName);
246-
if (Utils.IsNullOrEmpty(result))
247-
{
248-
return -1;
249-
}
250-
251-
var configOld = JsonUtils.Deserialize<ConfigOld>(result);
252-
if (configOld == null)
253-
{
254-
return -1;
255-
}
256-
257-
var subItem = JsonUtils.Deserialize<List<SubItem>>(JsonUtils.Serialize(configOld.subItem));
258-
foreach (var it in subItem)
259-
{
260-
if (Utils.IsNullOrEmpty(it.id))
261-
{
262-
it.id = Utils.GetGUID(false);
263-
}
264-
SQLiteHelper.Instance.Replace(it);
265-
}
266-
267-
var profileItems = JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(configOld.vmess));
268-
foreach (var it in profileItems)
269-
{
270-
if (Utils.IsNullOrEmpty(it.indexId))
271-
{
272-
it.indexId = Utils.GetGUID(false);
273-
}
274-
SQLiteHelper.Instance.Replace(it);
275-
}
276-
277-
foreach (var it in configOld.routings)
278-
{
279-
if (it.locked)
280-
{
281-
continue;
282-
}
283-
var routing = JsonUtils.Deserialize<RoutingItem>(JsonUtils.Serialize(it));
284-
foreach (var it2 in it.rules)
285-
{
286-
it2.id = Utils.GetGUID(false);
287-
}
288-
routing.ruleNum = it.rules.Count;
289-
routing.ruleSet = JsonUtils.Serialize(it.rules, false);
290-
291-
if (Utils.IsNullOrEmpty(routing.id))
292-
{
293-
routing.id = Utils.GetGUID(false);
294-
}
295-
SQLiteHelper.Instance.Replace(routing);
296-
}
297-
298-
config = JsonUtils.Deserialize<Config>(JsonUtils.Serialize(configOld));
299-
300-
if (config.coreBasicItem == null)
301-
{
302-
config.coreBasicItem = new()
303-
{
304-
logEnabled = configOld.logEnabled,
305-
loglevel = configOld.loglevel,
306-
muxEnabled = configOld.muxEnabled,
307-
};
308-
}
309-
310-
if (config.routingBasicItem == null)
311-
{
312-
config.routingBasicItem = new()
313-
{
314-
enableRoutingAdvanced = configOld.enableRoutingAdvanced,
315-
domainStrategy = configOld.domainStrategy
316-
};
317-
}
318-
319-
if (config.guiItem == null)
320-
{
321-
config.guiItem = new()
322-
{
323-
enableStatistics = configOld.enableStatistics,
324-
keepOlderDedupl = configOld.keepOlderDedupl,
325-
ignoreGeoUpdateCore = configOld.ignoreGeoUpdateCore,
326-
autoUpdateInterval = configOld.autoUpdateInterval,
327-
checkPreReleaseUpdate = configOld.checkPreReleaseUpdate,
328-
enableSecurityProtocolTls13 = configOld.enableSecurityProtocolTls13,
329-
trayMenuServersLimit = configOld.trayMenuServersLimit,
330-
};
331-
}
332-
333-
GetDefaultServer(config);
334-
GetDefaultRouting(config);
335-
SaveConfig(config);
336-
LoadConfig(ref config);
337-
338-
return 0;
339-
}
243+
//public static int ImportOldGuiConfig(Config config, string fileName)
244+
//{
245+
// var result = Utils.LoadResource(fileName);
246+
// if (Utils.IsNullOrEmpty(result))
247+
// {
248+
// return -1;
249+
// }
250+
251+
// var configOld = JsonUtils.Deserialize<ConfigOld>(result);
252+
// if (configOld == null)
253+
// {
254+
// return -1;
255+
// }
256+
257+
// var subItem = JsonUtils.Deserialize<List<SubItem>>(JsonUtils.Serialize(configOld.subItem));
258+
// foreach (var it in subItem)
259+
// {
260+
// if (Utils.IsNullOrEmpty(it.id))
261+
// {
262+
// it.id = Utils.GetGUID(false);
263+
// }
264+
// SQLiteHelper.Instance.Replace(it);
265+
// }
266+
267+
// var profileItems = JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(configOld.vmess));
268+
// foreach (var it in profileItems)
269+
// {
270+
// if (Utils.IsNullOrEmpty(it.indexId))
271+
// {
272+
// it.indexId = Utils.GetGUID(false);
273+
// }
274+
// SQLiteHelper.Instance.Replace(it);
275+
// }
276+
277+
// foreach (var it in configOld.routings)
278+
// {
279+
// if (it.locked)
280+
// {
281+
// continue;
282+
// }
283+
// var routing = JsonUtils.Deserialize<RoutingItem>(JsonUtils.Serialize(it));
284+
// foreach (var it2 in it.rules)
285+
// {
286+
// it2.id = Utils.GetGUID(false);
287+
// }
288+
// routing.ruleNum = it.rules.Count;
289+
// routing.ruleSet = JsonUtils.Serialize(it.rules, false);
290+
291+
// if (Utils.IsNullOrEmpty(routing.id))
292+
// {
293+
// routing.id = Utils.GetGUID(false);
294+
// }
295+
// SQLiteHelper.Instance.Replace(routing);
296+
// }
297+
298+
// config = JsonUtils.Deserialize<Config>(JsonUtils.Serialize(configOld));
299+
300+
// if (config.coreBasicItem == null)
301+
// {
302+
// config.coreBasicItem = new()
303+
// {
304+
// logEnabled = configOld.logEnabled,
305+
// loglevel = configOld.loglevel,
306+
// muxEnabled = configOld.muxEnabled,
307+
// };
308+
// }
309+
310+
// if (config.routingBasicItem == null)
311+
// {
312+
// config.routingBasicItem = new()
313+
// {
314+
// enableRoutingAdvanced = configOld.enableRoutingAdvanced,
315+
// domainStrategy = configOld.domainStrategy
316+
// };
317+
// }
318+
319+
// if (config.guiItem == null)
320+
// {
321+
// config.guiItem = new()
322+
// {
323+
// enableStatistics = configOld.enableStatistics,
324+
// keepOlderDedupl = configOld.keepOlderDedupl,
325+
// ignoreGeoUpdateCore = configOld.ignoreGeoUpdateCore,
326+
// autoUpdateInterval = configOld.autoUpdateInterval,
327+
// checkPreReleaseUpdate = configOld.checkPreReleaseUpdate,
328+
// enableSecurityProtocolTls13 = configOld.enableSecurityProtocolTls13,
329+
// trayMenuServersLimit = configOld.trayMenuServersLimit,
330+
// };
331+
// }
332+
333+
// GetDefaultServer(config);
334+
// GetDefaultRouting(config);
335+
// SaveConfig(config);
336+
// LoadConfig(ref config);
337+
338+
// return 0;
339+
//}
340340

341341
#endregion ConfigHandler
342342

v2rayN/v2rayN/Resx/ResUI.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

v2rayN/v2rayN/Resx/ResUI.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,4 +1216,7 @@
12161216
<data name="NeedRebootTips" xml:space="preserve">
12171217
<value>Successful operation. Click the settings menu to reboot the app.</value>
12181218
</data>
1219+
<data name="menuOpenTheFileLocation" xml:space="preserve">
1220+
<value>Open the storage location</value>
1221+
</data>
12191222
</root>

v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,4 +1213,7 @@
12131213
<data name="NeedRebootTips" xml:space="preserve">
12141214
<value>操作成功。请点击设置菜单重启应用。</value>
12151215
</data>
1216+
<data name="menuOpenTheFileLocation" xml:space="preserve">
1217+
<value>打开存储所在的位置</value>
1218+
</data>
12161219
</root>

v2rayN/v2rayN/Resx/ResUI.zh-Hant.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,4 +1186,7 @@
11861186
<data name="NeedRebootTips" xml:space="preserve">
11871187
<value>操作成功。 請點選設定選單重啟應用程式。</value>
11881188
</data>
1189+
<data name="menuOpenTheFileLocation" xml:space="preserve">
1190+
<value>打開儲存所在的位置</value>
1191+
</data>
11891192
</root>

v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ public class MainWindowViewModel : ReactiveObject
143143
public ReactiveCommand<Unit, Unit> GlobalHotkeySettingCmd { get; }
144144
public ReactiveCommand<Unit, Unit> RebootAsAdminCmd { get; }
145145
public ReactiveCommand<Unit, Unit> ClearServerStatisticsCmd { get; }
146-
public ReactiveCommand<Unit, Unit> ImportOldGuiConfigCmd { get; }
146+
public ReactiveCommand<Unit, Unit> OpenTheFileLocationCmd { get; }
147+
//public ReactiveCommand<Unit, Unit> ImportOldGuiConfigCmd { get; }
147148

148149
//CheckUpdate
149150
public ReactiveCommand<Unit, Unit> CheckUpdateNCmd { get; }
@@ -503,10 +504,14 @@ public MainWindowViewModel(ISnackbarMessageQueue snackbarMessageQueue, Action<EV
503504
_statistics?.ClearAllServerStatistics();
504505
RefreshServers();
505506
});
506-
ImportOldGuiConfigCmd = ReactiveCommand.Create(() =>
507+
OpenTheFileLocationCmd = ReactiveCommand.Create(() =>
507508
{
508-
ImportOldGuiConfig();
509+
Utils.ProcessStart("Explorer", $"/select,{Utils.GetConfigPath()}");
509510
});
511+
//ImportOldGuiConfigCmd = ReactiveCommand.Create(() =>
512+
//{
513+
// ImportOldGuiConfig();
514+
//});
510515

511516
//CheckUpdate
512517
CheckUpdateNCmd = ReactiveCommand.Create(() =>
@@ -1422,32 +1427,32 @@ private void RebootAsAdmin()
14221427
catch { }
14231428
}
14241429

1425-
private void ImportOldGuiConfig()
1426-
{
1427-
if (UI.OpenFileDialog(out string fileName,
1428-
"guiNConfig|*.json|All|*.*") != true)
1429-
{
1430-
return;
1431-
}
1432-
if (Utils.IsNullOrEmpty(fileName))
1433-
{
1434-
return;
1435-
}
1436-
1437-
var ret = ConfigHandler.ImportOldGuiConfig(_config, fileName);
1438-
if (ret == 0)
1439-
{
1440-
RefreshRoutingsMenu();
1441-
InitSubscriptionView();
1442-
RefreshServers();
1443-
Reload();
1444-
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
1445-
}
1446-
else
1447-
{
1448-
_noticeHandler?.Enqueue(ResUI.OperationFailed);
1449-
}
1450-
}
1430+
//private void ImportOldGuiConfig()
1431+
//{
1432+
// if (UI.OpenFileDialog(out string fileName,
1433+
// "guiNConfig|*.json|All|*.*") != true)
1434+
// {
1435+
// return;
1436+
// }
1437+
// if (Utils.IsNullOrEmpty(fileName))
1438+
// {
1439+
// return;
1440+
// }
1441+
1442+
// var ret = ConfigHandler.ImportOldGuiConfig(_config, fileName);
1443+
// if (ret == 0)
1444+
// {
1445+
// RefreshRoutingsMenu();
1446+
// InitSubscriptionView();
1447+
// RefreshServers();
1448+
// Reload();
1449+
// _noticeHandler?.Enqueue(ResUI.OperationSuccess);
1450+
// }
1451+
// else
1452+
// {
1453+
// _noticeHandler?.Enqueue(ResUI.OperationFailed);
1454+
// }
1455+
//}
14511456

14521457
#endregion Setting
14531458

v2rayN/v2rayN/Views/MainWindow.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,13 @@
191191
Header="{x:Static resx:ResUI.menuClearServerStatistics}" />
192192
<Separator Margin="-40,5" />
193193
<MenuItem
194+
x:Name="menuOpenTheFileLocation"
195+
Height="{StaticResource MenuItemHeight}"
196+
Header="{x:Static resx:ResUI.menuOpenTheFileLocation}" />
197+
<!--<MenuItem
194198
x:Name="menuImportOldGuiConfig"
195199
Height="{StaticResource MenuItemHeight}"
196-
Header="{x:Static resx:ResUI.menuImportOldGuiConfig}" />
200+
Header="{x:Static resx:ResUI.menuImportOldGuiConfig}" />-->
197201
</MenuItem>
198202
</Menu>
199203
<Separator />

v2rayN/v2rayN/Views/MainWindow.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ public MainWindow()
138138
this.BindCommand(ViewModel, vm => vm.GlobalHotkeySettingCmd, v => v.menuGlobalHotkeySetting).DisposeWith(disposables);
139139
this.BindCommand(ViewModel, vm => vm.RebootAsAdminCmd, v => v.menuRebootAsAdmin).DisposeWith(disposables);
140140
this.BindCommand(ViewModel, vm => vm.ClearServerStatisticsCmd, v => v.menuClearServerStatistics).DisposeWith(disposables);
141-
this.BindCommand(ViewModel, vm => vm.ImportOldGuiConfigCmd, v => v.menuImportOldGuiConfig).DisposeWith(disposables);
141+
this.BindCommand(ViewModel, vm => vm.OpenTheFileLocationCmd, v => v.menuOpenTheFileLocation).DisposeWith(disposables);
142+
//this.BindCommand(ViewModel, vm => vm.ImportOldGuiConfigCmd, v => v.menuImportOldGuiConfig).DisposeWith(disposables);
142143

143144
//check update
144145
this.BindCommand(ViewModel, vm => vm.CheckUpdateNCmd, v => v.menuCheckUpdateN).DisposeWith(disposables);

v2rayN/v2rayN/v2rayN.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<PackageReference Include="TaskScheduler" Version="2.11.0" />
2424
<PackageReference Include="ZXing.Net.Bindings.Windows.Compatibility" Version="0.16.12" />
2525
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
26-
<PackageReference Include="ReactiveUI.Validation" Version="3.1.7" />
26+
<PackageReference Include="ReactiveUI.Validation" Version="4.0.6" />
2727
<PackageReference Include="ReactiveUI.WPF" Version="20.0.1" />
2828
<PackageReference Include="Splat.NLog" Version="15.0.1" />
2929
</ItemGroup>

0 commit comments

Comments
 (0)