feat: auto reload page if wiki not loaded

This commit is contained in:
Lin Onetwo 2020-06-27 12:49:47 +08:00
parent 63041ef460
commit 8490cccadb

View file

@ -47,6 +47,18 @@ const handleLoaded = (event) => {
loadDarkReader();
});
// reload page if it is not loaded yet
const CHECK_LOADED_INTERVAL = 1000 * 3;
function refresh() {
const serverNotStarted = !document || document.querySelector('.tc-site-title') === null;
if (serverNotStarted) {
window.location.reload(true);
} else {
setTimeout(refresh, CHECK_LOADED_INTERVAL);
}
}
setTimeout(refresh, CHECK_LOADED_INTERVAL);
const jsCodeInjection = ipcRenderer.sendSync('get-preference', 'jsCodeInjection');
const allowNodeInJsCodeInjection = ipcRenderer.sendSync('get-preference', 'allowNodeInJsCodeInjection');
const cssCodeInjection = ipcRenderer.sendSync('get-preference', 'cssCodeInjection');