Enhance settings management and localStorage integration

- Added functionality to load settings from localStorage in the SettingsManager, ensuring user preferences are retained across sessions.
- Updated the state management to initialize settings from localStorage, improving user experience.
- Refactored the UpdateService to streamline update notification preferences.
- Improved migration logic in storageHelpers to prevent duplicate migrations and ensure data integrity.
- Removed unnecessary console logs for cleaner output in various modules.
This commit is contained in:
Will Miao
2025-03-22 08:46:36 +08:00
parent 19ef73a07f
commit 372d74ec71
6 changed files with 63 additions and 23 deletions

View File

@@ -8,15 +8,11 @@ export class UpdateService {
this.latestVersion = "v0.0.0"; // Initialize with default values
this.updateInfo = null;
this.updateAvailable = false;
this.updateNotificationsEnabled = getStorageItem('show_update_notifications') !== 'false';
this.updateNotificationsEnabled = getStorageItem('show_update_notifications');
this.lastCheckTime = parseInt(getStorageItem('last_update_check') || '0');
}
initialize() {
// Initialize update preferences from localStorage
const showUpdates = getStorageItem('show_update_notifications');
this.updateNotificationsEnabled = showUpdates === null || showUpdates === 'true';
// Register event listener for update notification toggle
const updateCheckbox = document.getElementById('updateNotifications');
if (updateCheckbox) {