This repository has been archived by the owner on Sep 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8a6b5a
commit 11d8e06
Showing
5 changed files
with
124 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
let userOrOrgName = "QuarkPixel"; | ||
let repoName = "ScreenAmbientLight"; | ||
let currentVersion = "0.1.0"; | ||
let checker = UpdateChecker.createNew(userOrOrgName, repoName, currentVersion); | ||
checker.hasNewVersion(function (result) { | ||
if(result) { | ||
checker.openBrowserToReleases(); | ||
} | ||
}); | ||
|
||
function loadapp(url, btnId, num) { | ||
mui("body").on("tap", btnId, function () { | ||
var loadId = this.getAttribute("id") | ||
sendloadId = loadId.slice(num) | ||
var getvalue = document.getElementById(loadId).innerHTML | ||
var loaddata = { | ||
config: { | ||
id: sendloadId, | ||
}, | ||
fun_Success: function (data) { | ||
console.log(JSON.stringify(data)) | ||
var geturl = data.data.down_a | ||
if (geturl == "") { | ||
alert("暂无数据可供下载") | ||
} else { | ||
createDownload(geturl, loadId) | ||
} | ||
}, | ||
} | ||
if (getvalue == "下载") { | ||
Fun_App.ExAjax(url, loaddata) | ||
} | ||
if (getvalue != "下载") { | ||
document | ||
.getElementById(loadId) | ||
.addEventListener("tap", function () { | ||
document.getElementById(loadId).innerHTML = "暂停" | ||
pauseDownload() | ||
}) | ||
} | ||
if (getvalue == "暂停") { | ||
document | ||
.getElementById(loadId) | ||
.addEventListener("tap", function () { | ||
resumeDownload() | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
/* | ||
* 创建下载任务 | ||
*/ | ||
function createDownload(url, loadId) { | ||
dTask = plus.downloader.createDownload(url) | ||
dTask.addEventListener( | ||
"statechanged", | ||
function (download, status) { | ||
var fimeName = download.getFileName().slice(11).replace(".apk", "") | ||
if (download.state == 4 && status == 200) { | ||
document.getElementById(loadId).innerHTML = "下载" | ||
plus.nativeUI.confirm( | ||
"下载已完成,是否安装?", | ||
function (e) { | ||
if (e.index == 0) { | ||
openFile(download.getFileName()) | ||
} else { | ||
del() | ||
} | ||
}, | ||
fimeName, | ||
["确定", "取消"] | ||
) | ||
} else { | ||
var progress = | ||
(download.downloadedSize / download.totalSize) * 100 | ||
progress = parseInt(progress.toFixed(2)) | ||
if (isNaN(progress)) { | ||
document.getElementById(loadId).innerHTML = "下载" | ||
} else if (progress == 100) { | ||
del() | ||
document.getElementById(loadId).innerHTML = "下载" | ||
} else { | ||
document.getElementById(loadId).innerHTML = progress + "%" | ||
} | ||
} | ||
}, | ||
false | ||
) | ||
dTask.start() | ||
} | ||
|
||
/* | ||
* 暂停下载任务 | ||
*/ | ||
// function pauseDownload() { | ||
// dtask.pause() | ||
// } | ||
/* | ||
* 恢复下载任务 | ||
*/ | ||
// function resumeDownload() { | ||
// dtask.resume() | ||
// } | ||
/* | ||
* 取消下载 | ||
*/ | ||
// function del() { | ||
// plus.downloader.clear() | ||
// } | ||
/* | ||
* 打开文件操作 | ||
*/ | ||
function openFile(fileName) { | ||
plus.runtime.openFile(fileName) | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#ScreenLamp { | ||
background-color: #e500e5; | ||
/* background-color: #e500e5; */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters