mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-18 07:23:59 +00:00
luci-app-unblockmusic: tidy up code (#8197)
This commit is contained in:
parent
38162e62b3
commit
fed785d92f
package/lean/luci-app-unblockmusic/luasrc
@ -1,4 +1,3 @@
|
||||
|
||||
module("luci.controller.unblockmusic", package.seeall)
|
||||
|
||||
function index()
|
||||
@ -6,17 +5,15 @@ function index()
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin", "services", "unblockmusic"}, firstchild(), _("Unblock Netease Music"), 50).dependent = false
|
||||
|
||||
entry({"admin", "services", "unblockmusic", "general"}, cbi("unblockmusic/unblockmusic"), _("Base Setting"), 1)
|
||||
entry({"admin", "services", "unblockmusic", "log"}, form("unblockmusic/unblockmusiclog"), _("Log"), 2)
|
||||
|
||||
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", "log"}, form("unblockmusic/unblockmusic_log"), _("Log"), 2).leaf = true
|
||||
entry({"admin", "services", "unblockmusic", "status"}, call("act_status")).leaf = true
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e={}
|
||||
e.running=luci.sys.call("busybox ps -w | grep UnblockNeteaseMusic | grep -v grep | grep -v logcheck.sh >/dev/null")==0
|
||||
local e = {}
|
||||
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.write_json(e)
|
||||
end
|
||||
|
@ -1,18 +1,19 @@
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
mp = Map("unblockmusic", translate("解锁网易云灰色歌曲"))
|
||||
mp = Map("unblockmusic")
|
||||
mp.title = translate("解锁网易云灰色歌曲")
|
||||
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.anonymous=true
|
||||
s.addremove=false
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
enabled = s:option(Flag, "enabled", translate("启用"))
|
||||
enabled.description = translate("启用后,路由器自动分流解锁,大部分设备无需设置代理")
|
||||
enabled.default = 0
|
||||
enabled.rmempty = false
|
||||
enabled.description = translate("启用后,路由器自动分流解锁,大部分设备无需设置代理")
|
||||
|
||||
apptype = s:option(ListValue, "apptype", translate("解锁程序选择"))
|
||||
if nixio.fs.access("/usr/bin/UnblockNeteaseMusic") then
|
||||
@ -48,63 +49,63 @@ search_limit.default = "0"
|
||||
search_limit:depends("apptype", "go")
|
||||
|
||||
flac = s:option(Flag, "flac_enabled", translate("启用无损音质"))
|
||||
flac.description = translate("目前仅支持酷我、QQ、咪咕")
|
||||
flac.default = "1"
|
||||
flac.rmempty = false
|
||||
flac.description = translate("目前仅支持酷我、QQ、咪咕")
|
||||
flac:depends("apptype", "nodejs")
|
||||
flac:depends("apptype", "go")
|
||||
|
||||
force = s:option(Flag, "force_enabled", translate("强制替换为高音质歌曲"))
|
||||
force.description = translate("如果歌曲音质在 320Kbps 以内,则尝试强制替换为高音质版本")
|
||||
force.default = "1"
|
||||
force.rmempty = false
|
||||
force.description = translate("如果歌曲音质在 320Kbps 以内,则尝试强制替换为高音质版本")
|
||||
force:depends("apptype", "nodejs")
|
||||
|
||||
o = s:option(Flag, "autoupdate")
|
||||
o.title = translate("自动检查更新主程序")
|
||||
o.default = "1"
|
||||
o.rmempty = false
|
||||
o.description = translate("每天自动检测并更新到最新版本")
|
||||
o:depends("apptype", "nodejs")
|
||||
autoupdate = s:option(Flag, "autoupdate", translate("自动检查更新主程序"))
|
||||
autoupdate.description = translate("每天自动检测并更新到最新版本")
|
||||
autoupdate.default = "1"
|
||||
autoupdate.rmempty = false
|
||||
autoupdate: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 参数")
|
||||
|
||||
local ver = fs.readfile("/usr/share/UnblockNeteaseMusic/core_ver") or "0.00"
|
||||
|
||||
o = s:option(Button, "restart",translate("手动更新"))
|
||||
o.inputtitle = translate("更新核心版本")
|
||||
o.description = string.format(translate("NodeJS 解锁主程序版本") .. "<strong><font color=\"green\">: %s </font></strong>", ver)
|
||||
o.inputstyle = "reload"
|
||||
o.write = function()
|
||||
restart = s:option(Button, "restart", translate("手动更新"))
|
||||
restart.inputtitle = translate("更新核心版本")
|
||||
restart.description = string.format(translate("NodeJS 解锁主程序版本") .. "<strong><font color=\"green\">: %s </font></strong>", ver)
|
||||
restart.inputstyle = "reload"
|
||||
restart.write = function()
|
||||
luci.sys.exec("/usr/share/UnblockNeteaseMusic/update_core.sh luci_update 2>&1")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "unblockmusic"))
|
||||
end
|
||||
o:depends("apptype", "nodejs")
|
||||
restart:depends("apptype", "nodejs")
|
||||
|
||||
t=mp:section(TypedSection,"acl_rule",translate("例外客户端规则"),
|
||||
translate("可以为局域网客户端分别设置不同的例外模式,默认无需设置"))
|
||||
t.template="cbi/tblsection"
|
||||
t.sortable=true
|
||||
t.anonymous=true
|
||||
t.addremove=true
|
||||
t = mp:section(TypedSection, "acl_rule")
|
||||
t.title = translate("例外客户端规则")
|
||||
t.description = translate("可以为局域网客户端分别设置不同的例外模式,默认无需设置")
|
||||
t.template = "cbi/tblsection"
|
||||
t.sortable = true
|
||||
t.anonymous = true
|
||||
t.addremove = true
|
||||
|
||||
e=t:option(Value,"ipaddr",translate("IP Address"))
|
||||
e.width="40%"
|
||||
e.datatype="ip4addr"
|
||||
e.placeholder="0.0.0.0/0"
|
||||
ipaddr = t:option(Value, "ipaddr", translate("IP 地址"))
|
||||
ipaddr.width = "40%"
|
||||
ipaddr.datatype = "ip4addr"
|
||||
ipaddr.placeholder = "0.0.0.0/0"
|
||||
luci.ip.neighbors({ family = 4 }, function(entry)
|
||||
if entry.reachable then
|
||||
e:value(entry.dest:string())
|
||||
ipaddr:value(entry.dest:string())
|
||||
end
|
||||
end)
|
||||
|
||||
e=t:option(ListValue,"filter_mode",translate("例外协议"))
|
||||
e.width="40%"
|
||||
e.default="disable"
|
||||
e.rmempty=false
|
||||
e:value("disable",translate("不代理HTTP和HTTPS"))
|
||||
e:value("http",translate("不代理HTTP"))
|
||||
e:value("https",translate("不代理HTTPS"))
|
||||
filter_mode = t:option(ListValue, "filter_mode", translate("例外协议"))
|
||||
filter_mode.width = "40%"
|
||||
filter_mode.default = "disable"
|
||||
filter_mode.rmempty = false
|
||||
filter_mode:value("disable", translate("不代理HTTP和HTTPS"))
|
||||
filter_mode:value("http", translate("不代理HTTP"))
|
||||
filter_mode:value("https", translate("不代理HTTPS"))
|
||||
|
||||
return mp
|
||||
|
Loading…
Reference in New Issue
Block a user