🎉 Sync 2026-03-12 23:47:33

This commit is contained in:
github-actions[bot] committed 2026-03-12 23:47:33 +08:00
1 parent 9438cde050
commit 6831af15af
21 files changed
+168 -410

No files matched your search

@@ -143,24 +143,35 @@ return view.extend({
clientTable.appendChild(E('tr', { 'class': 'tr table-titles' }, [
E('th', { 'class': 'th' }, _('IP Address')),
E('th', { 'class': 'th' }, _('MAC Address')),
E('th', { 'class': 'th' }, _('Status')),
E('th', { 'class': 'th' }, _('Name')),
E('th', { 'class': 'th' }, _('Online Time')),
E('th', { 'class': 'th' }, _('Connection Type')),
E('th', { 'class': 'th' }, _('Gateway ID'))
E('th', { 'class': 'th' }, _('Gateway ID')),
E('th', { 'class': 'th' }, _('Download Rate')),
E('th', { 'class': 'th' }, _('Upload Rate'))
]));
data.clients.forEach(function(client) {
var statusText = client.status === 1 ? _('Online') : _('Offline');
var onlineTime = formatOnlineTime(client.online_time || 0);
var connectionType = client.wired ? _('Wired') : _('Wireless');
// compute combined v4+v6 rates if present
var dl_rate = 0;
var ul_rate = 0;
if (client.traffic) {
dl_rate = (client.traffic.incoming_rate || 0) + (client.traffic.incoming_rate_v6 || 0);
ul_rate = (client.traffic.outgoing_rate || 0) + (client.traffic.outgoing_rate_v6 || 0);
}
clientTable.appendChild(E('tr', { 'class': 'tr' }, [
E('td', { 'class': 'td' }, client.ip || '-'),
E('td', { 'class': 'td' }, client.mac || '-'),
E('td', { 'class': 'td' }, statusText),
E('td', { 'class': 'td' }, client.name || '-'),
E('td', { 'class': 'td' }, onlineTime),
E('td', { 'class': 'td' }, connectionType),
E('td', { 'class': 'td' }, client.gw_id || '-')
E('td', { 'class': 'td' }, client.gw_id || '-'),
E('td', { 'class': 'td' }, formatRate(dl_rate)),
E('td', { 'class': 'td' }, formatRate(ul_rate))
]));
});
@@ -232,6 +243,19 @@ return view.extend({
return parts.join(' ');
}
// Helper to format byte-per-second rates into human readable strings
function formatRate(bps) {
if (!bps || bps === 0) return '-';
var units = ['B/s','KB/s','MB/s','GB/s'];
var idx = 0;
var value = bps;
while (value >= 1024 && idx < units.length - 1) {
value = value / 1024;
idx++;
}
return value.toFixed(value < 10 ? 2 : (value < 100 ? 1 : 0)) + ' ' + units[idx];
}
// Helper function to get auth mode text
function getAuthModeText(mode) {
switch(mode) {
@@ -399,6 +399,13 @@ msgstr " 使用,请先从 "
msgid " first."
msgstr " 中移除。"
# Client status UI additions
msgid "Download Rate"
msgstr "下载速率"
msgid "Upload Rate"
msgstr "上传速率"
#~ msgid "Down. (Bytes / Pkts.)"
#~ msgstr "下载(字节 / 数据包)"
+17 -197
View File
@@ -1,201 +1,21 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
MIT License
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
Copyright (c) 2025 sirpdboy
1. Definitions.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+2 -2
View File
@@ -7,8 +7,8 @@
include $(TOPDIR)/rules.mk
NAME:=kucat-config
PKG_NAME:=luci-app-$(NAME)
PKG_VERSION:=2.2.0
PKG_RELEASE:=1
PKG_VERSION:=2.2.1
PKG_RELEASE:=2
PKG_MAINTAINER:=sirpdboy team <herboy2008@gmail.com>
@@ -66,7 +66,7 @@ msgid "Shadow layering effect"
msgstr "阴影层次效果"
msgid "RGB color values"
msgstr "RGB颜色取值"
msgstr "颜色RGB获取工具"
msgid "Wallpaper synchronization"
msgstr "壁纸同步"
@@ -349,6 +349,6 @@ msgstr "你确定删除选择的 %d 个文件?"
msgid "Please select files to delete."
msgstr "请选择要删除的文件"
msgid ""
msgstr ""
msgid "Save current settings"
msgstr "存储当前设置"
+2 -2
View File
@@ -10,8 +10,8 @@ PKG_NAME:=luci-app-partexp
LUCI_TITLE:=LuCI Support for Automatic Partition Mount
LUCI_PKGARCH:=all
LUCI_DEPENDS:=+fdisk +block-mount +bc +blkid +parted +btrfs-progs +losetup +resize2fs +e2fsprogs +f2fs-tools +kmod-loop
PKG_VERSION:=2.0.3
PKG_RELEASE:=2
PKG_VERSION:=2.0.4
PKG_RELEASE:=3
PKG_LICENSE:=Apache-2.0
PKG_MAINTAINER:=Sirpdboy <herboy2008@gmail.com>
@@ -194,7 +194,6 @@ return view.extend({
var self = this;
// uci 对象已经在全局作用域可用
var uci = self.uci || window.uci;
setTimeout(function() {
self.initDOM();
@@ -222,7 +221,6 @@ return view.extend({
executeStatus: document.querySelector('#execute_status')
};
// 初始化状态变量
this.logPosition = '0';
this.logPolling = null;
this.isRunning = false;
@@ -244,7 +242,6 @@ return view.extend({
});
}
// 表单变化事件 - 自动保存
[this.dom.targetFunction, this.dom.targetDisk, this.dom.formatType].forEach(function(element) {
if (element) {
element.addEventListener('change', function() {
@@ -254,14 +251,12 @@ return view.extend({
}
});
// 复选框特殊处理
if (this.dom.keepConfig) {
this.dom.keepConfig.addEventListener('click', function() {
self.autoSaveConfig();
});
}
// 初始化表单可见性
if (this.dom.targetFunction) {
this.updateFormVisibility();
}
@@ -335,26 +330,21 @@ loadDevices: function() {
},
// 加载现有的日志文件内容
loadExistingLog: function() {
var self = this;
// 初始化时获取现有日志内容
callPartExpGetLog('0').then(function(response) {
if (response && response.log) {
var logContent = response.log.toString().trim();
if (logContent && self.dom.logView) {
// 显示现有日志内容
self.dom.logView.value = logContent;
// 自动滚动到底部
setTimeout(function() {
if (self.dom.logView && self.dom.logView.value) {
self.dom.logView.scrollTop = self.dom.logView.scrollHeight;
}
}, 100);
// 更新日志位置
if (response.position) {
self.logPosition = response.position;
}
@@ -379,7 +369,6 @@ loadDevices: function() {
return;
}
// 解析配置文件
var lines = content.split('\n');
var config = {};
@@ -395,12 +384,10 @@ loadDevices: function() {
}
});
// 设置表单值
if (self.dom.targetFunction) {
self.dom.targetFunction.value = config.target_function || '/opt';
}
if (self.dom.targetDisk && config.target_disk) {
// 等待设备加载完成后设置
setTimeout(function() {
if (self.dom.targetDisk) {
self.dom.targetDisk.value = config.target_disk;
@@ -414,10 +401,8 @@ loadDevices: function() {
self.dom.formatType.value = config.format_type || '0';
}
// 更新配置缓存
self.configCache = config;
// 更新表单可见性
self.updateFormVisibility();
}).catch(function(error) {
@@ -426,7 +411,6 @@ loadDevices: function() {
});
},
// 设置默认配置
setDefaultConfig: function() {
if (this.dom.targetFunction) {
this.dom.targetFunction.value = '/opt';
@@ -447,26 +431,20 @@ loadDevices: function() {
};
},
// 自动保存配置(防抖处理)
autoSaveConfig: function() {
var self = this;
// 清除之前的定时器
if (this.autoSaveTimer) {
clearTimeout(this.autoSaveTimer);
}
// 设置新的定时器,1.5秒后保存
this.autoSaveTimer = setTimeout(function() {
self.saveCurrentConfig();
}, 1500);
},
// 保存当前配置
saveCurrentConfig: function() {
var self = this;
// 获取当前表单值
var targetFunction = this.dom.targetFunction ? this.dom.targetFunction.value : '/opt';
var targetDisk = this.dom.targetDisk ? this.dom.targetDisk.value : '';
var keepConfig = this.dom.keepConfig ? this.dom.keepConfig.checked : false;
@@ -497,12 +475,10 @@ loadDevices: function() {
return self.saveConfigToFile(targetFunction, targetDisk, keepConfig, formatType);
});
} else {
// 如果 RPC 不可用,直接使用文件写入
return self.saveConfigToFile(targetFunction, targetDisk, keepConfig, formatType);
}
},
// 备选方案:直接写入配置文件
saveConfigToFile: function(targetFunction, targetDisk, keepConfig, formatType) {
var configContent = [
'# Auto-generated by partexp',
@@ -524,11 +500,9 @@ loadDevices: function() {
});
},
// 执行操作
executeOperation: function() {
var self = this;
// 先保存配置
this.saveCurrentConfig();
var target_function = this.dom.targetFunction.value;
var target_disk = this.dom.targetDisk.value;
@@ -538,7 +512,6 @@ loadDevices: function() {
return;
}
// 确认操作
var confirmMessage = _('Are you sure you want to execute partition expansion?') + '\n\n' +
_('Function:') + ' ' + this.getFunctionDescription(target_function) + '\n' +
(target_function !== '/' ? _('Disk:') + ' ' + target_disk + '\n' : '') +
@@ -552,33 +525,26 @@ loadDevices: function() {
return;
}
// 重置操作状态
this.resetOperationState();
// 标记为新操作开始
this.isNewOperation = true;
if (this.dom.logView) {
this.dom.logView.value = _('正在启动操作...');
}
// 更新按钮状态
if (this.dom.executeBtn) {
this.dom.executeBtn.disabled = true;
this.dom.executeBtn.textContent = _('Executing...');
}
// 切换到执行状态
this.switchState('executing');
// 开始进度显示
this.updateProgress(5, _('Starting operation...'));
// 调用分区操作
callPartExpAutopart()
.then(function(response) {
if (response && response.success) {
// 操作开始成功
self.isRunning = true;
self.operationComplete = false;
self.startLogPolling();
@@ -587,7 +553,6 @@ loadDevices: function() {
self.dom.executeStatus.textContent = _('Operation started successfully');
}
} else {
// 操作启动失败
var errorMsg = response && response.message ? response.message : _('Operation failed');
self.handleOperationError(errorMsg);
}
@@ -598,7 +563,6 @@ loadDevices: function() {
});
},
// 重置操作状态
resetOperationState: function() {
this.logPosition = '0';
this.isRunning = true;
@@ -608,11 +572,9 @@ loadDevices: function() {
this.lastPollTime = 0;
this.currentProgress = 0;
// 重置进度条
this.updateProgress(0, _('Starting operation...'));
},
// 处理操作错误
handleOperationError: function(errorMsg) {
alert(errorMsg);
if (this.dom.executeBtn) {
@@ -623,7 +585,6 @@ loadDevices: function() {
this.switchState('ready');
this.stopLogPolling();
// 在日志中显示错误信息
if (this.dom.logView) {
var currentLog = this.dom.logView.value || '';
this.dom.logView.value = currentLog + '\n\n' + _('操作失败:') + ' ' + errorMsg;
@@ -635,7 +596,6 @@ loadDevices: function() {
}
},
// 更新表单可见性
updateFormVisibility: function() {
if (!this.dom.targetFunction || !this.dom.targetDisk ||
!this.dom.keepConfig || !this.dom.formatType) return;
@@ -662,24 +622,20 @@ loadDevices: function() {
}
},
// 检查操作状态
checkOperationStatus: function() {
var self = this;
callPartExpGetStatus().then(function(response) {
if (response && response.running) {
// 有操作在进行中
self.isRunning = true;
self.switchState('executing');
self.startLogPolling();
// 禁用执行按钮
if (self.dom.executeBtn) {
self.dom.executeBtn.disabled = true;
self.dom.executeBtn.textContent = _('Operation in progress...');
}
// 更新状态
if (self.dom.executeStatus) {
self.dom.executeStatus.textContent = _('Operation in progress...');
}
@@ -689,30 +645,23 @@ loadDevices: function() {
});
},
// 开始轮询日志
startLogPolling: function() {
var self = this;
// 停止现有的轮询
this.stopLogPolling();
// 重置状态
this.pollErrorCount = 0;
this.pollingStartTime = Date.now();
this.lastPollTime = 0;
// 更新进度显示
this.updateProgress(10, _('Operation in progress...'));
// 开始轮询
this.logPolling = setInterval(function() {
// 检查是否超时(20分钟超时)
if (Date.now() - self.pollingStartTime > 20 * 60 * 1000) {
console.error('Operation timeout');
self.stopLogPolling();
self.isRunning = false;
// 显示超时信息
if (self.dom.logView) {
var currentLog = self.dom.logView.value || '';
self.dom.logView.value = currentLog + '\n\n[超时] 操作超过20分钟未完成,请检查系统';
@@ -746,7 +695,6 @@ loadDevices: function() {
var pollStartTime = Date.now();
// 总是从位置0开始获取完整日志内容
callPartExpGetLog('0').then(function(response) {
if (!response) {
console.error('No response from log polling');
@@ -759,7 +707,6 @@ loadDevices: function() {
self.lastPollTime = pollStartTime;
// 处理日志内容
if (response.log !== undefined) {
var logContent = response.log.toString().trim();
@@ -771,7 +718,6 @@ loadDevices: function() {
if (logContent !== '') {
self.dom.logView.value = logContent;
// 自动滚动到底部
setTimeout(function() {
if (self.dom.logView && self.dom.logView.value) {
self.dom.logView.scrollTop = self.dom.logView.scrollHeight;
@@ -780,27 +726,22 @@ loadDevices: function() {
}
}
// 更新进度
self.parseAndUpdateProgress(logContent);
// 检查操作是否完成
if (self.checkOperationComplete(logContent)) {
self.handleOperationComplete();
}
}
// 检查RPC返回的完成状态
if (response.complete) {
self.handleOperationComplete();
}
// 重置错误计数
self.pollErrorCount = 0;
}).catch(function(error) {
console.error('Log polling error:', error);
// 如果多次失败,停止轮询
self.pollErrorCount = (self.pollErrorCount || 0) + 1;
if (self.pollErrorCount > 5) {
console.error('Too many polling errors, stopping');
@@ -812,7 +753,6 @@ loadDevices: function() {
self.dom.executeBtn.disabled = false;
self.dom.executeBtn.textContent = _('Click to execute');
}
// 显示错误信息
if (self.dom.logView) {
var currentLog = self.dom.logView.value || '';
self.dom.logView.value = currentLog + '\n\n[错误] 日志轮询失败,请刷新页面查看最新状态';
@@ -826,11 +766,9 @@ loadDevices: function() {
});
},
// 检查操作是否完成
checkOperationComplete: function(logText) {
if (!logText) return false;
// 检查日志中是否包含操作完成标记
var completeMarkers = [
'重启设备',
'操作完成'
@@ -845,7 +783,6 @@ loadDevices: function() {
return false;
},
// 处理操作完成
handleOperationComplete: function() {
if (this.operationComplete) {
return;
@@ -855,7 +792,6 @@ loadDevices: function() {
this.isRunning = false;
this.isNewOperation = false;
// 立即停止轮询
this.stopLogPolling();
if (this.dom.logView) {
var currentLog = this.dom.logView.value || '';
@@ -869,28 +805,23 @@ loadDevices: function() {
}
}
// 进度条显示100%
this.updateProgress(100, _('Operation completed'));
// 启用执行按钮
setTimeout(() => {
if (this.dom.executeBtn) {
this.dom.executeBtn.disabled = false;
this.dom.executeBtn.textContent = _('Click to execute');
}
// 切换回就绪状态
setTimeout(() => {
this.switchState('ready');
}, 3000);
}, 2000);
},
// 解析并更新进度
parseAndUpdateProgress: function(logText) {
if (!logText || !this.dom.executeStatus) return;
// 尝试从日志中提取进度信息
var percent = 0;
var statusMessage = _('Operation in progress...');
@@ -898,7 +829,6 @@ loadDevices: function() {
percent = 100;
statusMessage = _('Operation completed');
} else if ( logText.includes('错误') || logText.includes('error')) {
// 错误情况,不更新进度
return;
} else if (logText.includes('分区扩容和挂载到') || logText.includes('正在挂载')) {
percent = 90;
@@ -923,38 +853,29 @@ loadDevices: function() {
statusMessage = _('Initializing...');
}
// 确保进度不会倒退
if (percent > 0) {
this.currentProgress = Math.max(this.currentProgress || 0, percent);
} else {
// 如果没有明确的进度标记,逐渐增加进度
this.currentProgress = Math.min(90, (this.currentProgress || 0) + 1);
}
// 更新进度显示
this.updateProgress(this.currentProgress, statusMessage);
},
// 更新进度显示
updateProgress: function(percent, message) {
if (!this.dom.progressBar || !this.dom.progressText || !this.dom.executeStatus) {
return;
}
// 确保百分比在有效范围内
percent = Math.max(0, Math.min(100, percent));
// 更新进度条
this.dom.progressBar.style.width = percent + '%';
// 更新进度文本
this.dom.progressText.textContent = percent + '%';
// 更新状态消息
this.dom.executeStatus.textContent = message;
},
// 停止轮询日志
stopLogPolling: function() {
if (this.logPolling) {
clearInterval(this.logPolling);
@@ -966,17 +887,14 @@ loadDevices: function() {
switchState: function(to) {
if (!this.dom.stateContainer) return;
// 移除所有状态类
this.dom.stateContainer.classList.remove(
'state-ctl-ready',
'state-ctl-executing'
);
// 添加新状态类
this.dom.stateContainer.classList.add('state-ctl-' + to);
},
// 获取功能描述
getFunctionDescription: function(func) {
switch(func) {
case '/': return _('Extend to root directory');
@@ -987,7 +905,6 @@ loadDevices: function() {
}
},
// 获取格式化类型描述
getFormatTypeDescription: function(type) {
switch(type) {
case '0': return _('No formatting');
@@ -998,7 +915,6 @@ loadDevices: function() {
}
},
// 页面生命周期方法
handleSaveApply: null,
handleSave: null,
handleReset: null
+2 -2
View File
@@ -1,6 +1,6 @@
#
# provides Web UI to shut down (power off) your device.
# Copyright (C) 2022-2025 sirpdboy <herboy2008@gmail.com>
# Copyright (C) 2022-2026 sirpdboy <herboy2008@gmail.com>
# This is free software, licensed under the GNU General Public License v3.
include $(TOPDIR)/rules.mk
@@ -12,7 +12,7 @@ LUCI_DESCRIPTION:=provides Web UI to shut down (power off) your device.
LUCI_PKGARCH:=all
PKG_VERSION:=2
PKG_RELEASE:=1
PKG_RELEASE:=2
include $(TOPDIR)/feeds/luci/luci.mk
@@ -1,4 +1,3 @@
'use strict';
'require view';
'require ui';
@@ -7,56 +6,81 @@
return view.extend({
render: function() {
return E([
E('h2', _('PowerOff')),
E('p', _('Turn off the power to the device you are using')),
E('hr'),
E('button', {
class: 'btn cbi-button cbi-button-negative',
E('div', { class: 'cbi-section' }, [
E('h2', { class: 'cbi-section-title' }, _('PowerOff')),
E('div', { class: 'cbi-section-descr' }, _('Turn off the power to the device you are using')),
E('hr', { style: 'margin: 15px 0' }),
E('div', { style: ' padding: 20px 0' }, [
E('button', {
class: 'btn cbi-button cbi-button-negative important',
style: 'padding: 0.5rem 1rem;font-size: 1.2em;font-weight: bold;border-radius: 4px;box-shadow: 0 2px 5px rgba(0,0,0,0.2);',
click: ui.createHandlerFn(this, 'handlePowerOff')
}, _('Perform Power Off')),
E('div', { 'style': 'text-align: center; padding: 10px; font-style: italic;' }, [
E('span', {}, [
_('© github '),
E('a', {
'href': 'https://github.com/sirpdboy/luci-app-poweroffdevice',
'target': '_blank',
'style': 'text-decoration: none;'
}, 'by sirpdboy')
}, _('⚠️ Perform Power Off'))
])
])
]);
},
handlePowerOff: function() {
return ui.showModal(_('PowerOff Device'), [
E('h4', { }, _('Turn off the power to the device you are using')),
return ui.showModal(_('⚠️ PowerOff Device'),
E('div', { style: 'min-width: 350px' }, [
E('div', { class: 'alert-message warning', style: 'margin: 0 0 15px 0; padding: 10px; background: #f0ad4e' }, [
E('h4', { style: 'margin: 0 0 5px 0; ' }, _('Warning!')),
E('p', { style: 'margin: 0; ' }, _('This action will immediately turn off the power to your device. Make sure to save all your work before proceeding.'))
]),
E('div', { class: 'right' }, [
E('div', { style: ' border-radius: 4px; padding: 15px; margin-bottom: 15px' }, [
E('p', { style: 'margin: 0 0 10px 0; font-weight: bold' }, _('Before you continue:')),
E('ul', { style: 'margin: 0; padding-left: 20px' }, [
E('li', { style: 'margin-bottom: 5px' }, _('Save all unsaved settings')),
E('li', { style: 'margin-bottom: 5px' }, _('Check if other users are active')),
E('li', _('The device needs to be manually turned on'))
])
]),
E('button', {
'class': 'btn btn-danger ',
'style': 'background: red!important; border-color: red!important',
'click': ui.createHandlerFn(this, function() {
ui.hideModal();
ui.showModal(_('PowerOffing...'), [
E('p', {'class': 'spinning' }, _('The device may have powered off. If not, check manually.'))
]);
return fs.exec('/sbin/poweroff').catch(function(e) {
ui.addNotification(null, E('p', e.message));
});
})
}, _('OK')),
' ',
E('button', {
'class': 'btn cbi-button cbi-button-apply',
'click': ui.hideModal
}, _('Cancel'))
E('div', { class: 'right', style: 'margin-top: 20px; padding-top: 15px; border-top: 1px solid #ddd' }, [
E('button', {
'class': 'btn cbi-button cbi-button-apply',
'style': 'margin-right: 10px; ',
'click': ui.hideModal
}, _('Cancel')),
E('button', {
'class': 'btn cbi-button cbi-button-negative',
'style': ' font-weight: bold;',
'click': ui.createHandlerFn(this, function() {
ui.hideModal();
// Show powering off modal
ui.showModal(_('Powering Off'),
E('div', { style: 'text-align: center; padding: 30px; min-width: 300px' }, [
E('div', {
class: 'spinning',
style: 'font-size: 48px; margin-bottom: 20px; color: #f0ad4e;'
}, '⚡'),
E('h3', { style: 'margin: 0 0 15px 0' }, _('Powering off device...')),
E('p', { style: 'color: #666; margin: 0' },
_('The device should power off within a few seconds. If the device remains on, you may need to perform a manual shutdown.'))
])
);
// Execute poweroff command
return fs.exec('/sbin/poweroff').catch(function(e) {
ui.hideModal();
ui.addNotification(null,
E('div', { style: 'padding: 10px' }, [
E('h4', { style: 'color: #d9534f; margin: 0 0 5px 0' }, _('Error!')),
E('p', { style: 'margin: 0' }, e.message)
])
);
});
})
}, _('Confirm Power Off'))
])
])
]);
);
},
handleSaveApply: null,
handleSave: null,
handleReset: null
});
});
@@ -6,33 +6,44 @@
msgid "PowerOff"
msgstr "关机"
msgid "PowerOff Device"
msgstr "设备关机"
msgid "⚠️ PowerOff Device"
msgstr "⚠️ 设备关机"
msgid "Perform Power Off"
msgstr "执行关机"
msgid "⚠️ Perform Power Off"
msgstr "⚠️ 执行关机"
msgid "Turn off the power to the device you are using"
msgstr "关闭您正在使用的设备的电源"
msgid "WARNING: Power off might result in a reboot on a device which not support power off."
msgstr "警告:对于不支持关机的设备,关机可能会导致重新启动."
msgid "This action will immediately turn off the power to your device. Make sure to save all your work before proceeding."
msgstr "此操作将立即关闭设备的电源。在继续之前,请确保保存所有工作"
msgid "PowerOffing..."
msgid "Powering off device..."
msgstr "正在关机..."
msgid "Device shutdown complete!"
msgstr "设备关机完毕!"
msgid "Confirm Power Off"
msgstr "确认关机"
msgid "PowerOff failed"
msgstr "关机失败"
msgid "Warning!"
msgstr "警告"
msgid "The device is shutting down..."
msgstr "设备正在关闭..."
msgid "Before you continue:"
msgstr "继续关机之前:"
msgid "Save all unsaved settings"
msgstr "保存所有未保存的设置"
msgid "Check if other users are active"
msgstr "检查其他用户是否处于活动状态"
msgid "The device needs to be manually turned on"
msgstr "设备需要手动开机"
msgid "Powering Off"
msgstr "关机中"
msgid "The device should power off within a few seconds. If the device remains on, you may need to perform a manual shutdown."
msgstr "设备应在几秒钟内关闭。如果设备保持开启状态,您可能需要执行手动关机"
msgid "The device may have powered off. If not, check manually."
msgstr "设备已断电。如果没有,请手动操作。"
msgid "Confirm"
msgstr "确认"
+2 -2
View File
@@ -6,8 +6,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-watchdog
PKG_VERSION:=1.0.7
PKG_RELEASE:=1
PKG_VERSION:=1.0.8
PKG_RELEASE:=2
PKG_MAINTAINER:=sirpdboy <herboy2008@gmail.com>
PKG_CONFIG_DEPENDS:=
@@ -26,7 +26,7 @@ function renderStatus(isRunning) {
return String.format(
'<em><span style="color:%s">%s <strong>%s %s</strong></span></em>',
color, icon, _('watchdog'), statusText
color, icon, _('Watch Dog'), statusText
);
}
@@ -68,7 +68,7 @@ return view.extend({
render: function() {
var m, s, o;
m = new form.Map('watchdog', _('watchdog'), _('This is the security watchdog plugin for OpenWRT, which monitors and guards web login, SSH connections, and other situations.<br /><br />If you encounter any issues while using it, please submit them here:') + '<a href="https://github.com/sirpdboy/luci-app-watchdog" target="_blank">' + _('GitHub Project Address') + '</a>');
m = new form.Map('watchdog', _('Watch Dog'), _('This is the security watchdog plugin for OpenWRT, which monitors and guards web login, SSH connections, and other situations.<br /><br />If you encounter any issues while using it, please submit them here:') + '<a href="https://github.com/sirpdboy/luci-app-watchdog" target="_blank">' + _('GitHub Project Address') + '</a>');
s = m.section(form.TypedSection);
s.anonymous = true;
@@ -93,18 +93,7 @@ return view.extend({
});
poll.start();
return E('div', { class: 'cbi-section', id: 'status_bar' }, [ statusView ,
E('div', { 'style': 'text-align: right; font-style: italic;' }, [
E('span', {}, [
_('© github '),
E('a', {
'href': 'https://github.com/sirpdboy',
'target': '_blank',
'style': 'text-decoration: none;'
}, 'by sirpdboy')
])
])
]);
return E('div', { class: 'cbi-section', id: 'status_bar' }, statusView );
}
s = m.section(form.NamedSection, 'config', 'watchdog', _(''));
@@ -152,11 +141,9 @@ return view.extend({
o.rows = 8;
o.wrap = 'soft';
// 修复:正确处理空文件的情况
o.cfgvalue = function(section_id) {
return fs.read('/usr/share/watchdog/api/ip_blacklist')
.then(function(content) {
// 如果文件不存在或为空,返回空字符串
return content || '';
})
.catch(function(err) {
@@ -165,59 +152,45 @@ return view.extend({
});
};
// 修复:确保空值能被正确保存,并触发日志
o.write = function(section_id, formvalue) {
var self = this;
return self.cfgvalue(section_id).then(function(oldValue) {
// 处理空值 - 如果表单值为空或只包含空白字符,清空文件
var newValue = (formvalue || '').trim();
// 如果值没有变化,不执行写入
if (oldValue === newValue) {
return;
}
// 处理空值情况 - 清空文件
if (newValue === '') {
return fs.write('/usr/share/watchdog/api/ip_blacklist', '')
.then(function() {
// 添加成功通知
ui.addNotification(null, E('p', {}, _('Blacklist cleared successfully')));
// 触发 watchdog 重新加载配置,这会记录日志
return fs.exec('/etc/init.d/watchdog', ['restart'])
.then(function() {
console.log('Watchdog restarted successfully');
})
.catch(function(err) {
console.error('Failed to restart watchdog:', err);
// 即使重启失败,也尝试手动触发清理
return fs.exec('/usr/bin/logger', ['-t', 'watchdog', 'Blacklist cleared via web interface']);
});
});
}
// 格式化内容:每行一个IP,去除空行
var lines = newValue.split('\n');
var validLines = [];
for (var i = 0; i < lines.length; i++) {
var line = lines[i].trim();
// 跳过空行
if (line === '') {
continue;
}
validLines.push(line);
}
// 如果没有有效IP,清空文件
if (validLines.length === 0) {
return fs.write('/usr/share/watchdog/api/ip_blacklist', '')
.then(function() {
ui.addNotification(null, E('p', {}, _('Blacklist cleared successfully')));
// 触发 watchdog 重新加载配置
return fs.exec('/etc/init.d/watchdog', ['restart'])
.then(function() {
console.log('Watchdog restarted successfully');
@@ -229,38 +202,29 @@ return view.extend({
});
}
// 找出删除的IP(对比新旧内容)
var oldLines = oldValue ? oldValue.split('\n').map(function(line) { return line.trim(); }).filter(function(line) { return line !== ''; }) : [];
var removedIPs = oldLines.filter(function(ip) {
return validLines.indexOf(ip) === -1;
});
// 写入格式化的内容,每个IP一行
var content = validLines.join('\n') + '\n';
return fs.write('/usr/share/watchdog/api/ip_blacklist', content)
.then(function() {
var message = _('Blacklist updated successfully');
if (removedIPs.length > 0) {
message += ' ' + _('Removed %s IP(s)').replace('%s', removedIPs.length);
// 记录到系统日志
return fs.exec('/usr/bin/logger', ['-t', 'watchdog', 'Removed IPs from blacklist: ' + removedIPs.join(', ')])
.then(function() {
ui.addNotification(null, E('p', {}, message));
return fs.exec('/etc/init.d/watchdog', ['restart']);
});
} else {
ui.addNotification(null, E('p', {}, message));
return fs.exec('/etc/init.d/watchdog', ['restart']);
}
})
.catch(function(err) {
ui.addNotification(null, E('p', { style: 'color:red' },
_('Failed to update blacklist: ') + err.message));
return Promise.reject(err);
});
}).catch(function(err) {
ui.addNotification(null, E('p', { style: 'color:red' },
_('Failed to read current blacklist: ') + err.message));
return Promise.reject(err);
});
};
@@ -93,17 +93,7 @@ return view.extend({
log_textarea,
E('small', {}, _('Refresh every 5 seconds.').format(L.env.pollinterval)),
E('div', { 'class': 'cbi-section-actions cbi-section-actions-right' })
]),
E('div', { 'style': 'text-align: right; font-style: italic;' }, [
E('span', {}, [
_('© github '),
E('a', {
'href': 'https://github.com/sirpdboy/luci-app-watchdog',
'target': '_blank',
'style': 'text-decoration: none;'
}, 'by sirpdboy')
])
])
])
]);
+4 -1
View File
@@ -8,7 +8,10 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Weblate 4.18-dev\n"
msgid "watchdog"
msgid "Control"
msgstr "管控"
msgid "Watch Dog"
msgstr "看门狗"
msgid "Watch Dog"
@@ -1,7 +1,7 @@
{
"admin/control": {
"title": "Control",
"order": 1,
"order": 44,
"action": {
"type": "firstchild",
"recurse": true
+3 -3
View File
@@ -9,8 +9,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=lucky
PKG_VERSION:=2.26.2
PKG_RELEASE:=1
PKG_VERSION:=2.27.2
PKG_RELEASE:=2
PKGARCH:=all
ifeq ($(ARCH),mipsel)
@@ -68,7 +68,7 @@ endef
define Build/Prepare
[ ! -f $(PKG_BUILD_DIR)/$(PKG_NAME)_$(PKG_VERSION)_Linux_$(LUCKY_ARCH).tar.gz ] && wget https://github.com/gdy666/lucky/releases/download/v$(PKG_VERSION)/$(PKG_NAME)_$(PKG_VERSION)_Linux_$(LUCKY_ARCH).tar.gz -O $(PKG_BUILD_DIR)/$(PKG_NAME)_$(PKG_VERSION)_Linux_$(LUCKY_ARCH).tar.gz
tar -xzvf $(PKG_BUILD_DIR)/$(PKG_NAME)_$(PKG_VERSION)_Linux_$(LUCKY_ARCH).tar.gz -C $(PKG_BUILD_DIR)
tar -xzvf $(PKG_BUILD_DIR)/$(PKG_NAME)_$(PKG_VERSION)_Linux_$(LUCKY_ARCH).tar.gz -C $(PKG_BUILD_DIR) || exit 1
endef
define Package/$(PKG_NAME)/conffiles
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 492 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 629 KiB

+1 -1
View File
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=watchdog
PKG_VERSION:=1
PKG_RELEASE:=1
PKG_RELEASE:=2
include $(INCLUDE_DIR)/package.mk
-1
View File
@@ -23,7 +23,6 @@ reload_service() {
start
}
# 检测防火墙类型
detect_firewall_type() {
if command -v nft >/dev/null && [ -x /sbin/fw4 ]; then
echo "nft"