2026-05-14 20:04:31 +08:00
|
|
|
import { NewState } from '@web/state'
|
|
|
|
|
|
|
|
|
|
// Re-exports
|
|
|
|
|
export * from './http.js'
|
|
|
|
|
export * from './ui.js'
|
|
|
|
|
export * from './form.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()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-18 20:23:05 +08:00
|
|
|
const htmlNode = document.documentElement;
|
|
|
|
|
if (!htmlNode.hasAttribute('$data-bs-theme') && !htmlNode.hasAttribute('data-bs-theme')) {
|
|
|
|
|
htmlNode.setAttribute('$data-bs-theme', "LocalStorage.darkMode?'dark':'light'");
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-14 20:04:31 +08:00
|
|
|
// 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 '@web/state'
|
|
|
|
|
if (typeof document !== 'undefined') {
|
2026-05-18 20:23:05 +08:00
|
|
|
const doRefresh = () => RefreshState(document.documentElement)
|
|
|
|
|
if (document.readyState !== 'loading') doRefresh()
|
|
|
|
|
else document.addEventListener('DOMContentLoaded', doRefresh, true)
|
2026-05-14 20:04:31 +08:00
|
|
|
}
|
2026-05-18 20:23:05 +08:00
|
|
|
|