luci-app-unblockmusic: tidy up code (#8197)
This commit is contained in:
parent
38162e62b3
commit
fed785d92f
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
module("luci.controller.unblockmusic", package.seeall)
|
module("luci.controller.unblockmusic", package.seeall)
|
||||||
|
|
||||||
function index()
|
function index()
|
||||||
@ -6,17 +5,15 @@ function index()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
entry({"admin", "services", "unblockmusic"}, firstchild(), _("Unblock Netease Music"), 50).dependent = false
|
entry({"admin", "services", "unblockmusic"}, alias("admin", "services", "unblockmusic", "general"), _("Unblock Netease Music"), 50).dependent = true
|
||||||
|
entry({"admin", "services", "unblockmusic", "general"}, cbi("unblockmusic/unblockmusic"), _("Base Setting"), 1).leaf = true
|
||||||
entry({"admin", "services", "unblockmusic", "general"}, cbi("unblockmusic/unblockmusic"), _("Base Setting"), 1)
|
entry({"admin", "services", "unblockmusic", "log"}, form("unblockmusic/unblockmusic_log"), _("Log"), 2).leaf = true
|
||||||
entry({"admin", "services", "unblockmusic", "log"}, form("unblockmusic/unblockmusiclog"), _("Log"), 2)
|
|
||||||
|
|
||||||
entry({"admin", "services", "unblockmusic", "status"}, call("act_status")).leaf = true
|
entry({"admin", "services", "unblockmusic", "status"}, call("act_status")).leaf = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function act_status()
|
function act_status()
|
||||||
local e={}
|
local e = {}
|
||||||
e.running=luci.sys.call("busybox ps -w | grep UnblockNeteaseMusic | grep -v grep | grep -v logcheck.sh >/dev/null")==0
|
e.running = luci.sys.call("busybox ps -w | grep UnblockNeteaseMusic | grep -v grep | grep -v logcheck.sh >/dev/null") == 0
|
||||||
luci.http.prepare_content("application/json")
|
luci.http.prepare_content("application/json")
|
||||||
luci.http.write_json(e)
|
luci.http.write_json(e)
|
||||||
end
|
end
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
local fs = require "nixio.fs"
|
local fs = require "nixio.fs"
|
||||||
|
|
||||||
mp = Map("unblockmusic", translate("解锁网易云灰色歌曲"))
|
mp = Map("unblockmusic")
|
||||||
|
mp.title = translate("解锁网易云灰色歌曲")
|
||||||
mp.description = translate("采用 [QQ/百度/酷狗/酷我/咪咕/JOOX]等音源,替换网易云变灰歌曲链接")
|
mp.description = translate("采用 [QQ/百度/酷狗/酷我/咪咕/JOOX]等音源,替换网易云变灰歌曲链接")
|
||||||
|
|
||||||
mp:section(SimpleSection).template = "unblockmusic/unblockmusic_status"
|
mp:section(SimpleSection).template = "unblockmusic/unblockmusic_status"
|
||||||
|
|
||||||
s = mp:section(TypedSection, "unblockmusic")
|
s = mp:section(TypedSection, "unblockmusic")
|
||||||
s.anonymous=true
|
s.anonymous = true
|
||||||
s.addremove=false
|
s.addremove = false
|
||||||
|
|
||||||
enabled = s:option(Flag, "enabled", translate("启用"))
|
enabled = s:option(Flag, "enabled", translate("启用"))
|
||||||
|
enabled.description = translate("启用后,路由器自动分流解锁,大部分设备无需设置代理")
|
||||||
enabled.default = 0
|
enabled.default = 0
|
||||||
enabled.rmempty = false
|
enabled.rmempty = false
|
||||||
enabled.description = translate("启用后,路由器自动分流解锁,大部分设备无需设置代理")
|
|
||||||
|
|
||||||
apptype = s:option(ListValue, "apptype", translate("解锁程序选择"))
|
apptype = s:option(ListValue, "apptype", translate("解锁程序选择"))
|
||||||
if nixio.fs.access("/usr/bin/UnblockNeteaseMusic") then
|
if nixio.fs.access("/usr/bin/UnblockNeteaseMusic") then
|
||||||
@ -48,63 +49,63 @@ search_limit.default = "0"
|
|||||||
search_limit:depends("apptype", "go")
|
search_limit:depends("apptype", "go")
|
||||||
|
|
||||||
flac = s:option(Flag, "flac_enabled", translate("启用无损音质"))
|
flac = s:option(Flag, "flac_enabled", translate("启用无损音质"))
|
||||||
|
flac.description = translate("目前仅支持酷我、QQ、咪咕")
|
||||||
flac.default = "1"
|
flac.default = "1"
|
||||||
flac.rmempty = false
|
flac.rmempty = false
|
||||||
flac.description = translate("目前仅支持酷我、QQ、咪咕")
|
|
||||||
flac:depends("apptype", "nodejs")
|
flac:depends("apptype", "nodejs")
|
||||||
flac:depends("apptype", "go")
|
flac:depends("apptype", "go")
|
||||||
|
|
||||||
force = s:option(Flag, "force_enabled", translate("强制替换为高音质歌曲"))
|
force = s:option(Flag, "force_enabled", translate("强制替换为高音质歌曲"))
|
||||||
|
force.description = translate("如果歌曲音质在 320Kbps 以内,则尝试强制替换为高音质版本")
|
||||||
force.default = "1"
|
force.default = "1"
|
||||||
force.rmempty = false
|
force.rmempty = false
|
||||||
force.description = translate("如果歌曲音质在 320Kbps 以内,则尝试强制替换为高音质版本")
|
|
||||||
force:depends("apptype", "nodejs")
|
force:depends("apptype", "nodejs")
|
||||||
|
|
||||||
o = s:option(Flag, "autoupdate")
|
autoupdate = s:option(Flag, "autoupdate", translate("自动检查更新主程序"))
|
||||||
o.title = translate("自动检查更新主程序")
|
autoupdate.description = translate("每天自动检测并更新到最新版本")
|
||||||
o.default = "1"
|
autoupdate.default = "1"
|
||||||
o.rmempty = false
|
autoupdate.rmempty = false
|
||||||
o.description = translate("每天自动检测并更新到最新版本")
|
autoupdate:depends("apptype", "nodejs")
|
||||||
o:depends("apptype", "nodejs")
|
|
||||||
|
|
||||||
download_certificate=s:option(DummyValue,"opennewwindow",translate("HTTPS 证书"))
|
download_certificate = s:option(DummyValue, "opennewwindow", translate("HTTPS 证书"))
|
||||||
download_certificate.description = translate("<input type=\"button\" class=\"btn cbi-button cbi-button-apply\" value=\"下载CA根证书\" onclick=\"window.open('https://raw.githubusercontent.com/UnblockNeteaseMusic/server/enhanced/ca.crt')\" /><br />Mac/iOS客户端需要安装 CA根证书并信任<br />iOS系统需要在“设置 -> 通用 -> 关于本机 -> 证书信任设置”中,信任 UnblockNeteaseMusic Root CA <br />Linux 设备请在启用时加入 --ignore-certificate-errors 参数")
|
download_certificate.description = translate("<input type=\"button\" class=\"btn cbi-button cbi-button-apply\" value=\"下载CA根证书\" onclick=\"window.open('https://raw.githubusercontent.com/UnblockNeteaseMusic/server/enhanced/ca.crt')\" /><br />Mac/iOS客户端需要安装 CA根证书并信任<br />iOS系统需要在“设置 -> 通用 -> 关于本机 -> 证书信任设置”中,信任 UnblockNeteaseMusic Root CA <br />Linux 设备请在启用时加入 --ignore-certificate-errors 参数")
|
||||||
|
|
||||||
local ver = fs.readfile("/usr/share/UnblockNeteaseMusic/core_ver") or "0.00"
|
local ver = fs.readfile("/usr/share/UnblockNeteaseMusic/core_ver") or "0.00"
|
||||||
|
|
||||||
o = s:option(Button, "restart",translate("手动更新"))
|
restart = s:option(Button, "restart", translate("手动更新"))
|
||||||
o.inputtitle = translate("更新核心版本")
|
restart.inputtitle = translate("更新核心版本")
|
||||||
o.description = string.format(translate("NodeJS 解锁主程序版本") .. "<strong><font color=\"green\">: %s </font></strong>", ver)
|
restart.description = string.format(translate("NodeJS 解锁主程序版本") .. "<strong><font color=\"green\">: %s </font></strong>", ver)
|
||||||
o.inputstyle = "reload"
|
restart.inputstyle = "reload"
|
||||||
o.write = function()
|
restart.write = function()
|
||||||
luci.sys.exec("/usr/share/UnblockNeteaseMusic/update_core.sh luci_update 2>&1")
|
luci.sys.exec("/usr/share/UnblockNeteaseMusic/update_core.sh luci_update 2>&1")
|
||||||
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "unblockmusic"))
|
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "unblockmusic"))
|
||||||
end
|
end
|
||||||
o:depends("apptype", "nodejs")
|
restart:depends("apptype", "nodejs")
|
||||||
|
|
||||||
t=mp:section(TypedSection,"acl_rule",translate("例外客户端规则"),
|
t = mp:section(TypedSection, "acl_rule")
|
||||||
translate("可以为局域网客户端分别设置不同的例外模式,默认无需设置"))
|
t.title = translate("例外客户端规则")
|
||||||
t.template="cbi/tblsection"
|
t.description = translate("可以为局域网客户端分别设置不同的例外模式,默认无需设置")
|
||||||
t.sortable=true
|
t.template = "cbi/tblsection"
|
||||||
t.anonymous=true
|
t.sortable = true
|
||||||
t.addremove=true
|
t.anonymous = true
|
||||||
|
t.addremove = true
|
||||||
|
|
||||||
e=t:option(Value,"ipaddr",translate("IP Address"))
|
ipaddr = t:option(Value, "ipaddr", translate("IP 地址"))
|
||||||
e.width="40%"
|
ipaddr.width = "40%"
|
||||||
e.datatype="ip4addr"
|
ipaddr.datatype = "ip4addr"
|
||||||
e.placeholder="0.0.0.0/0"
|
ipaddr.placeholder = "0.0.0.0/0"
|
||||||
luci.ip.neighbors({ family = 4 }, function(entry)
|
luci.ip.neighbors({ family = 4 }, function(entry)
|
||||||
if entry.reachable then
|
if entry.reachable then
|
||||||
e:value(entry.dest:string())
|
ipaddr:value(entry.dest:string())
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
e=t:option(ListValue,"filter_mode",translate("例外协议"))
|
filter_mode = t:option(ListValue, "filter_mode", translate("例外协议"))
|
||||||
e.width="40%"
|
filter_mode.width = "40%"
|
||||||
e.default="disable"
|
filter_mode.default = "disable"
|
||||||
e.rmempty=false
|
filter_mode.rmempty = false
|
||||||
e:value("disable",translate("不代理HTTP和HTTPS"))
|
filter_mode:value("disable", translate("不代理HTTP和HTTPS"))
|
||||||
e:value("http",translate("不代理HTTP"))
|
filter_mode:value("http", translate("不代理HTTP"))
|
||||||
e:value("https",translate("不代理HTTPS"))
|
filter_mode:value("https", translate("不代理HTTPS"))
|
||||||
|
|
||||||
return mp
|
return mp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user