mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-30 05:22:44 +08:00
微调检测更新的方法
This commit is contained in:
parent
409f6fc5c1
commit
194cde3f8d
30
assets/checkUpdate.js
Normal file
30
assets/checkUpdate.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
checkUpdate = () => {
|
||||||
|
let p = window.pluginInfo;
|
||||||
|
if (!utools.db.get(p.version)) {
|
||||||
|
$.get(p.publishPage, data => {
|
||||||
|
var re = new RegExp(`<title>\\[插件\\]\\[${p.pluginName} (.*?)\\](.*?) - 猿料<\\/title>`)
|
||||||
|
data = re.exec(data);
|
||||||
|
let lastVer = data[1],
|
||||||
|
desc = data[2];
|
||||||
|
if (lastVer != p.version) {
|
||||||
|
options = {
|
||||||
|
type: 'info',
|
||||||
|
title: '插件有可用更新',
|
||||||
|
icon: window.logo,
|
||||||
|
cancelId: 1,
|
||||||
|
message: `发现新版本 ${lastVer},是否前往更新?\n更新内容:\n${desc}`,
|
||||||
|
buttons: ['起驾', '朕知道了', '别再烦朕']
|
||||||
|
};
|
||||||
|
window.messageBox(options, index => {
|
||||||
|
if (index == 0) {
|
||||||
|
window.open(p.publishPage)
|
||||||
|
} else if (index == 2) {
|
||||||
|
utools.db.put({ _id: p.version, data: "pass" })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.log('当前已是最新版本!');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@
|
|||||||
<script src="assets/hlsearch.js"></script>
|
<script src="assets/hlsearch.js"></script>
|
||||||
<script src="assets/jquery.nicescroll.min.js"></script>
|
<script src="assets/jquery.nicescroll.min.js"></script>
|
||||||
<script src="assets/prism.js"></script>
|
<script src="assets/prism.js"></script>
|
||||||
|
<script src="assets/checkUpdate.js"></script>
|
||||||
<title>Manuals</title>
|
<title>Manuals</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user