feat(performance): implement comprehensive performance improvements for Worklenz frontend

- Introduced a new document summarizing performance optimizations across the application.
- Applied React.memo(), useMemo(), and useCallback() to key components to minimize unnecessary re-renders and optimize rendering performance.
- Implemented a route preloading system to enhance navigation speed and user experience.
- Added performance monitoring utilities for development to track component render times and function execution.
- Enhanced lazy loading and suspense boundaries for better loading states.
- Conducted production optimizations, including TypeScript error fixes and memory management improvements.
- Memoized style and configuration objects to reduce garbage collection pressure and improve memory usage.
This commit is contained in:
chamiakJ
2025-06-21 18:16:13 +05:30
parent 5221061241
commit bb57280c8c
7 changed files with 610 additions and 133 deletions

View File

@@ -1,46 +1,50 @@
import React, { memo } from 'react';
import { colors } from '@/styles/colors';
import { getInitialTheme } from '@/utils/get-initial-theme';
import { ConfigProvider, theme, Layout, Spin } from 'antd';
// Loading component with theme awareness
export const SuspenseFallback = () => {
// Memoized loading component with theme awareness
export const SuspenseFallback = memo(() => {
const currentTheme = getInitialTheme();
const isDark = currentTheme === 'dark';
// Memoize theme configuration to prevent unnecessary re-renders
const themeConfig = React.useMemo(() => ({
algorithm: isDark ? theme.darkAlgorithm : theme.defaultAlgorithm,
components: {
Layout: {
colorBgLayout: isDark ? colors.darkGray : '#fafafa',
},
Spin: {
colorPrimary: isDark ? '#fff' : '#1890ff',
},
},
}), [isDark]);
// Memoize layout style to prevent object recreation
const layoutStyle = React.useMemo(() => ({
position: 'fixed' as const,
width: '100vw',
height: '100vh',
background: 'transparent',
transition: 'none',
}), []);
// Memoize spin style to prevent object recreation
const spinStyle = React.useMemo(() => ({
position: 'absolute' as const,
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
}), []);
return (
<ConfigProvider
theme={{
algorithm: isDark ? theme.darkAlgorithm : theme.defaultAlgorithm,
components: {
Layout: {
colorBgLayout: isDark ? colors.darkGray : '#fafafa',
},
Spin: {
colorPrimary: isDark ? '#fff' : '#1890ff',
},
},
}}
>
<Layout
className="app-loading-container"
style={{
position: 'fixed',
width: '100vw',
height: '100vh',
background: 'transparent',
transition: 'none',
}}
>
<Spin
size="large"
style={{
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
}}
/>
<ConfigProvider theme={themeConfig}>
<Layout className="app-loading-container" style={layoutStyle}>
<Spin size="large" style={spinStyle} />
</Layout>
</ConfigProvider>
);
};
});
SuspenseFallback.displayName = 'SuspenseFallback';