🎄 Sync 2025-11-29 00:11:57

This commit is contained in:
actions-user
2025-11-29 00:11:57 +08:00
parent 308506363e
commit d460bcc564
5 changed files with 46 additions and 18 deletions

View File

@@ -3984,6 +3984,11 @@ function downsampleForMobile(data, labels, upSeries, downSeries, maxPoints) {
if (allDeviceRules.length === 0) {
rulesInfo.appendChild(E('div', { 'style': 'font-size: 0.75rem; opacity: 0.6;' }, '-'));
} else {
// 显示规则总数
rulesInfo.appendChild(E('div', {
'style': 'font-size: 0.75rem; font-weight: 600; margin-bottom: 4px;'
}, allDeviceRules.length + ' ' + (allDeviceRules.length === 1 ? _('rule') : _('rules'))));
// 显示当前生效的规则
if (activeRules.length > 0) {
// 合并多个规则的限制值
@@ -3991,11 +3996,6 @@ function downsampleForMobile(data, labels, upSeries, downSeries, maxPoints) {
var uploadLimit = mergedLimits.uploadLimit;
var downloadLimit = mergedLimits.downloadLimit;
// 显示规则数量
rulesInfo.appendChild(E('div', {
'style': 'font-size: 0.75rem; font-weight: 600; margin-bottom: 4px;'
}, activeRules.length + ' ' + (activeRules.length === 1 ? _('rule') : _('rules'))));
// 显示限速值(箭头固定颜色,文字默认颜色)
var limitsContainer = E('div', {
'style': 'font-size: 0.75rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;'
@@ -4208,17 +4208,17 @@ function downsampleForMobile(data, labels, upSeries, downSeries, maxPoints) {
var rulesContent = E('div', { 'class': 'device-card-rules-content' });
// 显示规则总数
rulesContent.appendChild(E('div', {
'class': 'device-card-rules-count'
}, allDeviceRules.length + ' ' + (allDeviceRules.length === 1 ? _('rule') : _('rules'))));
if (activeRules.length > 0) {
// 合并多个规则的限制值
var mergedLimits = mergeActiveRulesLimits(activeRules);
var uploadLimit = mergedLimits.uploadLimit;
var downloadLimit = mergedLimits.downloadLimit;
// 显示规则数量
rulesContent.appendChild(E('div', {
'class': 'device-card-rules-count'
}, activeRules.length + ' ' + (activeRules.length === 1 ? _('rule') : _('rules'))));
// 显示限速值
var limitsText = [];
limitsText.push('↑' + (uploadLimit > 0 ? formatByterate(uploadLimit, speedUnit) : _('Unlimited')));

View File

@@ -3,13 +3,19 @@ local api = require "luci.passwall.api"
-%>
<script type="text/javascript">
//<![CDATA[
var log_textarea = null;
var first_load_done = false;
function scrollToBottom() {
log_textarea.scrollTop = log_textarea.scrollHeight;
}
function clearlog(btn) {
XHR.get('<%=api.url("clear_log")%>', null,
function(x, data) {
if(x && x.status == 200) {
var log_textarea = document.getElementById('log_textarea');
if(x && x.status == 200 && log_textarea) {
log_textarea.innerHTML = "";
log_textarea.scrollTop = log_textarea.scrollHeight;
scrollToBottom();
}
}
);
@@ -18,8 +24,16 @@ local api = require "luci.passwall.api"
XHR.poll(5, '<%=api.url("get_log")%>', null,
function(x, data) {
if(x && x.status == 200) {
var log_textarea = document.getElementById('log_textarea');
if (!log_textarea) log_textarea = document.getElementById('log_textarea');
var wasBottom = (log_textarea.scrollTop + log_textarea.clientHeight >= log_textarea.scrollHeight - 10);
log_textarea.innerHTML = x.responseText;
if (!first_load_done) {
scrollToBottom();
first_load_done = true;
}
else if (wasBottom) {
scrollToBottom();
}
}
}
);

View File

@@ -52,7 +52,7 @@ local api = require "luci.passwall.api"
function add_node() {
var nodes_link = document.getElementById("nodes_link").value;
var group = (document.querySelector('#addlink_group_custom input[type="hidden"]')?.value || "default");
nodes_link = nodes_link.replace(/\t/g, "").replace(/\r\n|\r/g, "\n").replace(/\s+/g, '').replace(/<[^>]*>/g, '').trim();
nodes_link = nodes_link.replace(/\t/g, "").replace(/\r\n|\r/g, "\n").replace(/<[^>]*>/g, '').trim();
if (nodes_link != "") {
var s = nodes_link.split('://');
if (s.length > 1) {

View File

@@ -1804,7 +1804,9 @@ local function update_node(manual)
end
end
luci.sys.call("/etc/init.d/" .. appname .. " restart > /dev/null 2>&1 &")
if manual ~= 1 then
luci.sys.call("/etc/init.d/" .. appname .. " restart > /dev/null 2>&1 &")
end
end
local function parse_link(raw, add_mode, group, cfgid)

View File

@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=bandix
PKG_VERSION:=0.9.0
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_LICENSE:=Apache-2.0
PKG_MAINTAINER:=timsaya
@@ -50,13 +50,25 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_BIN) ./files/bandix.init $(1)/etc/init.d/bandix
$(INSTALL_CONF) ./files/bandix.config $(1)/etc/config/bandix
# 将配置文件安装到临时位置,由 postinst 决定是否复制到最终位置
$(INSTALL_DIR) $(1)/usr/share/bandix
$(INSTALL_CONF) ./files/bandix.config $(1)/usr/share/bandix/bandix.config.default
endef
define Package/$(PKG_NAME)/conffiles
/etc/config/bandix
endef
define Package/$(PKG_NAME)/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
# 检查配置文件是否存在,如果不存在才从默认配置复制
if [ ! -f /etc/config/bandix ]; then
cp /usr/share/bandix/bandix.config.default /etc/config/bandix
fi
# 添加到 sysupgrade.conf 以在系统升级时保留
if ! grep -q "^/usr/share/bandix$$" /etc/sysupgrade.conf; then
echo "/usr/share/bandix" >> /etc/sysupgrade.conf
fi