添加状态信息部分的frpc版本显示

This commit is contained in:
Windy_CI 2024-09-01 13:16:28 +08:00
parent d8287f5638
commit e4087ab694
3 changed files with 28 additions and 22 deletions

View File

@ -13,6 +13,7 @@ end
function act_status()
local e = {}
e.running = luci.sys.call("pidof frpc > /dev/null") == 0
e.bin_version = luci.sys.exec("frpc -v")
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View File

@ -1,22 +0,0 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[services]], [[frpc]], [[status]])%>', null,
function(x, data) {
var tb = document.getElementById('frpc_status');
if (data && tb) {
if (data.running) {
var links = '<em><b><font color=green>Frpc <%:RUNNING%></font></b></em>';
tb.innerHTML = links;
} else {
tb.innerHTML = '<em><b><font color=red>Frpc <%:NOT RUNNING%></font></b></em>';
}
}
}
);
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
<p id="frpc_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>

View File

@ -0,0 +1,27 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[services]], [[frpc]], [[status]])%>', null,
function(x, data) {
var tb = document.getElementById('frpc_status');
if (data && tb) {
if (data.running) {
tb.innerHTML = '<em><b><font color=green> <%:Frpc%> ' + data.bin_version + '<%:RUNNING%></font></b></em><input class="btn cbi-button mar-10" type="button" value="<%:Open Frpc page%>" onclick="openwebui();" />';
} else {
tb.innerHTML = '<em><b><font color=red> <%:Frpc%> ' + data.bin_version + '<%:NOT RUNNING%></font></b></em>';
}
}
}
);
function openwebui(){
var url = window.location.host+":<%=luci.sys.exec("uci -q get frpc.common.transport_webServer_port"):gsub("^%s*(.-)%s*$", "%1")%>";
window.open('http://'+url,'target','');
}
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
<p id="frpc_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>