Przeglądaj źródła

refactor: remove obsolete functions

Signed-off-by: Tianling Shen <[email protected]>
Tianling Shen 4 lat temu
rodzic
commit
5defeb2225

+ 1 - 1
Makefile

@@ -10,7 +10,7 @@ LUCI_PKGARCH:=all
 
 PKG_NAME:=luci-app-unblockneteasemusic
 PKG_VERSION:=2.9
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_MAINTAINER:=Tianling Shen <[email protected]>
 

+ 1 - 30
luasrc/controller/unblockneteasemusic.lua

@@ -16,10 +16,9 @@ function index()
 
 	entry({"admin", "services", "unblockneteasemusic", "general"},cbi("unblockneteasemusic/unblockneteasemusic"), _("基本设定"), 1)
 	entry({"admin", "services", "unblockneteasemusic", "upgrade"},form("unblockneteasemusic/unblockneteasemusic_upgrade"), _("更新组件"), 2).leaf = true
-	entry({"admin", "services", "unblockneteasemusic", "log"},form("unblockneteasemusic/unblockneteasemusiclog"), _("日志"), 3)
+	entry({"admin", "services", "unblockneteasemusic", "log"},form("unblockneteasemusic/unblockneteasemusic_log"), _("日志"), 3)
 
 	entry({"admin", "services", "unblockneteasemusic", "status"},call("act_status")).leaf=true
-	entry({"admin", "services", "unblockneteasemusic", "update_luci"},call("act_update_luci"))
 	entry({"admin", "services", "unblockneteasemusic", "update_core"},call("act_update_core"))
 end
 
@@ -30,34 +29,6 @@ function act_status()
 	luci.http.write_json(e)
 end
 
-function update_luci()
-	luci_cloud_ver=luci.sys.exec("uclient-fetch -q -O- 'https://api.github.com/repos/immortalwrt/luci-app-unblockneteasemusic/releases/latest' | jsonfilter -e '@.tag_name'")
-	if not luci_cloud_ver then
-		return "1"
-	else
-		luci_local_ver=luci.sys.exec("opkg info 'luci-app-unblockneteasemusic' |sed -n '2p' |tr -d 'Version: '")
-		if not luci_local_ver or (luci_local_ver ~= luci_cloud_ver) then
-			luci.sys.call("rm -f /usr/share/unblockneteasemusic/update_luci_successfully")
-			luci.sys.call("/usr/share/unblockneteasemusic/update.sh update_luci")
-			if not nixio.fs.access("/usr/share/unblockneteasemusic/update_luci_successfully") then
-				return "2"
-			else
-				luci.sys.call("rm -f /usr/share/unblockneteasemusic/update_luci_successfully")
-				return luci_cloud_ver
-			end
-		else
-			return "0"
-		end
-	end
-end
-
-function act_update_luci()
-	luci.http.prepare_content("application/json")
-	luci.http.write_json({
-		ret = update_luci();
-	})
-end
-
 function update_core()
 	core_cloud_ver=luci.sys.exec("uclient-fetch -q -O- 'https://api.github.com/repos/1715173329/UnblockNeteaseMusic/commits/enhanced' | jsonfilter -e '@.sha'")
 	core_cloud_ver_mini=string.sub(core_cloud_ver, 1, 7)

+ 0 - 0
luasrc/model/cbi/unblockneteasemusic/unblockneteasemusiclog.lua → luasrc/model/cbi/unblockneteasemusic/unblockneteasemusic_log.lua


+ 0 - 6
luasrc/model/cbi/unblockneteasemusic/unblockneteasemusic_upgrade.lua

@@ -4,12 +4,6 @@ m = SimpleForm("Version")
 m.reset = false
 m.submit = false
 
-up_luci = m:field(DummyValue,"update_luci", translate("更新LuCI"))
-up_luci.rawhtml = true
-up_luci.template = "unblockneteasemusic/update_luci"
-up_luci.value = translate("未检查")
-up_luci.description = "更新完毕后请手动刷新该界面"
-
 up_core = m:field(DummyValue,"update_core", translate("更新主程序"))
 up_core.rawhtml = true
 up_core.template = "unblockneteasemusic/update_core"

+ 0 - 36
luasrc/view/unblockneteasemusic/update_luci.htm

@@ -1,36 +0,0 @@
-<%+cbi/valueheader%>
-
-<script type="text/javascript">//<![CDATA[
-	function act_update_luci(btn,dataname)
-	{
-		btn.disabled = true;
-		btn.value    = '<%:正在更新LuCI...%> ';
-		XHR.get('<%=luci.dispatcher.build_url("admin", "services", "unblockneteasemusic","update_luci")%>',
-			status.ret,
-			function(x,status)
-			{
-				var s = document.getElementById(dataname+'-status');
-				if (s)
-				{
-					if(status.ret=="0")
-						s.innerHTML ="<font color='green'>"+"<%:当前已是最新版本%>"+"</font>";
-					else if (status.ret=="1")
-						s.innerHTML ="<font color='red'>"+"<%:无法检测最新版本%>"+"</font>";
-					else if(status.ret=="2")
-						s.innerHTML ="<font color='red'>"+"<%:更新失败,请稍后重试%>"+"</font>";
-					else
-						s.innerHTML ="<font color='green'>"+"<%:更新成功,当前版本号:%>"+status.ret+"</font>";
-				}
-				btn.disabled = false;
-				btn.value    = '<%:点此更新LuCI%>';
-			}
-		);
-		return false;
-	}
-//]]></script>
-
-
-<input type="button" class="btn cbi-button cbi-input-reload" value="<%:点此更新LuCI%> " onclick="return act_update_luci(this,'<%=self.option%>')" />
-<span id="<%=self.option%>-status"><em><%=self.value%></em></span>
-
-<%+cbi/valuefooter%>

+ 0 - 40
root/usr/share/unblockneteasemusic/update.sh

@@ -18,42 +18,6 @@ function clean_log(){
 	echo "" > "/tmp/$NAME.log"
 }
 
-function check_luci_latest_version(){
-	luci_latest_ver="$(uclient-fetch -q -O- 'https://api.github.com/repos/immortalwrt/luci-app-unblockneteasemusic/releases/latest' | jsonfilter -e '@.tag_name')"
-	[ -z "${luci_latest_ver}" ] && { echo -e "\nFailed to check latest LuCI version, please try again later." >> "/tmp/$NAME.log"; exit 1; }
-	if [ "$(opkg info "luci-app-unblockneteasemusic" |sed -n "2p" |tr -d "Version: ")" != "${luci_latest_ver}" ]; then
-		clean_log
-		echo -e "Local LuCI version: $(opkg info "luci-app-unblockneteasemusic" |sed -n "2p" |tr -d "Version: "), cloud LuCI version: ${luci_latest_ver}." >> "/tmp/$NAME.log"
-		update_luci
-	else
-		echo -e "\nLocal LuCI version: $(opkg info "luci-app-unblockneteasemusic" |sed -n "2p" |tr -d "Version: "), cloud LuCI version: ${luci_latest_ver}." >> "/tmp/$NAME.log"
-		echo -e "You're already using the latest LuCI version." >> "/tmp/$NAME.log"
-		exit 3
-	fi
-}
-
-function update_luci(){
-	echo -e "Updating LuCI..." >> "/tmp/$NAME.log"
-
-	mkdir -p "/tmp" > "/dev/null" 2>&1
-
-	uclient-fetch -q "https://github.com/immortalwrt/luci-app-unblockneteasemusic/releases/download/v${luci_latest_ver}/luci-app-unblockneteasemusic_${luci_latest_ver}_all.ipk" -O "/tmp/luci-app-unblockneteasemusic_${luci_latest_ver}_all.ipk" > "/dev/null" 2>&1
-	opkg install "/tmp/luci-app-unblockneteasemusic_${luci_latest_ver}_all.ipk"
-	rm -f "/tmp/luci-app-unblockneteasemusic_${luci_latest_ver}_all.ipk"
-	rm -rf "/tmp/luci-indexcache" "/tmp/luci-modulecache"
-
-	if [ "$(opkg info 'luci-app-unblockneteasemusic' |sed -n '2p' |tr -d 'Version: ')" != "${luci_latest_ver}" ]; then
-		echo -e "Failed to update LuCI." >> "/tmp/$NAME.log"
-		exit 1
-	else
-		touch "/usr/share/$NAME/update_luci_successfully"
-		/etc/init.d/firewall restart > "/dev/null" 2>&1
-	fi
-
-	echo -e "Succeeded in updating LuCI." > "/tmp/$NAME.log"
-	echo -e "Current LuCI version: ${luci_latest_ver}.\n" >> "/tmp/$NAME.log"
-}
-
 function check_core_latest_version(){
 	core_latest_ver="$(uclient-fetch -q -O- 'https://api.github.com/repos/1715173329/UnblockNeteaseMusic/commits/enhanced' | jsonfilter -e '@.sha')"
 	[ -z "${core_latest_ver}" ] && { echo -e "\nFailed to check latest core version, please try again later." >> "/tmp/$NAME.log"; exit 1; }
@@ -99,10 +63,6 @@ function update_core(){
 }
 
 case "$1" in
-	"update_luci")
-		check_luci_if_already_running
-		check_luci_latest_version
-		;;
 	"update_core")
 		check_core_if_already_running
 		check_core_latest_version