update 2025-11-08 04:22:25

This commit is contained in:
kenzok8
2025-11-08 04:22:25 +08:00
parent 4575694384
commit 99f8641a42
6 changed files with 87 additions and 56 deletions

View File

@@ -9,8 +9,8 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-netspeedtest PKG_NAME:=luci-app-netspeedtest
PKG_VERSION:=5.0.6 PKG_VERSION:=5.1.0
PKG_RELEASE:=20250711 PKG_RELEASE:=20251108
LUCI_TITLE:=LuCI Support for netspeedtest LUCI_TITLE:=LuCI Support for netspeedtest
LUCI_DEPENDS:=+speedtest-cli +homebox +netspeedtest $(if $(find_package iperf3-ssl),+iperf3-ssl,+iperf3) LUCI_DEPENDS:=+speedtest-cli +homebox +netspeedtest $(if $(find_package iperf3-ssl),+iperf3-ssl,+iperf3)

View File

@@ -27,33 +27,54 @@ return view.extend({
E('p', {}, _('Please enable the Homebox service')) E('p', {}, _('Please enable the Homebox service'))
]); ]);
var iframe = E('iframe', { var isHttps = window.location.protocol === 'https:';
src: window.location.origin + ':' + state.port, var iframe;
style: 'border:none;width: 100%; min-height: 80vh; border: none; border-radius: 3px;overflow:hidden !important;'
}); if (!isHttps) {
iframe = E('iframe', {
async function checkProcess() { src: window.location.origin + ':' + state.port,
try { style: 'border:none;width: 100%; min-height: 80vh; border: none; border-radius: 3px;overflow:hidden !important;'
// 尝试使用pgrep });
const res = await fs.exec('/usr/bin/pgrep', ['homebox']); }
return {
running: res.code === 0, function createHttpsButton() {
pid: res.stdout.trim() || null return E('div', {
}; style: 'text-align: center; padding: 2em;'
} catch (err) { }, [
// 回退到ps方法 E('h2', {}, _('Homebox Control panel')),
try { E('p', {}, _('Due to browser security policies, the Homebox interface https cannot be embedded directly.')),
const psRes = await fs.exec('/bin/ps', ['-w', '-C', 'homebox', '-o', 'pid=']); E('a', {
const pid = psRes.stdout.trim(); href: 'http://' + window.location.hostname + ':' + state.port,
return { target: '_blank',
running: pid !== '', class: 'cbi-button cbi-button-apply',
pid: pid || null style: 'display: inline-block; margin-top: 1em; padding: 10px 20px; font-size: 16px; text-decoration: none; color: white;'
}; }, _('Open Web Interface'))
} catch (err) {
return { running: false, pid: null }; ]);
}
async function checkProcess() {
try {
// 尝试使用pgrep
const res = await fs.exec('/usr/bin/pgrep', ['homebox']);
return {
running: res.code === 0,
pid: res.stdout.trim() || null
};
} catch (err) {
// 回退到ps方法
try {
const psRes = await fs.exec('/bin/ps', ['-w', '-C', 'homebox', '-o', 'pid=']);
const pid = psRes.stdout.trim();
return {
running: pid !== '',
pid: pid || null
};
} catch (err) {
return { running: false, pid: null };
}
}
} }
}
}
function controlService(action) { function controlService(action) {
var command = action === 'start' var command = action === 'start'
@@ -70,14 +91,17 @@ async function checkProcess() {
statusText.style.fontWeight = 'bold'; statusText.style.fontWeight = 'bold';
statusText.style.fontSize = '0.92rem'; statusText.style.fontSize = '0.92rem';
// 更新按钮状态
toggleBtn.textContent = state.running ? _('Stop Server') : _('Start Server'); toggleBtn.textContent = state.running ? _('Stop Server') : _('Start Server');
toggleBtn.className = `btn cbi-button cbi-button-${state.running ? 'reset' : 'apply'}`; toggleBtn.className = `btn cbi-button cbi-button-${state.running ? 'reset' : 'apply'}`;
// Update container content based on state // Update container content based on state and protocol
container.textContent = ''; container.textContent = '';
if (state.running) { if (state.running) {
container.appendChild(iframe); if (isHttps) {
container.appendChild(createHttpsButton());
} else {
container.appendChild(iframe);
}
} else { } else {
container.appendChild(statusMessage); container.appendChild(statusMessage);
} }
@@ -93,21 +117,20 @@ async function checkProcess() {
}); });
})); }));
// 开始
statusSection.appendChild(E('div', { 'style': 'margin: 15px' }, [ statusSection.appendChild(E('div', { 'style': 'margin: 15px' }, [
E('h3', {}, _('Lan Speedtest Homebox')), E('h3', {}, _('Lan Speedtest Homebox')),
E('div', { 'class': 'cbi-map-descr' }, [statusIcon, statusText]), E('div', { 'class': 'cbi-map-descr' }, [statusIcon, statusText]),
E('div', {'class': 'cbi-value', 'style': 'margin-top: 20px'}, [ E('div', {'class': 'cbi-value', 'style': 'margin-top: 20px'}, [
E('div', {'class': 'cbi-value-title'}, _('Homebox service control')), E('div', {'class': 'cbi-value-title'}, _('Homebox service control')),
E('div', {'class': 'cbi-value-field'}, toggleBtn), E('div', {'class': 'cbi-value-field'}, toggleBtn),
E('div', { 'style': 'text-align: right; font-style: italic; margin-top: 20px;' }, [ E('div', { 'style': 'text-align: right; font-style: italic; margin-top: 20px;' }, [
_('© github '), _('© github '),
E('a', { E('a', {
'href': 'https://github.com/sirpdboy/luci-app-netspeedtest', 'href': 'https://github.com/sirpdboy',
'target': '_blank', 'target': '_blank',
'style': 'text-decoration: none;' 'style': 'text-decoration: none;'
}, 'by sirpdboy') }, 'by sirpdboy')
]) ])
]) ])
])); ]));
@@ -134,9 +157,9 @@ async function checkProcess() {
statusSection, statusSection,
container container
]); ]);
} },
// handleSaveApply: null, handleSaveApply: null,
// handleSave: null, handleSave: null,
// handleReset: null handleReset: null
}); });

View File

@@ -53,9 +53,9 @@ function controlService(action) {
return view.extend({ return view.extend({
// handleSaveApply: null, handleSaveApply: null,
// handleSave: null, handleSave: null,
// handleReset: null, handleReset: null,
load: function() { load: function() {
return Promise.all([ return Promise.all([
uci.load('netspeedtest') uci.load('netspeedtest')

View File

@@ -28,11 +28,10 @@ return view.extend({
}; };
return m.render(); return m.render();
} },
handleSaveApply: null,
// handleSaveApply: null, handleSave: null,
// handleSave: null, handleReset: null
// handleReset: null
}); });

View File

@@ -168,5 +168,8 @@ return view.extend({
}, this), 5); }, this), 5);
return nodes; return nodes;
}, this, m)); }, this, m));
} },
handleSaveApply: null,
handleSave: null,
handleReset: null
}); });

View File

@@ -100,8 +100,8 @@ msgstr "Homebox服务端"
msgid "Homebox Service Not Running" msgid "Homebox Service Not Running"
msgstr "Homebox服务端未运行" msgstr "Homebox服务端未运行"
msgid "Ookla® SpeedTest-CLI" msgid "Open Web Interface"
msgstr "" msgstr "打开WEB页面"
msgid "Start Ookla SpeedTest" msgid "Start Ookla SpeedTest"
msgstr "开始宽带测速" msgstr "开始宽带测速"
@@ -119,4 +119,10 @@ msgid "No test results yet."
msgstr "还没有测试结果" msgstr "还没有测试结果"
msgid "Test Script" msgid "Test Script"
msgstr "测速脚本" msgstr "测速脚本"
msgid "Homebox Control panel"
msgstr "Homebox控制台"
msgid "Due to browser security policies, the Homebox interface https cannot be embedded directly."
msgstr "由于浏览器安全策略Homebox接口https不能直接嵌入。"