From dcdb24e7a2db9af79ee86e359bca60571e860388 Mon Sep 17 00:00:00 2001 From: sbwml Date: Mon, 23 Jun 2025 21:32:05 +0800 Subject: [PATCH] luci-app-openlist: "Open Web Interface" button uses site_url if available * fallback to protocol/hostname/port Signed-off-by: sbwml --- luci-app-openlist/Makefile | 2 +- .../luci-static/resources/view/openlist/basic.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/luci-app-openlist/Makefile b/luci-app-openlist/Makefile index 181bccc..6f4a28e 100644 --- a/luci-app-openlist/Makefile +++ b/luci-app-openlist/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openlist -PKG_VERSION:=1.0.0 +PKG_VERSION:=1.0.1 PKG_RELEASE:=1 LUCI_TITLE:=LuCI support for openlist diff --git a/luci-app-openlist/htdocs/luci-static/resources/view/openlist/basic.js b/luci-app-openlist/htdocs/luci-static/resources/view/openlist/basic.js index 401f3c3..a980c6b 100644 --- a/luci-app-openlist/htdocs/luci-static/resources/view/openlist/basic.js +++ b/luci-app-openlist/htdocs/luci-static/resources/view/openlist/basic.js @@ -23,12 +23,18 @@ function getServiceStatus() { }); } -function renderStatus(isRunning, protocol, webport) { +function renderStatus(isRunning, protocol, webport, site_url) { var spanTemp = '%s %s'; var renderHTML; if (isRunning) { - var button = String.format('', - _('Open Web Interface'), protocol, window.location.hostname, webport); + var buttonUrl = ''; + if (site_url && site_url.trim() !== '') { + buttonUrl = site_url; + } else { + buttonUrl = String.format('%s//%s:%s/', protocol, window.location.hostname, webport); + } + var button = String.format('', + _('Open Web Interface'), buttonUrl); renderHTML = spanTemp.format('green', 'OpenList', _('RUNNING')) + button; } else { renderHTML = spanTemp.format('red', 'OpenList', _('NOT RUNNING')); @@ -71,6 +77,7 @@ return view.extend({ } else if (ssl === '1') { protocol = 'https:'; } + var site_url = uci.get(data[0], '@openlist[0]', 'site_url') || ''; m = new form.Map('openlist', _('OpenList'), _('A file list program that supports multiple storage.')); @@ -83,7 +90,7 @@ return view.extend({ poll.add(function () { return L.resolveDefault(getServiceStatus()).then(function (res) { var view = document.getElementById('service_status'); - view.innerHTML = renderStatus(res, protocol, webport); + view.innerHTML = renderStatus(res, protocol, webport, site_url); }); });