local resourceName = "test-download" _webResources:afterDownload(function(webResource, scriptFile, throwable) if (webResource:getName() == resourceName) then if (scriptFile ~= nil) then _console:log("afterDownload", webResource, "下载成功", scriptFile) elseif (throwable ~= nil) then _console:error("afterDownload", webResource, "下载失败", throwable) end end end) _webResources:beforeDownload(function(webResource) if (webResource:getName() == resourceName) then local RegexUtils = _java:loadClass("com.blankj.utilcode.util.RegexUtils") webResource:setUrl(RegexUtils:getReplaceFirst(webResource:getUrl(), "172.16.0.238", "172.16.0.235")) _console:log("beforeDownload", webResource) _console:assertTrue(webResource:getProperty("p1") == "v11", "p1 == v11") _console:log(webResource:getProperties()) -- 这里可以根据 property 执行其他操作 end return nil end) _webResources:download(function(webResource) webResource:setName(resourceName) webResource:setUrl("https://github.com/m8test/runtime-release/raw/refs/heads/main/frameworks/android-34.jar") webResource:setVersion("34") -- p1 = v1 webResource:addProperty("p1", "v1", true) -- p1 = v11 webResource:addProperty("p1", "v11", true) -- p1 = v11 webResource:addProperty("p1", "v111", false) -- p2 = v2 webResource:addProperty("p2", "v2", false) -- p3 = v3 webResource:addProperty("p3", "v3", false) -- p3 = nil webResource:removeProperty("p3") end)