From c20a1449f1ef44e0c4a4e6e7e15c9d57f9d8bd00 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 11 Jun 2022 20:16:47 +0800 Subject: [PATCH] update 2022-06-11 20:16:47 --- luci-app-openclash/luasrc/controller/openclash.lua | 7 +++++-- luci-app-openclash/luasrc/view/openclash/sub_info_show.htm | 6 +++--- natflow/Makefile | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/luci-app-openclash/luasrc/controller/openclash.lua b/luci-app-openclash/luasrc/controller/openclash.lua index ddf63dff7..e03b17d3e 100644 --- a/luci-app-openclash/luasrc/controller/openclash.lua +++ b/luci-app-openclash/luasrc/controller/openclash.lua @@ -596,7 +596,9 @@ function sub_info_get() download = string.sub(string.match(info, "download=%d+"), 10, -1) or nil total = tonumber(string.format("%.1f",string.sub(string.match(info, "total=%d+"), 7, -1))) or nil used = tonumber(string.format("%.1f",(upload + download))) or nil - day_expire = tonumber(string.sub(string.match(info, "expire=%d+"), 8, -1)) or nil + if string.match(info, "expire=%d+") then + day_expire = tonumber(string.sub(string.match(info, "expire=%d+"), 8, -1)) or nil + end expire = os.date("%Y-%m-%d", day_expire) or "null" if day_expire and os.time() <= day_expire then day_left = math.ceil((day_expire - os.time()) / (3600*24)) @@ -605,6 +607,7 @@ function sub_info_get() else day_left = 0 end + if used and total and used <= total then percent = string.format("%.1f",(used/total)*100) or nil elseif used == nil or total == nil or total == 0 then @@ -1491,4 +1494,4 @@ function process_status(name) else return luci.sys.call(string.format("ps -w |grep '%s' |grep -v grep >/dev/null", name)) == 0 end -end \ No newline at end of file +end diff --git a/luci-app-openclash/luasrc/view/openclash/sub_info_show.htm b/luci-app-openclash/luasrc/view/openclash/sub_info_show.htm index bf162b889..95f9b6e61 100644 --- a/luci-app-openclash/luasrc/view/openclash/sub_info_show.htm +++ b/luci-app-openclash/luasrc/view/openclash/sub_info_show.htm @@ -39,9 +39,9 @@ sub_info_get_<%=idname%>(); function progressbar_<%=idname%>(v, m, pc, np, f, t, tr) { return String.format( '