45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
import { NewState } from '@apigo.cc/state'
|
|
|
|
// Re-exports
|
|
export * from './http.js'
|
|
export * from './ui.js'
|
|
export * from './form.js'
|
|
export * from './controls.js'
|
|
export * from './list.js'
|
|
export * from './nav.js'
|
|
export * from './interaction.js'
|
|
|
|
// 页面退出状态
|
|
export const State = NewState({ exitBlocks: 0 })
|
|
globalThis.State = State
|
|
|
|
if (typeof window !== 'undefined') {
|
|
window.addEventListener('beforeunload', (event) => {
|
|
if (State.exitBlocks > 0) event.preventDefault()
|
|
})
|
|
}
|
|
|
|
const htmlNode = document.documentElement;
|
|
if (!htmlNode.hasAttribute('$data-bs-theme') && !htmlNode.hasAttribute('data-bs-theme')) {
|
|
htmlNode.setAttribute('$data-bs-theme', "LocalStorage.darkMode?'dark':'light'");
|
|
}
|
|
|
|
// Side effects: ensure global namespaces are populated
|
|
import { HTTP } from './http.js'
|
|
import { UI } from './ui.js'
|
|
import { AutoForm } from './form.js'
|
|
import { MouseMover } from './interaction.js'
|
|
|
|
globalThis.HTTP = HTTP
|
|
globalThis.UI = UI
|
|
globalThis.AutoForm = AutoForm
|
|
globalThis.MouseMover = MouseMover
|
|
|
|
import { RefreshState } from '@apigo.cc/state'
|
|
if (typeof document !== 'undefined') {
|
|
const doRefresh = () => RefreshState(document.documentElement)
|
|
if (document.readyState !== 'loading') setTimeout(doRefresh, 1)
|
|
else document.addEventListener('DOMContentLoaded', () => setTimeout(doRefresh, 1), true)
|
|
}
|
|
|