Refactor state management to support hierarchical structure and page-specific states

- Introduced a new hierarchical state structure to manage global and page-specific states, enhancing organization and maintainability.
- Updated various managers and components to utilize the new state structure, ensuring consistent access to page-specific data.
- Removed the initSettings function and replaced it with initPageState for better initialization of page-specific states.
- Adjusted imports across multiple files to accommodate the new state management approach, improving code clarity.
This commit is contained in:
Will Miao
2025-03-19 21:12:04 +08:00
parent d7a253cba3
commit 90f74018ae
9 changed files with 240 additions and 121 deletions

View File

@@ -1,5 +1,5 @@
// Core application functionality
import { state, initSettings } from './state/index.js';
import { state } from './state/index.js';
import { LoadingManager } from './managers/LoadingManager.js';
import { modalManager } from './managers/ModalManager.js';
import { updateService } from './managers/UpdateService.js';
@@ -18,9 +18,6 @@ export class AppCore {
async initialize() {
if (this.initialized) return;
// Initialize settings
initSettings();
// Initialize managers
state.loadingManager = new LoadingManager();
modalManager.initialize();
@@ -80,4 +77,4 @@ export class AppCore {
export const appCore = new AppCore();
// Export common utilities for global use
export { showToast, modalManager, state, lazyLoadImages, initializeInfiniteScroll };
export { showToast, lazyLoadImages, initializeInfiniteScroll };