Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
luci-app-passwall: improve performance
Browse files Browse the repository at this point in the history
SakuraFallingMad committed Dec 10, 2024
1 parent 5d3fd8b commit 0ebe7b7
Showing 2 changed files with 48 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -278,8 +278,20 @@ if api.fs.access(gfwlist_path) then
o.rows = 45
o.wrap = "off"
o.cfgvalue = function(self, section)
return fs.readfile(gfwlist_path) or ""
local limit = 100 -- 限制行数
local cmd = string.format("head -n %d %s", limit, gfwlist_path)
return api.sys.exec(cmd) or ""
-- return fs.readfile(gfwlist_path) or ""
end
local total_lines_cmd = string.format("wc -l < %s", gfwlist_path)
local total_lines = tonumber(api.sys.exec(total_lines_cmd)) or 0
local displayed_lines = 100

local total_lines_label = s:taboption("gfw_list", DummyValue, "total_lines", translate("Total Lines"))
total_lines_label.value = translatef("%d lines", total_lines)

local displayed_lines_label = s:taboption("gfw_list", DummyValue, "displayed_lines", translate("Displayed Lines"))
displayed_lines_label.value = translatef("%d lines", displayed_lines)
end

if api.fs.access(chnlist_path) then
@@ -289,8 +301,20 @@ if api.fs.access(chnlist_path) then
o.rows = 45
o.wrap = "off"
o.cfgvalue = function(self, section)
return fs.readfile(chnlist_path) or ""
local limit = 100 -- 限制行数
local cmd = string.format("head -n %d %s", limit, chnlist_path)
return api.sys.exec(cmd) or ""
-- return fs.readfile(chnlist_path) or ""
end
local total_lines_cmd = string.format("wc -l < %s", chnlist_path)
local total_lines = tonumber(api.sys.exec(total_lines_cmd)) or 0
local displayed_lines = 100

local total_lines_label = s:taboption("chn_list", DummyValue, "total_lines", translate("Total Lines"))
total_lines_label.value = translatef("%d lines", total_lines)

local displayed_lines_label = s:taboption("chn_list", DummyValue, "displayed_lines", translate("Displayed Lines"))
displayed_lines_label.value = translatef("%d lines", displayed_lines)
end

if api.fs.access(chnroute_path) then
@@ -300,8 +324,20 @@ if api.fs.access(chnroute_path) then
o.rows = 45
o.wrap = "off"
o.cfgvalue = function(self, section)
return fs.readfile(chnroute_path) or ""
local limit = 100 -- 限制行数
local cmd = string.format("head -n %d %s", limit, chnroute_path)
return api.sys.exec(cmd) or ""
-- return fs.readfile(chnroute_path) or ""
end
local total_lines_cmd = string.format("wc -l < %s", chnroute_path)
local total_lines = tonumber(api.sys.exec(total_lines_cmd)) or 0
local displayed_lines = 100

local total_lines_label = s:taboption("chnroute_list", DummyValue, "total_lines", translate("Total Lines"))
total_lines_label.value = translatef("%d lines", total_lines)

local displayed_lines_label = s:taboption("chnroute_list", DummyValue, "displayed_lines", translate("Displayed Lines"))
displayed_lines_label.value = translatef("%d lines", displayed_lines)
end

m:append(Template(appname .. "/rule_list/js"))
9 changes: 9 additions & 0 deletions applications/luci-app-passwall/po/zh_Hans/passwall.po
Original file line number Diff line number Diff line change
@@ -1725,3 +1725,12 @@ msgstr "与使用 %s 节点时生效。"

msgid "Set the default domain resolution strategy for the sing-box node."
msgstr "为 sing-box 节点设置默认的域名解析策略。"

msgid "Total Lines"
msgstr "总行数:"

msgid "Displayed Lines"
msgstr "展示行数:"

msgid "%d lines"
msgstr "%d 行"

0 comments on commit 0ebe7b7

Please sign in to comment.