diff --git a/v2rayN/ProtosLib/ProtosLib.csproj b/v2rayN/ProtosLib/ProtosLib.csproj index 91569b53c5..dea1f90aa3 100644 --- a/v2rayN/ProtosLib/ProtosLib.csproj +++ b/v2rayN/ProtosLib/ProtosLib.csproj @@ -9,8 +9,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/v2rayN/ServiceLib/Enums/EConfigType.cs b/v2rayN/ServiceLib/Enums/EConfigType.cs index b7005e4a53..5c73e728ba 100644 --- a/v2rayN/ServiceLib/Enums/EConfigType.cs +++ b/v2rayN/ServiceLib/Enums/EConfigType.cs @@ -5,12 +5,12 @@ public enum EConfigType VMess = 1, Custom = 2, Shadowsocks = 3, - Socks = 4, + SOCKS = 4, VLESS = 5, Trojan = 6, Hysteria2 = 7, - Tuic = 8, - Wireguard = 9, - Http = 10 + TUIC = 8, + WireGuard = 9, + HTTP = 10 } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Global.cs b/v2rayN/ServiceLib/Global.cs index edbdd2a8cb..1451ea47bc 100644 --- a/v2rayN/ServiceLib/Global.cs +++ b/v2rayN/ServiceLib/Global.cs @@ -136,25 +136,25 @@ public class Global { {EConfigType.VMess,"vmess://"}, {EConfigType.Shadowsocks,"ss://"}, - {EConfigType.Socks,"socks://"}, + {EConfigType.SOCKS,"socks://"}, {EConfigType.VLESS,"vless://"}, {EConfigType.Trojan,"trojan://"}, {EConfigType.Hysteria2,"hysteria2://"}, - {EConfigType.Tuic,"tuic://"}, - {EConfigType.Wireguard,"wireguard://"} + {EConfigType.TUIC,"tuic://"}, + {EConfigType.WireGuard,"wireguard://"} }; public static readonly Dictionary ProtocolTypes = new() { {EConfigType.VMess,"vmess"}, {EConfigType.Shadowsocks,"shadowsocks"}, - {EConfigType.Socks,"socks"}, - {EConfigType.Http,"http"}, + {EConfigType.SOCKS,"socks"}, + {EConfigType.HTTP,"http"}, {EConfigType.VLESS,"vless"}, {EConfigType.Trojan,"trojan"}, {EConfigType.Hysteria2,"hysteria2"}, - {EConfigType.Tuic,"tuic"}, - {EConfigType.Wireguard,"wireguard"} + {EConfigType.TUIC,"tuic"}, + {EConfigType.WireGuard,"wireguard"} }; public static readonly List VmessSecurities = new() { "aes-128-gcm", "chacha20-poly1305", "auto", "none", "zero" }; @@ -165,7 +165,7 @@ public class Global public static readonly List Flows = new() { "", "xtls-rprx-vision", "xtls-rprx-vision-udp443" }; public static readonly List Networks = new() { "tcp", "kcp", "ws", "httpupgrade", "splithttp", "h2", "quic", "grpc" }; public static readonly List KcpHeaderTypes = new() { "srtp", "utp", "wechat-video", "dtls", "wireguard" }; - public static readonly List CoreTypes = new() { "v2fly", "SagerNet", "Xray", "sing_box" }; + public static readonly List CoreTypes = new() { "v2fly", "Xray", "sing_box" };//TODO public static readonly List CoreTypes4VLESS = new() { "Xray", "sing_box" }; public static readonly List DomainStrategies = new() { "AsIs", "IPIfNonMatch", "IPOnDemand" }; public static readonly List DomainStrategies4Singbox = new() { "ipv4_only", "ipv6_only", "prefer_ipv4", "prefer_ipv6", "" }; diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index fc092a82b3..2a4d97a41e 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -140,7 +140,14 @@ public static int LoadConfig(ref Config? config) } if (Utils.IsNullOrEmpty(config.uiItem.currentLanguage)) { - config.uiItem.currentLanguage = Global.Languages[2]; + if (Thread.CurrentThread.CurrentCulture.Name.Equals("zh-cn", StringComparison.CurrentCultureIgnoreCase)) + { + config.uiItem.currentLanguage = Global.Languages[0]; + } + else + { + config.uiItem.currentLanguage = Global.Languages[2]; + } } if (config.constItem == null) @@ -394,13 +401,13 @@ public static int AddServer(Config config, ProfileItem profileItem) { EConfigType.VMess => AddVMessServer(config, item), EConfigType.Shadowsocks => AddShadowsocksServer(config, item), - EConfigType.Socks => AddSocksServer(config, item), - EConfigType.Http => AddHttpServer(config, item), + EConfigType.SOCKS => AddSocksServer(config, item), + EConfigType.HTTP => AddHttpServer(config, item), EConfigType.Trojan => AddTrojanServer(config, item), EConfigType.VLESS => AddVlessServer(config, item), EConfigType.Hysteria2 => AddHysteria2Server(config, item), - EConfigType.Tuic => AddTuicServer(config, item), - EConfigType.Wireguard => AddWireguardServer(config, item), + EConfigType.TUIC => AddTuicServer(config, item), + EConfigType.WireGuard => AddWireguardServer(config, item), _ => -1, }; return ret; @@ -732,7 +739,7 @@ public static int AddShadowsocksServer(Config config, ProfileItem profileItem, b /// public static int AddSocksServer(Config config, ProfileItem profileItem, bool toFile = true) { - profileItem.configType = EConfigType.Socks; + profileItem.configType = EConfigType.SOCKS; profileItem.address = profileItem.address.TrimEx(); @@ -749,7 +756,7 @@ public static int AddSocksServer(Config config, ProfileItem profileItem, bool to /// public static int AddHttpServer(Config config, ProfileItem profileItem, bool toFile = true) { - profileItem.configType = EConfigType.Http; + profileItem.configType = EConfigType.HTTP; profileItem.address = profileItem.address.TrimEx(); @@ -822,7 +829,7 @@ public static int AddHysteria2Server(Config config, ProfileItem profileItem, boo /// public static int AddTuicServer(Config config, ProfileItem profileItem, bool toFile = true) { - profileItem.configType = EConfigType.Tuic; + profileItem.configType = EConfigType.TUIC; profileItem.coreType = ECoreType.sing_box; profileItem.address = profileItem.address.TrimEx(); @@ -861,7 +868,7 @@ public static int AddTuicServer(Config config, ProfileItem profileItem, bool toF /// public static int AddWireguardServer(Config config, ProfileItem profileItem, bool toFile = true) { - profileItem.configType = EConfigType.Wireguard; + profileItem.configType = EConfigType.WireGuard; profileItem.coreType = ECoreType.sing_box; profileItem.address = profileItem.address.TrimEx(); @@ -1256,12 +1263,12 @@ private static int AddBatchServers(Config config, string strData, string subid, { EConfigType.VMess => AddVMessServer(config, profileItem, false), EConfigType.Shadowsocks => AddShadowsocksServer(config, profileItem, false), - EConfigType.Socks => AddSocksServer(config, profileItem, false), + EConfigType.SOCKS => AddSocksServer(config, profileItem, false), EConfigType.Trojan => AddTrojanServer(config, profileItem, false), EConfigType.VLESS => AddVlessServer(config, profileItem, false), EConfigType.Hysteria2 => AddHysteria2Server(config, profileItem, false), - EConfigType.Tuic => AddTuicServer(config, profileItem, false), - EConfigType.Wireguard => AddWireguardServer(config, profileItem, false), + EConfigType.TUIC => AddTuicServer(config, profileItem, false), + EConfigType.WireGuard => AddWireguardServer(config, profileItem, false), _ => -1, }; diff --git a/v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigSingbox.cs b/v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigSingbox.cs index 32fc70e679..823c0b2961 100644 --- a/v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigSingbox.cs +++ b/v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigSingbox.cs @@ -606,7 +606,7 @@ private int GenOutbound(ProfileItem node, Outbound4Sbox outbound) GenOutboundMux(node, outbound); break; } - case EConfigType.Socks: + case EConfigType.SOCKS: { outbound.version = "5"; if (Utils.IsNotEmpty(node.security) @@ -617,7 +617,7 @@ private int GenOutbound(ProfileItem node, Outbound4Sbox outbound) } break; } - case EConfigType.Http: + case EConfigType.HTTP: { if (Utils.IsNotEmpty(node.security) && Utils.IsNotEmpty(node.id)) @@ -667,14 +667,14 @@ private int GenOutbound(ProfileItem node, Outbound4Sbox outbound) outbound.down_mbps = _config.hysteriaItem.down_mbps > 0 ? _config.hysteriaItem.down_mbps : null; break; } - case EConfigType.Tuic: + case EConfigType.TUIC: { outbound.uuid = node.id; outbound.password = node.security; outbound.congestion_control = node.headerType; break; } - case EConfigType.Wireguard: + case EConfigType.WireGuard: { outbound.private_key = node.id; outbound.peer_public_key = node.publicKey; @@ -1240,7 +1240,7 @@ private int GenDnsDomains(ProfileItem? node, SingboxConfig singboxConfig, DNSIte } //Tun2SocksAddress - if (_config.tunModeItem.enableTun && node?.configType == EConfigType.Socks && Utils.IsDomain(node?.sni)) + if (_config.tunModeItem.enableTun && node?.configType == EConfigType.SOCKS && Utils.IsDomain(node?.sni)) { dns4Sbox.rules.Insert(0, new() { diff --git a/v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigV2ray.cs b/v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigV2ray.cs index 23079d4408..263a2fa6fb 100644 --- a/v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigV2ray.cs +++ b/v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigV2ray.cs @@ -110,7 +110,7 @@ public int GenerateClientMultipleLoadConfig(List selecteds, out V2r { continue; } - if (it.configType is EConfigType.Hysteria2 or EConfigType.Tuic or EConfigType.Wireguard) + if (it.configType is EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.WireGuard) { continue; } @@ -647,8 +647,8 @@ private int GenOutbound(ProfileItem node, Outbounds4Ray outbound) outbound.settings.vnext = null; break; } - case EConfigType.Socks: - case EConfigType.Http: + case EConfigType.SOCKS: + case EConfigType.HTTP: { ServersItem4Ray serversItem; if (outbound.settings.servers.Count <= 0) @@ -1208,8 +1208,8 @@ private int GenMoreOutbounds(ProfileItem node, V2rayConfig v2rayConfig) if (prevNode is not null && prevNode.configType != EConfigType.Custom && prevNode.configType != EConfigType.Hysteria2 - && prevNode.configType != EConfigType.Tuic - && prevNode.configType != EConfigType.Wireguard) + && prevNode.configType != EConfigType.TUIC + && prevNode.configType != EConfigType.WireGuard) { var prevOutbound = JsonUtils.Deserialize(txtOutbound); GenOutbound(prevNode, prevOutbound); @@ -1227,8 +1227,8 @@ private int GenMoreOutbounds(ProfileItem node, V2rayConfig v2rayConfig) if (nextNode is not null && nextNode.configType != EConfigType.Custom && nextNode.configType != EConfigType.Hysteria2 - && nextNode.configType != EConfigType.Tuic - && nextNode.configType != EConfigType.Wireguard) + && nextNode.configType != EConfigType.TUIC + && nextNode.configType != EConfigType.WireGuard) { var nextOutbound = JsonUtils.Deserialize(txtOutbound); GenOutbound(nextNode, nextOutbound); diff --git a/v2rayN/ServiceLib/Handler/CoreHandler.cs b/v2rayN/ServiceLib/Handler/CoreHandler.cs index d17b3cdbba..0dc9c5fec5 100644 --- a/v2rayN/ServiceLib/Handler/CoreHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreHandler.cs @@ -66,7 +66,7 @@ public void LoadCore(ProfileItem? node) public int LoadCoreConfigSpeedtest(List selecteds) { int pid = -1; - var coreType = selecteds.Exists(t => t.configType == EConfigType.Hysteria2 || t.configType == EConfigType.Tuic || t.configType == EConfigType.Wireguard) ? ECoreType.sing_box : ECoreType.Xray; + var coreType = selecteds.Exists(t => t.configType == EConfigType.Hysteria2 || t.configType == EConfigType.TUIC || t.configType == EConfigType.WireGuard) ? ECoreType.sing_box : ECoreType.Xray; string configPath = Utils.GetConfigPath(Global.CoreSpeedtestConfigFileName); if (CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType, out string msg) != 0) { @@ -204,7 +204,7 @@ private void CoreStart(ProfileItem node) itemSocks = new ProfileItem() { coreType = preCoreType, - configType = EConfigType.Socks, + configType = EConfigType.SOCKS, address = Global.Loopback, sni = node.address, //Tun2SocksAddress port = LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks) @@ -216,7 +216,7 @@ private void CoreStart(ProfileItem node) itemSocks = new ProfileItem() { coreType = preCoreType, - configType = EConfigType.Socks, + configType = EConfigType.SOCKS, address = Global.Loopback, port = node.preSocksPort.Value, }; diff --git a/v2rayN/ServiceLib/Handler/Fmt/FmtHandler.cs b/v2rayN/ServiceLib/Handler/Fmt/FmtHandler.cs index 03e9bf96dd..95742f770b 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/FmtHandler.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/FmtHandler.cs @@ -10,12 +10,12 @@ public class FmtHandler { EConfigType.VMess => VmessFmt.ToUri(item), EConfigType.Shadowsocks => ShadowsocksFmt.ToUri(item), - EConfigType.Socks => SocksFmt.ToUri(item), + EConfigType.SOCKS => SocksFmt.ToUri(item), EConfigType.Trojan => TrojanFmt.ToUri(item), EConfigType.VLESS => VLESSFmt.ToUri(item), EConfigType.Hysteria2 => Hysteria2Fmt.ToUri(item), - EConfigType.Tuic => TuicFmt.ToUri(item), - EConfigType.Wireguard => WireguardFmt.ToUri(item), + EConfigType.TUIC => TuicFmt.ToUri(item), + EConfigType.WireGuard => WireguardFmt.ToUri(item), _ => null, }; @@ -49,7 +49,7 @@ public class FmtHandler { return ShadowsocksFmt.Resolve(str, out msg); } - else if (str.StartsWith(Global.ProtocolShares[EConfigType.Socks])) + else if (str.StartsWith(Global.ProtocolShares[EConfigType.SOCKS])) { return SocksFmt.Resolve(str, out msg); } @@ -65,11 +65,11 @@ public class FmtHandler { return Hysteria2Fmt.Resolve(str, out msg); } - else if (str.StartsWith(Global.ProtocolShares[EConfigType.Tuic])) + else if (str.StartsWith(Global.ProtocolShares[EConfigType.TUIC])) { return TuicFmt.Resolve(str, out msg); } - else if (str.StartsWith(Global.ProtocolShares[EConfigType.Wireguard])) + else if (str.StartsWith(Global.ProtocolShares[EConfigType.WireGuard])) { return WireguardFmt.Resolve(str, out msg); } diff --git a/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs index aab73da9c3..0f0df5fb67 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs @@ -17,7 +17,7 @@ public class SocksFmt : BaseFmt return null; } - item.configType = EConfigType.Socks; + item.configType = EConfigType.SOCKS; return item; } @@ -41,7 +41,7 @@ public class SocksFmt : BaseFmt //new var pw = Utils.Base64Encode($"{item.security}:{item.id}"); url = $"{pw}@{GetIpv6(item.address)}:{item.port}"; - url = $"{Global.ProtocolShares[EConfigType.Socks]}{url}{remark}"; + url = $"{Global.ProtocolShares[EConfigType.SOCKS]}{url}{remark}"; return url; } @@ -49,9 +49,9 @@ public class SocksFmt : BaseFmt { ProfileItem item = new() { - configType = EConfigType.Socks + configType = EConfigType.SOCKS }; - result = result[Global.ProtocolShares[EConfigType.Socks].Length..]; + result = result[Global.ProtocolShares[EConfigType.SOCKS].Length..]; //remark int indexRemark = result.IndexOf("#"); if (indexRemark > 0) diff --git a/v2rayN/ServiceLib/Handler/Fmt/TuicFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/TuicFmt.cs index 02268e6e66..bdfdce9189 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/TuicFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/TuicFmt.cs @@ -8,7 +8,7 @@ public class TuicFmt : BaseFmt ProfileItem item = new() { - configType = EConfigType.Tuic + configType = EConfigType.TUIC }; Uri url = new(str); @@ -57,7 +57,7 @@ public class TuicFmt : BaseFmt $"{item.id}:{item.security}", GetIpv6(item.address), item.port); - url = $"{Global.ProtocolShares[EConfigType.Tuic]}{url}{query}{remark}"; + url = $"{Global.ProtocolShares[EConfigType.TUIC]}{url}{query}{remark}"; return url; } } diff --git a/v2rayN/ServiceLib/Handler/Fmt/WireguardFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/WireguardFmt.cs index aaac166c45..743a82bef9 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/WireguardFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/WireguardFmt.cs @@ -8,7 +8,7 @@ public class WireguardFmt : BaseFmt ProfileItem item = new() { - configType = EConfigType.Wireguard + configType = EConfigType.WireGuard }; Uri url = new(str); @@ -62,7 +62,7 @@ public class WireguardFmt : BaseFmt Utils.UrlEncode(item.id), GetIpv6(item.address), item.port); - url = $"{Global.ProtocolShares[EConfigType.Wireguard]}{url}/{query}{remark}"; + url = $"{Global.ProtocolShares[EConfigType.WireGuard]}{url}/{query}{remark}"; return url; } } diff --git a/v2rayN/ServiceLib/Handler/LazyConfig.cs b/v2rayN/ServiceLib/Handler/LazyConfig.cs index afc1f7295f..e54ccdb0e9 100644 --- a/v2rayN/ServiceLib/Handler/LazyConfig.cs +++ b/v2rayN/ServiceLib/Handler/LazyConfig.cs @@ -38,6 +38,14 @@ public LazyConfig() SQLiteHelper.Instance.CreateTable(); SQLiteHelper.Instance.CreateTable(); SQLiteHelper.Instance.CreateTable(); + + //TODO + //Prepare to remove the clash + SQLiteHelper.Instance.Execute($"update ProfileItem set coreType = 13 where coreType = 11"); + SQLiteHelper.Instance.Execute($"update ProfileItem set coreType = 13 where coreType = 12"); + //Prepare to remove the SagerNet + SQLiteHelper.Instance.Execute($"update ProfileItem set coreType = 2 where coreType = 3"); + } #region Config diff --git a/v2rayN/ServiceLib/Handler/TaskHandler.cs b/v2rayN/ServiceLib/Handler/TaskHandler.cs index 0add446a87..b010d7160c 100644 --- a/v2rayN/ServiceLib/Handler/TaskHandler.cs +++ b/v2rayN/ServiceLib/Handler/TaskHandler.cs @@ -12,7 +12,7 @@ public TaskHandler() public void RegUpdateTask(Config config, Action update) { Task.Run(() => UpdateTaskRunSubscription(config, update)); - Task.Run(() => UpdateTaskRunGeo(config, update)); + //Task.Run(() => UpdateTaskRunGeo(config, update)); } private async Task UpdateTaskRunSubscription(Config config, Action update) diff --git a/v2rayN/ServiceLib/Handler/UpdateHandler.cs b/v2rayN/ServiceLib/Handler/UpdateHandler.cs index 49703f1cbd..263214c29e 100644 --- a/v2rayN/ServiceLib/Handler/UpdateHandler.cs +++ b/v2rayN/ServiceLib/Handler/UpdateHandler.cs @@ -276,7 +276,7 @@ private async Task CheckUpdateAsync(DownloadHandler downloadHan var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(type); var url = coreInfo?.coreReleaseApiUrl; - var result = await downloadHandle.DownloadStringAsync(url, true, Global.AppName); + var result = await downloadHandle.TryDownloadString(url, true, Global.AppName); if (Utils.IsNotEmpty(result)) { return await ParseDownloadUrl(type, result, preRelease); diff --git a/v2rayN/ServiceLib/Models/ConfigItems.cs b/v2rayN/ServiceLib/Models/ConfigItems.cs index d29d6c35a5..589cc628f5 100644 --- a/v2rayN/ServiceLib/Models/ConfigItems.cs +++ b/v2rayN/ServiceLib/Models/ConfigItems.cs @@ -94,7 +94,7 @@ public class GUIItem public bool ignoreGeoUpdateCore { get; set; } = true; - public int autoUpdateInterval { get; set; } = 10; + public int autoUpdateInterval { get; set; } public bool checkPreReleaseUpdate { get; set; } = false; diff --git a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs index edb0a9d92e..8f11ce226f 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs +++ b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs @@ -655,7 +655,7 @@ public static string menuAddCustomServer { } /// - /// 查找类似 Add [Http] server 的本地化字符串。 + /// 查找类似 Add [HTTP] server 的本地化字符串。 /// public static string menuAddHttpServer { get { @@ -700,7 +700,7 @@ public static string menuAddShadowsocksServer { } /// - /// 查找类似 Add [Socks] server 的本地化字符串。 + /// 查找类似 Add [SOCKS] server 的本地化字符串。 /// public static string menuAddSocksServer { get { @@ -718,7 +718,7 @@ public static string menuAddTrojanServer { } /// - /// 查找类似 Add [Tuic] server 的本地化字符串。 + /// 查找类似 Add [TUIC] server 的本地化字符串。 /// public static string menuAddTuicServer { get { @@ -745,7 +745,7 @@ public static string menuAddVmessServer { } /// - /// 查找类似 Add [Wireguard] server 的本地化字符串。 + /// 查找类似 Add [WireGuard] server 的本地化字符串。 /// public static string menuAddWireguardServer { get { diff --git a/v2rayN/ServiceLib/Resx/ResUI.resx b/v2rayN/ServiceLib/Resx/ResUI.resx index c9e7d71b02..1705e9aab5 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.resx @@ -536,7 +536,7 @@ Add [Shadowsocks] server - Add [Socks] server + Add [SOCKS] server Add [Trojan] server @@ -1094,7 +1094,7 @@ Use System Hosts - Add [Tuic] server + Add [TUIC] server Congestion control @@ -1115,7 +1115,7 @@ Enable IPv6 Address - Add [Wireguard] server + Add [WireGuard] server PrivateKey @@ -1148,7 +1148,7 @@ *grpc Authority - Add [Http] server + Add [HTTP] server Use Xray and enable non-Tun mode, which conflicts with the group previous proxy diff --git a/v2rayN/ServiceLib/Resx/ResUI.ru.resx b/v2rayN/ServiceLib/Resx/ResUI.ru.resx index 7c9abbf2aa..b24e9d54e5 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.ru.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.ru.resx @@ -536,7 +536,7 @@ Добавить сервер [Shadowsocks] - Добавить сервер [Socks] + Добавить сервер [SOCKS] Добавить сервер [Trojan] diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx index b88be0c546..cb144224b8 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx @@ -536,7 +536,7 @@ 添加[Shadowsocks]服务器 - 添加[Socks]服务器 + 添加[SOCKS]服务器 添加[Trojan]服务器 @@ -1091,7 +1091,7 @@ 使用系统hosts - 添加[Tuic]服务器 + 添加[TUIC]服务器 拥塞控制算法 @@ -1112,7 +1112,7 @@ 启用IPv6 - 添加[Wireguard]服务器 + 添加[WireGuard]服务器 PrivateKey @@ -1145,7 +1145,7 @@ *grpc Authority - 添加[Http]服务器 + 添加[HTTP]服务器 启用分片(Fragment) diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx index 913705fb35..35eec9e594 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx @@ -535,7 +535,7 @@ 新增[Shadowsocks]伺服器 - 新增[Socks]伺服器 + 新增[SOCKS]伺服器 新增[Trojan]伺服器 @@ -1082,7 +1082,7 @@ IP 或 IP CIDR - 新增[Tuic]伺服器 + 新增[TUIC]伺服器 前置代理別名 @@ -1118,7 +1118,7 @@ *grpc Authority - 新增[Http]伺服器 + 新增[HTTP]伺服器 啟用分片(Fragment) diff --git a/v2rayN/ServiceLib/ServiceLib.csproj b/v2rayN/ServiceLib/ServiceLib.csproj index 6f6bec694f..ca4e2c75ca 100644 --- a/v2rayN/ServiceLib/ServiceLib.csproj +++ b/v2rayN/ServiceLib/ServiceLib.csproj @@ -4,15 +4,15 @@ net8.0 enable enable - 6.59.0 + 6.60.0 - - + + - + diff --git a/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs b/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs index 7083d94b52..f0176f90f2 100644 --- a/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs @@ -21,7 +21,7 @@ public AddServerViewModel(ProfileItem profileItem, Func(); _updateView = updateView; - if (profileItem.id.IsNullOrEmpty()) + if (profileItem.indexId.IsNullOrEmpty()) { profileItem.network = Global.DefaultNetwork; profileItem.headerType = Global.None; @@ -74,8 +74,8 @@ private async Task SaveServerAsync() return; } } - if (SelectedSource.configType != EConfigType.Socks - && SelectedSource.configType != EConfigType.Http) + if (SelectedSource.configType != EConfigType.SOCKS + && SelectedSource.configType != EConfigType.HTTP) { if (Utils.IsNullOrEmpty(SelectedSource.id)) { diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index 7977bce281..07a08f29c7 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -14,6 +14,7 @@ public class MainWindowViewModel : MyReactiveObject #region private prop private CoreHandler _coreHandler; + private bool _isAdministrator { get; set; } #endregion private prop @@ -139,17 +140,16 @@ public class MainWindowViewModel : MyReactiveObject [Reactive] public int TabMainSelectedIndex { get; set; } - public bool IsAdministrator { get; set; } - #endregion UI #region Init - public MainWindowViewModel(Func>? updateView) + public MainWindowViewModel(bool isAdministrator, Func>? updateView) { _config = LazyConfig.Instance.Config; _noticeHandler = Locator.Current.GetService(); _updateView = updateView; + _isAdministrator = isAdministrator; MessageBus.Current.Listen(Global.CommandRefreshProfiles).Subscribe(async x => await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null)); @@ -158,6 +158,16 @@ public MainWindowViewModel(Func>? updateView) Init(); + _config.uiItem.showInTaskbar = true; + if (_config.tunModeItem.enableTun && _isAdministrator) + { + EnableTun = true; + } + else + { + _config.tunModeItem.enableTun = EnableTun = false; + } + #region WhenAnyValue && ReactiveCommand this.WhenAnyValue( @@ -196,11 +206,11 @@ public MainWindowViewModel(Func>? updateView) }); AddSocksServerCmd = ReactiveCommand.Create(() => { - AddServerAsync(true, EConfigType.Socks); + AddServerAsync(true, EConfigType.SOCKS); }); AddHttpServerCmd = ReactiveCommand.Create(() => { - AddServerAsync(true, EConfigType.Http); + AddServerAsync(true, EConfigType.HTTP); }); AddTrojanServerCmd = ReactiveCommand.Create(() => { @@ -212,11 +222,11 @@ public MainWindowViewModel(Func>? updateView) }); AddTuicServerCmd = ReactiveCommand.Create(() => { - AddServerAsync(true, EConfigType.Tuic); + AddServerAsync(true, EConfigType.TUIC); }); AddWireguardServerCmd = ReactiveCommand.Create(() => { - AddServerAsync(true, EConfigType.Wireguard); + AddServerAsync(true, EConfigType.WireGuard); }); AddCustomServerCmd = ReactiveCommand.Create(() => { @@ -319,8 +329,6 @@ public MainWindowViewModel(Func>? updateView) #endregion WhenAnyValue && ReactiveCommand AutoHideStartup(); - - _config.uiItem.showInTaskbar = true; } private void Init() @@ -767,7 +775,8 @@ public void SetListenerType(ESysProxyType type) private async Task ChangeSystemProxyStatusAsync(ESysProxyType type, bool blChange) { - await _updateView?.Invoke(EViewAction.UpdateSysProxy, _config.tunModeItem.enableTun ? true : false); + //await _updateView?.Invoke(EViewAction.UpdateSysProxy, _config.tunModeItem.enableTun ? true : false); + await _updateView?.Invoke(EViewAction.UpdateSysProxy, false); _noticeHandler?.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.systemProxyItem.sysProxyType.ToString()}"); BlSystemProxyClear = (type == ESysProxyType.ForcedClear); @@ -853,12 +862,13 @@ private void DoEnableTun(bool c) { _config.tunModeItem.enableTun = EnableTun; // When running as a non-administrator, reboot to administrator mode - if (EnableTun && !IsAdministrator) + if (EnableTun && !_isAdministrator) { _config.tunModeItem.enableTun = false; RebootAsAdmin(); return; } + ConfigHandler.SaveConfig(_config); Reload(); } } diff --git a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs index c3a2769011..010cceb027 100644 --- a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs @@ -85,8 +85,8 @@ public AddServerWindow(ProfileItem profileItem) }); break; - case EConfigType.Socks: - case EConfigType.Http: + case EConfigType.SOCKS: + case EConfigType.HTTP: gridSocks.IsVisible = true; break; @@ -121,7 +121,7 @@ public AddServerWindow(ProfileItem profileItem) cmbFingerprint.SelectedValue = string.Empty; break; - case EConfigType.Tuic: + case EConfigType.TUIC: gridTuic.IsVisible = true; sepa2.IsVisible = false; gridTransport.IsVisible = false; @@ -135,7 +135,7 @@ public AddServerWindow(ProfileItem profileItem) }); break; - case EConfigType.Wireguard: + case EConfigType.WireGuard: gridWireguard.IsVisible = true; sepa2.IsVisible = false; @@ -168,8 +168,8 @@ public AddServerWindow(ProfileItem profileItem) this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.cmbSecurity3.SelectedValue).DisposeWith(disposables); break; - case EConfigType.Socks: - case EConfigType.Http: + case EConfigType.SOCKS: + case EConfigType.HTTP: this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId4.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.txtSecurity4.Text).DisposeWith(disposables); break; @@ -190,13 +190,13 @@ public AddServerWindow(ProfileItem profileItem) this.Bind(ViewModel, vm => vm.SelectedSource.path, v => v.txtPath7.Text).DisposeWith(disposables); break; - case EConfigType.Tuic: + case EConfigType.TUIC: this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId8.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.txtSecurity8.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.headerType, v => v.cmbHeaderType8.SelectedValue).DisposeWith(disposables); break; - case EConfigType.Wireguard: + case EConfigType.WireGuard: this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId9.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.publicKey, v => v.txtPublicKey9.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.path, v => v.txtPath9.Text).DisposeWith(disposables); diff --git a/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml index 2ccaf5c634..5008bee10c 100644 --- a/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml @@ -95,7 +95,7 @@ BorderThickness="1" Classes="TextArea Margin8" TextWrapping="Wrap" - Watermark="Http/Socks" /> + Watermark="HTTP/SOCKS" /> @@ -153,7 +153,7 @@ BorderThickness="1" Classes="TextArea Margin8" TextWrapping="Wrap" - Watermark="Http/Socks" /> + Watermark="HTTP/SOCKS" /> diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs index d0f31977f7..65fefdf579 100644 --- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs @@ -34,8 +34,9 @@ public MainWindow() menuPromotion.Click += menuPromotion_Click; menuClose.Click += menuClose_Click; + var IsAdministrator = true;//WindowsUtils.IsAdministrator(); MessageBus.Current.Listen(Global.CommandSendSnackMsg).Subscribe(x => DelegateSnackMsg(x)); - ViewModel = new MainWindowViewModel(UpdateViewHandler); + ViewModel = new MainWindowViewModel(IsAdministrator, UpdateViewHandler); Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel)); //WindowsHandler.Instance.RegisterGlobalHotkey(_config, OnHotkeyHandler, null); @@ -114,24 +115,10 @@ public MainWindow() if (Utils.IsWindows()) { - var IsAdministrator = false;//WindowsUtils.IsAdministrator(); - ViewModel.IsAdministrator = IsAdministrator; this.Title = $"{Utils.GetVersion()} - {(IsAdministrator ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}"; - if (_config.tunModeItem.enableTun) - { - if (IsAdministrator) - { - ViewModel.EnableTun = true; - } - else - { - _config.tunModeItem.enableTun = ViewModel.EnableTun = false; - } - } } else { - ViewModel.IsAdministrator = true; this.Title = $"{Utils.GetVersion()}"; menuRebootAsAdmin.IsVisible = false; menuSettingsSetUWP.IsVisible = false; diff --git a/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj b/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj index 6e421b31d7..1eda6990bf 100644 --- a/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj +++ b/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj @@ -27,7 +27,7 @@ - + diff --git a/v2rayN/v2rayN/App.xaml b/v2rayN/v2rayN/App.xaml index 3b7aefeec9..e8c8bfb146 100644 --- a/v2rayN/v2rayN/App.xaml +++ b/v2rayN/v2rayN/App.xaml @@ -1,9 +1,9 @@  @@ -181,6 +181,23 @@ TargetType="{x:Type TextBlock}"> + + + \ No newline at end of file diff --git a/v2rayN/v2rayN/Views/AddServer2Window.xaml b/v2rayN/v2rayN/Views/AddServer2Window.xaml index 4e8b003c19..b196a21234 100644 --- a/v2rayN/v2rayN/Views/AddServer2Window.xaml +++ b/v2rayN/v2rayN/Views/AddServer2Window.xaml @@ -17,10 +17,9 @@ FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}" ResizeMode="NoResize" ShowInTaskbar="False" + Style="{StaticResource WindowGlobal}" TextElement.FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}" TextElement.Foreground="{DynamicResource MaterialDesignBody}" - TextOptions.TextFormattingMode="Display" - TextOptions.TextRenderingMode="Auto" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> diff --git a/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs b/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs index eceaeba47c..d9e59fb5d3 100644 --- a/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs +++ b/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs @@ -17,6 +17,9 @@ public AddServer2Window(ProfileItem profileItem) foreach (ECoreType it in Enum.GetValues(typeof(ECoreType))) { if (it == ECoreType.v2rayN) + continue; + //TODO + if (it is ECoreType.clash or ECoreType.clash_meta or ECoreType.SagerNet) continue; cmbCoreType.Items.Add(it.ToString()); } diff --git a/v2rayN/v2rayN/Views/AddServerWindow.xaml b/v2rayN/v2rayN/Views/AddServerWindow.xaml index 64fa23ec4a..f23efe2584 100644 --- a/v2rayN/v2rayN/Views/AddServerWindow.xaml +++ b/v2rayN/v2rayN/Views/AddServerWindow.xaml @@ -17,10 +17,9 @@ FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}" ResizeMode="CanResize" ShowInTaskbar="False" + Style="{StaticResource WindowGlobal}" TextElement.FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}" TextElement.Foreground="{DynamicResource MaterialDesignBody}" - TextOptions.TextFormattingMode="Display" - TextOptions.TextRenderingMode="Auto" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> diff --git a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs index cfcf5ceeb5..03de439054 100644 --- a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs @@ -79,8 +79,8 @@ public AddServerWindow(ProfileItem profileItem) }); break; - case EConfigType.Socks: - case EConfigType.Http: + case EConfigType.SOCKS: + case EConfigType.HTTP: gridSocks.Visibility = Visibility.Visible; break; @@ -115,7 +115,7 @@ public AddServerWindow(ProfileItem profileItem) cmbFingerprint.Text = string.Empty; break; - case EConfigType.Tuic: + case EConfigType.TUIC: gridTuic.Visibility = Visibility.Visible; sepa2.Visibility = Visibility.Collapsed; gridTransport.Visibility = Visibility.Collapsed; @@ -129,7 +129,7 @@ public AddServerWindow(ProfileItem profileItem) }); break; - case EConfigType.Wireguard: + case EConfigType.WireGuard: gridWireguard.Visibility = Visibility.Visible; sepa2.Visibility = Visibility.Collapsed; @@ -162,8 +162,8 @@ public AddServerWindow(ProfileItem profileItem) this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.cmbSecurity3.Text).DisposeWith(disposables); break; - case EConfigType.Socks: - case EConfigType.Http: + case EConfigType.SOCKS: + case EConfigType.HTTP: this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId4.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.txtSecurity4.Text).DisposeWith(disposables); break; @@ -184,13 +184,13 @@ public AddServerWindow(ProfileItem profileItem) this.Bind(ViewModel, vm => vm.SelectedSource.path, v => v.txtPath7.Text).DisposeWith(disposables); break; - case EConfigType.Tuic: + case EConfigType.TUIC: this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId8.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.txtSecurity8.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.headerType, v => v.cmbHeaderType8.Text).DisposeWith(disposables); break; - case EConfigType.Wireguard: + case EConfigType.WireGuard: this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId9.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.publicKey, v => v.txtPublicKey9.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.path, v => v.txtPath9.Text).DisposeWith(disposables); diff --git a/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml b/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml index 16b41c4421..219893bb5c 100644 --- a/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml +++ b/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml @@ -12,6 +12,7 @@ d:DesignHeight="600" d:DesignWidth="800" x:TypeArguments="vms:BackupAndRestoreViewModel" + Style="{StaticResource ViewGlobal}" mc:Ignorable="d"> diff --git a/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml.cs b/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml.cs index bf6b08bef0..34c6dc1d30 100644 --- a/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml.cs +++ b/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml.cs @@ -26,7 +26,7 @@ public BackupAndRestoreView() this.Bind(ViewModel, vm => vm.SelectedSource.userName, v => v.txtWebDavUserName.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.password, v => v.txtWebDavPassword.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.dirName, v => v.txtWebDavDirName.Text).DisposeWith(disposables); - + this.BindCommand(ViewModel, vm => vm.WebDavCheckCmd, v => v.menuWebDavCheck).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.RemoteBackupCmd, v => v.menuRemoteBackup).DisposeWith(disposables); diff --git a/v2rayN/v2rayN/Views/CheckUpdateView.xaml b/v2rayN/v2rayN/Views/CheckUpdateView.xaml index 0f101a0d51..6ec007ea37 100644 --- a/v2rayN/v2rayN/Views/CheckUpdateView.xaml +++ b/v2rayN/v2rayN/Views/CheckUpdateView.xaml @@ -12,6 +12,7 @@ d:DesignHeight="450" d:DesignWidth="800" x:TypeArguments="vms:CheckUpdateViewModel" + Style="{StaticResource ViewGlobal}" mc:Ignorable="d"> diff --git a/v2rayN/v2rayN/Views/ClashConnectionsView.xaml b/v2rayN/v2rayN/Views/ClashConnectionsView.xaml index b9e3ef5e2c..90ff314263 100644 --- a/v2rayN/v2rayN/Views/ClashConnectionsView.xaml +++ b/v2rayN/v2rayN/Views/ClashConnectionsView.xaml @@ -1,11 +1,11 @@ diff --git a/v2rayN/v2rayN/Views/DNSSettingWindow.xaml b/v2rayN/v2rayN/Views/DNSSettingWindow.xaml index 7776e4186c..0b69f7c950 100644 --- a/v2rayN/v2rayN/Views/DNSSettingWindow.xaml +++ b/v2rayN/v2rayN/Views/DNSSettingWindow.xaml @@ -17,10 +17,9 @@ FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}" ResizeMode="NoResize" ShowInTaskbar="False" + Style="{StaticResource WindowGlobal}" TextElement.FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}" TextElement.Foreground="{DynamicResource MaterialDesignBody}" - TextOptions.TextFormattingMode="Display" - TextOptions.TextRenderingMode="Auto" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> @@ -117,7 +116,7 @@ x:Name="txtnormalDNS" Margin="{StaticResource SettingItemMargin}" VerticalAlignment="Stretch" - materialDesign:HintAssist.Hint="Http/Socks" + materialDesign:HintAssist.Hint="HTTP/SOCKS" AcceptsReturn="True" BorderThickness="1" Style="{StaticResource MaterialDesignOutlinedTextBox}" @@ -186,7 +185,7 @@ x:Name="txtnormalDNS2" Grid.Column="0" VerticalAlignment="Stretch" - materialDesign:HintAssist.Hint="Http/Socks" + materialDesign:HintAssist.Hint="HTTP/SOCKS" AcceptsReturn="True" BorderThickness="1" Style="{StaticResource MaterialDesignOutlinedTextBox}" diff --git a/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml b/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml index 37bf6e235e..904217d2bc 100644 --- a/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml +++ b/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml @@ -18,10 +18,9 @@ KeyDown="GlobalHotkeySettingWindow_KeyDown" ResizeMode="NoResize" ShowInTaskbar="False" + Style="{StaticResource WindowGlobal}" TextElement.FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}" TextElement.Foreground="{DynamicResource MaterialDesignBody}" - TextOptions.TextFormattingMode="Display" - TextOptions.TextRenderingMode="Auto" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml b/v2rayN/v2rayN/Views/MainWindow.xaml index c8f3cf9ff0..9ed581b003 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml +++ b/v2rayN/v2rayN/Views/MainWindow.xaml @@ -18,10 +18,9 @@ Background="{DynamicResource MaterialDesignPaper}" FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}" ShowInTaskbar="True" + Style="{StaticResource WindowGlobal}" TextElement.FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}" TextElement.Foreground="{DynamicResource MaterialDesignBody}" - TextOptions.TextFormattingMode="Display" - TextOptions.TextRenderingMode="Auto" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs index a72718bbe6..37ab2720a2 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -36,8 +36,9 @@ public MainWindow() menuCheckUpdate.Click += MenuCheckUpdate_Click; menuBackupAndRestore.Click += MenuBackupAndRestore_Click; + var IsAdministrator = WindowsUtils.IsAdministrator(); MessageBus.Current.Listen(Global.CommandSendSnackMsg).Subscribe(x => DelegateSnackMsg(x)); - ViewModel = new MainWindowViewModel(UpdateViewHandler); + ViewModel = new MainWindowViewModel(IsAdministrator, UpdateViewHandler); Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel)); WindowsHandler.Instance.RegisterGlobalHotkey(_config, OnHotkeyHandler, null); @@ -143,20 +144,7 @@ public MainWindow() } }); - var IsAdministrator = WindowsUtils.IsAdministrator(); - ViewModel.IsAdministrator = IsAdministrator; this.Title = $"{Utils.GetVersion()} - {(IsAdministrator ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}"; - if (_config.tunModeItem.enableTun) - { - if (IsAdministrator) - { - ViewModel.EnableTun = true; - } - else - { - _config.tunModeItem.enableTun = ViewModel.EnableTun = false; - } - } if (!_config.guiItem.enableHWA) { @@ -505,7 +493,8 @@ private void AddHelpMenuItem() { var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(); foreach (var it in coreInfo - .Where(t => t.coreType != ECoreType.v2fly + .Where(t => t.coreType != ECoreType.v2fly + && t.coreType != ECoreType.SagerNet && t.coreType != ECoreType.clash && t.coreType != ECoreType.clash_meta && t.coreType != ECoreType.hysteria)) diff --git a/v2rayN/v2rayN/Views/MsgView.xaml b/v2rayN/v2rayN/Views/MsgView.xaml index 18445008ca..491950d72e 100644 --- a/v2rayN/v2rayN/Views/MsgView.xaml +++ b/v2rayN/v2rayN/Views/MsgView.xaml @@ -11,6 +11,7 @@ d:DesignHeight="450" d:DesignWidth="800" x:TypeArguments="vms:MsgViewModel" + Style="{StaticResource ViewGlobal}" mc:Ignorable="d"> diff --git a/v2rayN/v2rayN/Views/ProfilesView.xaml b/v2rayN/v2rayN/Views/ProfilesView.xaml index 5a5f1532e0..8bfe2d9824 100644 --- a/v2rayN/v2rayN/Views/ProfilesView.xaml +++ b/v2rayN/v2rayN/Views/ProfilesView.xaml @@ -13,6 +13,7 @@ d:DesignHeight="450" d:DesignWidth="800" x:TypeArguments="vms:ProfilesViewModel" + Style="{StaticResource ViewGlobal}" mc:Ignorable="d"> diff --git a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs index 625dadf668..49ad8ade83 100644 --- a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs +++ b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs @@ -338,24 +338,16 @@ private void RestoreUI() item2.Width = item.Width; item2.DisplayIndex = displayIndex++; } + if (item.Name.StartsWith("to")) + { + if (!_config.guiItem.enableStatistics) + { + item2.Visibility = Visibility.Hidden; + } + } } } } - - if (!_config.guiItem.enableStatistics) - { - colTodayUp.Visibility = - colTodayDown.Visibility = - colTotalUp.Visibility = - colTotalDown.Visibility = Visibility.Hidden; - } - else - { - colTodayUp.Visibility = - colTodayDown.Visibility = - colTotalUp.Visibility = - colTotalDown.Visibility = Visibility.Visible; - } } private void StorageUI() diff --git a/v2rayN/v2rayN/Views/QrcodeView.xaml b/v2rayN/v2rayN/Views/QrcodeView.xaml index 602138efcd..b24111c2b5 100644 --- a/v2rayN/v2rayN/Views/QrcodeView.xaml +++ b/v2rayN/v2rayN/Views/QrcodeView.xaml @@ -8,6 +8,7 @@ xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib" d:DesignHeight="300" d:DesignWidth="300" + Style="{StaticResource ViewGlobal}" mc:Ignorable="d"> diff --git a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml index 7ff01c0a61..4de2a494db 100644 --- a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml +++ b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml @@ -1,14 +1,14 @@  diff --git a/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml b/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml index 1292f71448..cf2d465445 100644 --- a/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml +++ b/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml @@ -1,14 +1,14 @@  diff --git a/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml b/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml index 11be6eb397..18bc01681b 100644 --- a/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml +++ b/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml @@ -17,10 +17,9 @@ FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}" ResizeMode="NoResize" ShowInTaskbar="False" + Style="{StaticResource WindowGlobal}" TextElement.FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}" TextElement.Foreground="{DynamicResource MaterialDesignBody}" - TextOptions.TextFormattingMode="Display" - TextOptions.TextRenderingMode="Auto" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> diff --git a/v2rayN/v2rayN/Views/SubEditWindow.xaml b/v2rayN/v2rayN/Views/SubEditWindow.xaml index f56ad0dfe5..b571a74d19 100644 --- a/v2rayN/v2rayN/Views/SubEditWindow.xaml +++ b/v2rayN/v2rayN/Views/SubEditWindow.xaml @@ -1,14 +1,14 @@  diff --git a/v2rayN/v2rayN/Views/SubSettingWindow.xaml b/v2rayN/v2rayN/Views/SubSettingWindow.xaml index 4c7abbaf53..65177272d7 100644 --- a/v2rayN/v2rayN/Views/SubSettingWindow.xaml +++ b/v2rayN/v2rayN/Views/SubSettingWindow.xaml @@ -17,10 +17,9 @@ FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}" ResizeMode="NoResize" ShowInTaskbar="False" + Style="{StaticResource WindowGlobal}" TextElement.FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}" TextElement.Foreground="{DynamicResource MaterialDesignBody}" - TextOptions.TextFormattingMode="Display" - TextOptions.TextRenderingMode="Auto" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> diff --git a/v2rayN/v2rayN/v2rayN.csproj b/v2rayN/v2rayN/v2rayN.csproj index 01628743be..66d3e499ac 100644 --- a/v2rayN/v2rayN/v2rayN.csproj +++ b/v2rayN/v2rayN/v2rayN.csproj @@ -19,7 +19,7 @@ - +