diff --git a/luci-app-netspeedtest/Makefile b/luci-app-netspeedtest/Makefile index e7db83be8..be91f35ab 100644 --- a/luci-app-netspeedtest/Makefile +++ b/luci-app-netspeedtest/Makefile @@ -9,8 +9,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-netspeedtest -PKG_VERSION:=5.0.6 -PKG_RELEASE:=20250711 +PKG_VERSION:=5.1.0 +PKG_RELEASE:=20251108 LUCI_TITLE:=LuCI Support for netspeedtest LUCI_DEPENDS:=+speedtest-cli +homebox +netspeedtest $(if $(find_package iperf3-ssl),+iperf3-ssl,+iperf3) diff --git a/luci-app-netspeedtest/htdocs/luci-static/resources/view/netspeedtest/homebox.js b/luci-app-netspeedtest/htdocs/luci-static/resources/view/netspeedtest/homebox.js index 4b6b0cb7b..a368bc8a7 100644 --- a/luci-app-netspeedtest/htdocs/luci-static/resources/view/netspeedtest/homebox.js +++ b/luci-app-netspeedtest/htdocs/luci-static/resources/view/netspeedtest/homebox.js @@ -27,33 +27,54 @@ return view.extend({ E('p', {}, _('Please enable the Homebox service')) ]); - var iframe = E('iframe', { - src: window.location.origin + ':' + state.port, - style: 'border:none;width: 100%; min-height: 80vh; border: none; border-radius: 3px;overflow:hidden !important;' - }); - -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 }; + var isHttps = window.location.protocol === 'https:'; + var iframe; + + if (!isHttps) { + iframe = E('iframe', { + src: window.location.origin + ':' + state.port, + style: 'border:none;width: 100%; min-height: 80vh; border: none; border-radius: 3px;overflow:hidden !important;' + }); + } + + function createHttpsButton() { + return E('div', { + style: 'text-align: center; padding: 2em;' + }, [ + E('h2', {}, _('Homebox Control panel')), + E('p', {}, _('Due to browser security policies, the Homebox interface https cannot be embedded directly.')), + E('a', { + href: 'http://' + window.location.hostname + ':' + state.port, + target: '_blank', + class: 'cbi-button cbi-button-apply', + style: 'display: inline-block; margin-top: 1em; padding: 10px 20px; font-size: 16px; text-decoration: none; color: white;' + }, _('Open Web Interface')) + + ]); + } + + 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) { var command = action === 'start' @@ -70,14 +91,17 @@ async function checkProcess() { statusText.style.fontWeight = 'bold'; statusText.style.fontSize = '0.92rem'; - // 更新按钮状态 toggleBtn.textContent = state.running ? _('Stop Server') : _('Start Server'); 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 = ''; if (state.running) { - container.appendChild(iframe); + if (isHttps) { + container.appendChild(createHttpsButton()); + } else { + container.appendChild(iframe); + } } else { container.appendChild(statusMessage); } @@ -93,21 +117,20 @@ async function checkProcess() { }); })); - // 开始 statusSection.appendChild(E('div', { 'style': 'margin: 15px' }, [ E('h3', {}, _('Lan Speedtest Homebox')), E('div', { 'class': 'cbi-map-descr' }, [statusIcon, statusText]), E('div', {'class': 'cbi-value', 'style': 'margin-top: 20px'}, [ E('div', {'class': 'cbi-value-title'}, _('Homebox service control')), E('div', {'class': 'cbi-value-field'}, toggleBtn), - E('div', { 'style': 'text-align: right; font-style: italic; margin-top: 20px;' }, [ - _('© github '), - E('a', { - 'href': 'https://github.com/sirpdboy/luci-app-netspeedtest', - 'target': '_blank', - 'style': 'text-decoration: none;' - }, 'by sirpdboy') - ]) + E('div', { 'style': 'text-align: right; font-style: italic; margin-top: 20px;' }, [ + _('© github '), + E('a', { + 'href': 'https://github.com/sirpdboy', + 'target': '_blank', + 'style': 'text-decoration: none;' + }, 'by sirpdboy') + ]) ]) ])); @@ -134,9 +157,9 @@ async function checkProcess() { statusSection, container ]); - } + }, - // handleSaveApply: null, - // handleSave: null, - // handleReset: null + handleSaveApply: null, + handleSave: null, + handleReset: null }); \ No newline at end of file diff --git a/luci-app-netspeedtest/htdocs/luci-static/resources/view/netspeedtest/iperf3.js b/luci-app-netspeedtest/htdocs/luci-static/resources/view/netspeedtest/iperf3.js index bc4a463bf..7d96957dd 100644 --- a/luci-app-netspeedtest/htdocs/luci-static/resources/view/netspeedtest/iperf3.js +++ b/luci-app-netspeedtest/htdocs/luci-static/resources/view/netspeedtest/iperf3.js @@ -53,9 +53,9 @@ function controlService(action) { return view.extend({ -// handleSaveApply: null, -// handleSave: null, -// handleReset: null, + handleSaveApply: null, + handleSave: null, + handleReset: null, load: function() { return Promise.all([ uci.load('netspeedtest') diff --git a/luci-app-netspeedtest/htdocs/luci-static/resources/view/netspeedtest/openspeedtest.js b/luci-app-netspeedtest/htdocs/luci-static/resources/view/netspeedtest/openspeedtest.js index 8bc8e88b9..3e47fdbd9 100644 --- a/luci-app-netspeedtest/htdocs/luci-static/resources/view/netspeedtest/openspeedtest.js +++ b/luci-app-netspeedtest/htdocs/luci-static/resources/view/netspeedtest/openspeedtest.js @@ -28,11 +28,10 @@ return view.extend({ }; return m.render(); - } + }, - - // handleSaveApply: null, - // handleSave: null, - // handleReset: null + handleSaveApply: null, + handleSave: null, + handleReset: null }); diff --git a/luci-app-netspeedtest/htdocs/luci-static/resources/view/netspeedtest/speedtest.js b/luci-app-netspeedtest/htdocs/luci-static/resources/view/netspeedtest/speedtest.js index c04a41eb0..6a7fa0c4a 100644 --- a/luci-app-netspeedtest/htdocs/luci-static/resources/view/netspeedtest/speedtest.js +++ b/luci-app-netspeedtest/htdocs/luci-static/resources/view/netspeedtest/speedtest.js @@ -168,5 +168,8 @@ return view.extend({ }, this), 5); return nodes; }, this, m)); - } + }, + handleSaveApply: null, + handleSave: null, + handleReset: null }); diff --git a/luci-app-netspeedtest/po/zh_Hans/netspeedtest.po b/luci-app-netspeedtest/po/zh_Hans/netspeedtest.po index a84d28e38..4824ecb7d 100644 --- a/luci-app-netspeedtest/po/zh_Hans/netspeedtest.po +++ b/luci-app-netspeedtest/po/zh_Hans/netspeedtest.po @@ -100,8 +100,8 @@ msgstr "Homebox服务端" msgid "Homebox Service Not Running" msgstr "Homebox服务端未运行" -msgid "Ookla® SpeedTest-CLI" -msgstr "" +msgid "Open Web Interface" +msgstr "打开WEB页面" msgid "Start Ookla SpeedTest" msgstr "开始宽带测速" @@ -119,4 +119,10 @@ msgid "No test results yet." msgstr "还没有测试结果" msgid "Test Script" -msgstr "测速脚本" \ No newline at end of file +msgstr "测速脚本" + +msgid "Homebox Control panel" +msgstr "Homebox控制台" + +msgid "Due to browser security policies, the Homebox interface https cannot be embedded directly." +msgstr "由于浏览器安全策略,Homebox接口https不能直接嵌入。"