This commit implements a major architectural refactor to improve modularity, type safety, and maintainability across the codebase.
Key changes include:
- **Responsive System Refactor**: Migrated from a monolithic `useResponsive` hook to a set of specialized, granular hooks (`useBreakpoint`, `useOrientation`, `usePlatform`, etc.) located in `src/presentation/hooks/responsive`. This reduces unnecessary re-renders and improves developer experience.
- **Core Service Restructuring**: Introduced a new directory structure for services, including dedicated folders for `datasources`, `mappers`, and domain-specific types (`message`, `post`).
- **Data Layer Improvements**:
- Centralized JSON parsing logic in `src/database/core/jsonUtils.ts`.
- Cleaned up repository implementations by removing redundant local utility functions.
- Refactored `MessageMapper` to use the new centralized JSON utility.
- **Type System Cleanup**:
- Decomposed the large `src/types/dto.ts` into a modular `src/types/dto/` directory.
- Simplified `src/types/index.ts` and introduced backward-compatible aliases for core entities.
- **Utility Consolidation**:
- Created a centralized `src/utils/formatTime.ts` to replace fragmented date formatting logic across various screens and components.
- Removed deprecated responsive utility files in favor of the new hook-based system.
- **Service Logic Refinement**: Refactored `ApiClient` and `WebSocketService` to use a centralized `showVerificationModal` service, removing duplicated state management for verification prompts.
100 lines
2.3 KiB
TypeScript
100 lines
2.3 KiB
TypeScript
/**
|
|
* Hooks 导出
|
|
*/
|
|
|
|
// ==================== 响应式 Hooks ====================
|
|
export {
|
|
useBreakpoint,
|
|
useBreakpointGTE,
|
|
useScreenSize,
|
|
useWindowDimensions,
|
|
useOrientation,
|
|
usePlatform,
|
|
useResponsiveValue,
|
|
useColumnCount,
|
|
useResponsiveSpacing,
|
|
useResponsive,
|
|
getBreakpoint,
|
|
getFineBreakpoint,
|
|
isBreakpointGTE,
|
|
isBreakpointLT,
|
|
isBreakpointBetween,
|
|
BREAKPOINTS,
|
|
FINE_BREAKPOINTS,
|
|
} from '../presentation/hooks/responsive';
|
|
|
|
export type {
|
|
BreakpointKey,
|
|
FineBreakpointKey,
|
|
BreakpointValue,
|
|
ResponsiveValue,
|
|
Orientation,
|
|
PlatformInfo,
|
|
ScreenSize,
|
|
MediaQueryOptions,
|
|
ResponsiveInfo,
|
|
} from '../presentation/hooks/responsive';
|
|
|
|
// ==================== 其他 Hooks ====================
|
|
export {
|
|
usePrefetch,
|
|
prefetchPosts,
|
|
prefetchConversations,
|
|
prefetchUserInfo,
|
|
prefetchOnAppLaunch,
|
|
prefetchMessageScreen,
|
|
prefetchHomeScreen,
|
|
} from './usePrefetch';
|
|
|
|
// ==================== 分页 Hooks ====================
|
|
export {
|
|
usePagination,
|
|
usePaginationManager,
|
|
} from './usePagination';
|
|
|
|
export type {
|
|
UsePaginationOptions,
|
|
UsePaginationReturn,
|
|
} from './usePagination';
|
|
|
|
// ==================== 游标分页 Hooks ====================
|
|
export { useCursorPagination } from './useCursorPagination';
|
|
|
|
// ==================== 连接状态 Hooks ====================
|
|
export { useConnectionState } from './useConnectionState';
|
|
|
|
export type { UseConnectionStateResult } from './useConnectionState';
|
|
|
|
// ==================== 媒体缓存 Hooks ====================
|
|
export { useMediaCache } from './useMediaCache';
|
|
|
|
export type { UseMediaCacheReturn } from './useMediaCache';
|
|
|
|
// ==================== 差异更新 Hooks ====================
|
|
export { useDifferentialMessages } from './useDifferentialMessages';
|
|
|
|
export type {
|
|
UseDifferentialMessagesOptions,
|
|
UseDifferentialMessagesResult,
|
|
} from './useDifferentialMessages';
|
|
|
|
export { useDifferentialPosts } from './useDifferentialPosts';
|
|
|
|
export type {
|
|
UseDifferentialPostsOptions,
|
|
UseDifferentialPostsResult,
|
|
DiffUpdatesInfo,
|
|
} from './useDifferentialPosts';
|
|
|
|
// ==================== 平台键盘 Hooks ====================
|
|
export {
|
|
usePlatformKeyboard,
|
|
useKeyboardAvoidingProps,
|
|
useKeyboardListener,
|
|
} from './usePlatformKeyboard';
|
|
|
|
export type {
|
|
KeyboardEventType,
|
|
PlatformKeyboardOptions,
|
|
PlatformKeyboardResult,
|
|
} from './usePlatformKeyboard'; |