mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-02 19:40:48 +08:00
🐛 remove invalid requests during boot (#10227)
This commit is contained in:
parent
bb23e7b2f3
commit
beefd871e9
@ -30,10 +30,6 @@
|
|||||||
style="color: #9aa0a6;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;padding: 8px;height: 16px;line-height: 16px;"></div>
|
style="color: #9aa0a6;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;padding: 8px;height: 16px;line-height: 16px;"></div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
const sleep = (ms) => {
|
|
||||||
return new Promise(resolve => setTimeout(resolve, ms))
|
|
||||||
}
|
|
||||||
|
|
||||||
const getSearch = (key) => {
|
const getSearch = (key) => {
|
||||||
if (window.location.search.indexOf('?') === -1) {
|
if (window.location.search.indexOf('?') === -1) {
|
||||||
return ''
|
return ''
|
||||||
@ -49,36 +45,9 @@
|
|||||||
})
|
})
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
const redirect = () => {
|
|
||||||
const uri = 'http://127.0.0.1:' + location.port
|
|
||||||
if (navigator.userAgent.match(/Android/i))
|
|
||||||
document.location = uri
|
|
||||||
else
|
|
||||||
window.location.replace(uri)
|
|
||||||
}
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const v = getSearch('v')
|
const v = getSearch('v')
|
||||||
document.getElementById('details').textContent = "v" + v + ' Booting kernel...'
|
document.getElementById('details').textContent = "v" + v + ' Booting kernel...'
|
||||||
let progressing = false
|
|
||||||
while (!progressing) {
|
|
||||||
try {
|
|
||||||
const progressResult = await fetch('http://127.0.0.1:' + location.port + '/api/system/bootProgress')
|
|
||||||
const progressData = await progressResult.json()
|
|
||||||
document.getElementById('progress').style.width = progressData.data.progress + '%'
|
|
||||||
document.getElementById('details').textContent = progressData.data.details
|
|
||||||
if (progressData.data.progress >= 100) {
|
|
||||||
progressing = true
|
|
||||||
if (navigator.userAgent.indexOf('Electron') === -1) {
|
|
||||||
redirect()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
await sleep(100)
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
await sleep(100)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})()
|
})()
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
Reference in New Issue
Block a user