41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
|
|
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()
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
// 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') {
|
||
|
|
const doRefresh = () => {
|
||
|
|
console.log('Base project triggering RefreshState');
|
||
|
|
RefreshState(document.documentElement);
|
||
|
|
}
|
||
|
|
if (document.readyState !== 'loading') doRefresh()
|
||
|
|
else document.addEventListener('DOMContentLoaded', doRefresh, true)
|
||
|
|
}
|