32 lines
1.7 KiB
JavaScript
32 lines
1.7 KiB
JavaScript
// Deferred same-origin script: no remote dependency, inline handler or application API.
|
|
;(function () {
|
|
var boot = document.getElementById('admin-boot')
|
|
if (!boot) return
|
|
try {
|
|
// Only appearance keys are read. Vue/Pinia remains the owner after mount.
|
|
function readPreference(name) {
|
|
var record = JSON.parse(localStorage.getItem('like_admin_' + name) || 'null')
|
|
return record && (!record.expire || record.expire >= Date.now() / 1000) ? record.value : null
|
|
}
|
|
var appearance = readPreference('admin_ui') || document.documentElement.dataset.defaultAdminUi
|
|
var profile = appearance === 'v2' && readPreference('admin_ui_v2_setting')
|
|
var mode = appearance === 'v2' ? (profile && profile.colorMode) : localStorage.getItem('vueuse-color-scheme')
|
|
if (mode === 'dark' || mode === 'light') boot.dataset.mode = mode
|
|
} catch (_) { /* Browser privacy settings: CSS follows the system. */ }
|
|
|
|
// A slow network is not a failure. Keep waiting unless the user chooses to reload.
|
|
var slow = setTimeout(function () {
|
|
if (boot.dataset.state === 'loading') boot.dataset.state = 'slow'
|
|
}, 12000)
|
|
function entryFailed(event) {
|
|
// Optional SDK/style/image errors must never turn a healthy app into a failure.
|
|
var script = event.target
|
|
if (script && script.tagName === 'SCRIPT' && script.type === 'module') boot.dataset.state = 'error'
|
|
}
|
|
window.addEventListener('error', entryFailed, true)
|
|
window.addEventListener('admin:mounted', function () {
|
|
clearTimeout(slow)
|
|
window.removeEventListener('error', entryFailed, true)
|
|
}, { once: true })
|
|
})()
|