Improve traffic refresh

This commit is contained in:
2dust 2023-01-03 15:11:34 +08:00
parent 43b96ea4e5
commit 0f099a19cd
5 changed files with 25 additions and 7 deletions

View file

@ -91,6 +91,10 @@ namespace v2rayN.Handler
if (Global.ShowInTaskbar) if (Global.ShowInTaskbar)
{ {
server.indexId = config_.indexId; server.indexId = config_.indexId;
server.todayUp = _serverStatItem.todayUp;
server.todayDown = _serverStatItem.todayDown;
server.totalUp = _serverStatItem.totalUp;
server.totalDown = _serverStatItem.totalDown;
updateFunc_(server); updateFunc_(server);
} }
if (server.proxyUp != 0 || server.proxyDown != 0) if (server.proxyUp != 0 || server.proxyDown != 0)

View file

@ -1,12 +1,8 @@
namespace v2rayN.Mode namespace v2rayN.Mode
{ {
[Serializable] [Serializable]
class ServerSpeedItem class ServerSpeedItem : ServerStatItem
{ {
public string indexId
{
get; set;
}
public long proxyUp public long proxyUp
{ {
get; set; get; set;

View file

@ -533,6 +533,24 @@ namespace v2rayN.ViewModels
} }
SpeedProxyDisplay = string.Format("{0}:{1}/s¡ü | {2}/s¡ý", Global.agentTag, Utils.HumanFy(update.proxyUp), Utils.HumanFy(update.proxyDown)); SpeedProxyDisplay = string.Format("{0}:{1}/s¡ü | {2}/s¡ý", Global.agentTag, Utils.HumanFy(update.proxyUp), Utils.HumanFy(update.proxyDown));
SpeedDirectDisplay = string.Format("{0}:{1}/s¡ü | {2}/s¡ý", Global.directTag, Utils.HumanFy(update.directUp), Utils.HumanFy(update.directDown)); SpeedDirectDisplay = string.Format("{0}:{1}/s¡ü | {2}/s¡ý", Global.directTag, Utils.HumanFy(update.directUp), Utils.HumanFy(update.directDown));
if (update.proxyUp + update.proxyDown > 0)
{
var second = DateTime.Now.Second;
if (second % 3 == 0)
{
var item = _profileItems.Where(it => it.indexId == update.indexId).FirstOrDefault();
if (item != null)
{
item.todayDown = Utils.HumanFy(update.todayDown);
item.todayUp = Utils.HumanFy(update.todayUp);
item.totalDown = Utils.HumanFy(update.totalDown);
item.totalUp = Utils.HumanFy(update.totalUp);
_profileItems.Replace(item, Utils.DeepCopy(item));
}
}
}
})); }));
} }
catch (Exception ex) catch (Exception ex)