add preloader

This commit is contained in:
biss committed 2025-08-13 13:56:27 +08:00
1 parent 21678e4fde
commit fe6bb1da09
5 files changed
+70 -132

No files matched your search

+1 -1
View File
@@ -790,7 +790,7 @@ mask:
# Loading Animation # Loading Animation
preloader: preloader:
enable: false enable: true
# source # source
# 1. fullpage-loading # 1. fullpage-loading
# 2. pace (progress bar) # 2. pace (progress bar)
@@ -1,42 +1,23 @@
#loading-box #loading-box(onclick='document.getElementById("loading-box").classList.add("loaded")')
.loading-left-bg .loading-bg
.loading-right-bg div.loading-img
.spinner-box .loading-image-dot
.configure-border-1
.configure-core
.configure-border-2
.configure-core
.loading-word= _p('loading')
script. script.
(()=>{ const preloader = {
const $loadingBox = document.getElementById('loading-box') endLoading: () => {
const $body = document.body document.body.style.overflow = 'auto';
const preloader = { document.getElementById('loading-box').classList.add("loaded")
endLoading: () => { },
if ($loadingBox.classList.contains('loaded')) return initLoading: () => {
$body.style.overflow = '' document.body.style.overflow = '';
$loadingBox.classList.add('loaded') document.getElementById('loading-box').classList.remove("loaded")
},
initLoading: () => {
$body.style.overflow = 'hidden'
$loadingBox.classList.remove('loaded')
}
}
preloader.initLoading()
if (document.readyState === 'complete') {
preloader.endLoading()
} else {
window.addEventListener('load', preloader.endLoading)
document.addEventListener('DOMContentLoaded', preloader.endLoading)
// Add timeout protection: force end after 7 seconds
setTimeout(preloader.endLoading, 7000)
} }
}
window.addEventListener('load',()=> { preloader.endLoading() })
if (!{theme.pjax && theme.pjax.enable}) { if (!{theme.pjax && theme.pjax.enable}) {
btf.addGlobalFn('pjaxSend', preloader.initLoading, 'preloader_init') document.addEventListener('pjax:send', () => { preloader.initLoading() })
btf.addGlobalFn('pjaxComplete', preloader.endLoading, 'preloader_end') document.addEventListener('pjax:complete', () => { preloader.endLoading() })
} }
})()
@@ -1,5 +1,7 @@
if theme.preloader.enable if theme.preloader.source === 1
if theme.preloader.source === 1 include ./fullpage-loading.pug
include ./fullpage-loading.pug else if theme.preloader.source === 2
else include ./pace.pug
include ./pace.pug else
include ./fullpage-loading.pug
include ./pace.pug
Loaded 3 of 5 files, more files were not shown because too many files have changed in this diff. Show more