移除条件渲染和 CSS animation 的冲突,改用纯 CSS transition 控制显示/隐藏。 **问题根源:** - 组件使用 `if (!open) return null;` 条件渲染,导致挂载时立即出现 - CSS 同时使用 `animation: slideInLeft`,触发从 -100% 的二次滑入 - 两个独立显示机制叠加,造成双重动画闪烁 **修复方案:** - SessionSidebar: 移除条件渲染,始终保持 DOM 存在,通过动态 className 控制状态 - App.css: 移除 `animation` 和 `@keyframes`,改用 `transition: transform` - 新增 `.sidebar--collapsed` / `.sidebar--open` 类控制 `translateX` - 新增 `.sidebar-backdrop--visible` 类控制背景遮罩淡入淡出 - 添加 `pointer-events: none` 确保隐藏状态不响应交互 影响范围: - frontend/src/components/SessionSidebar/index.tsx - frontend/src/App.css
React + TypeScript + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Oxc
- @vitejs/plugin-react-swc uses SWC
React Compiler
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see this documentation.
Expanding the ESLint configuration
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,
// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
You can also install eslint-plugin-react-x and eslint-plugin-react-dom for React-specific lint rules:
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])