fix: 提升管理端启动与导航稳定性

- 等待初始路由就绪并提供可恢复的启动失败页面

- 收敛失效登录导航并按需加载 SVG 图标资源
This commit is contained in:
2026-07-24 19:02:28 +08:00
parent a75f7baf1b
commit da59c713f9
12 changed files with 259 additions and 13 deletions

View File

@@ -0,0 +1,27 @@
import { afterEach, describe, expect, it, vi } from 'vitest';
import { renderStartupError } from './startup-error';
describe('startup error fallback', () => {
afterEach(() => {
document.body.replaceChildren();
});
it('renders a recoverable error state and reloads on demand', () => {
const root = document.createElement('div');
const reload = vi.fn();
document.body.append(root);
expect(renderStartupError({ reload, root })).toBe(true);
expect(root.querySelector('[role="alert"]')).not.toBeNull();
expect(root.textContent).toContain('页面加载失败');
const retryButton = root.querySelector<HTMLButtonElement>('button');
retryButton?.click();
expect(reload).toHaveBeenCalledOnce();
});
it('returns false when the application root is missing', () => {
expect(renderStartupError({ root: null })).toBe(false);
});
});