feat(preferences): integrate PreferenceService and enhance testing capabilities

This commit refactors the PreferenceService to use named exports for better consistency and updates the DbService import accordingly. It introduces a testing mechanism for the PreferenceService by creating test windows to facilitate cross-window preference synchronization testing. Additionally, improvements are made to the usePreference hook for better performance and stability, ensuring efficient preference management in the application.
This commit is contained in:
fullex
2025-08-12 13:44:41 +08:00
parent c02f93e6b9
commit b219e96544
15 changed files with 1412 additions and 25 deletions
+1 -2
View File
@@ -1,3 +1,4 @@
import { dbService } from '@data/db/DbService'
import { loggerService } from '@logger'
import { DefaultPreferences } from '@shared/data/preferences'
import type { PreferenceDefaultScopeType, PreferenceKeyType } from '@shared/data/types'
@@ -5,7 +6,6 @@ import { IpcChannel } from '@shared/IpcChannel'
import { and, eq } from 'drizzle-orm'
import { BrowserWindow } from 'electron'
import dbService from './db/DbService'
import { preferenceTable } from './db/schemas/preference'
const logger = loggerService.withContext('PreferenceService')
@@ -296,4 +296,3 @@ export class PreferenceService {
// Export singleton instance
export const preferenceService = PreferenceService.getInstance()
export default preferenceService