1
0

style: 修复前端 UI 细节问题

- 供应商/模型/统计表格增加列宽约束和 ellipsis 省略号
- 修复主题切换按钮在暗色侧边栏中不可见
- 表格添加 scroll 属性防止窄屏溢出
- 自定义表格空状态提示文案
This commit is contained in:
2026-04-16 22:59:26 +08:00
parent 870004af23
commit c5b3d9dfc7
10 changed files with 106 additions and 12 deletions

View File

@@ -3,8 +3,11 @@ import { describe, it, expect, vi } from 'vitest';
import { BrowserRouter } from 'react-router';
import { AppLayout } from '@/components/AppLayout';
const mockToggleTheme = vi.fn();
const mockSetTheme = vi.fn();
vi.mock('@/contexts/ThemeContext', () => ({
useTheme: vi.fn(() => ({ mode: 'light', toggleTheme: vi.fn() })),
useTheme: vi.fn(() => ({ mode: 'light', toggleTheme: mockToggleTheme, setTheme: mockSetTheme })),
}));
const renderWithRouter = (component: React.ReactNode) => {
@@ -26,11 +29,27 @@ describe('AppLayout', () => {
expect(screen.getByText('用量统计')).toBeInTheDocument();
});
it('renders theme toggle button', () => {
it('renders theme toggle button with visible color in sidebar', () => {
renderWithRouter(<AppLayout />);
const themeButton = screen.getByRole('button', { name: 'moon' });
expect(themeButton).toBeInTheDocument();
expect(themeButton.style.color).toBe('rgba(255, 255, 255, 0.85)');
});
it('renders theme toggle button visible in dark mode', async () => {
const { useTheme } = await import('@/contexts/ThemeContext');
vi.mocked(useTheme).mockReturnValue({
mode: 'dark',
toggleTheme: mockToggleTheme,
setTheme: mockSetTheme,
});
renderWithRouter(<AppLayout />);
const themeButton = screen.getByRole('button', { name: 'sun' });
expect(themeButton).toBeInTheDocument();
expect(themeButton.style.color).toBe('rgba(255, 255, 255, 0.85)');
});
it('renders content outlet', () => {