diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/rule_list.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/rule_list.lua index 551d6612..27e863a1 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/rule_list.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/rule_list.lua @@ -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")) diff --git a/luci-app-passwall/po/zh-cn/passwall.po b/luci-app-passwall/po/zh-cn/passwall.po index dfb3bd63..a32f413f 100644 --- a/luci-app-passwall/po/zh-cn/passwall.po +++ b/luci-app-passwall/po/zh-cn/passwall.po @@ -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 行"