F1-2: 迁移 claude-design 原型壳层到 eip4-web
新增 src/shell/(AppShell/Topbar/SideMenu/TabBar/GlobalSearch/SettingsDrawer/theme.css) 和 src/components/ui/(Icon/Dialog/Drawer/Toast/Pagination), src/api/menu.ts 含 GET /api/menu + 404 降级; App.tsx 路由改为 AppShell <Outlet> 包裹,登录/待办/amis 渲染三页功能保持不变。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
49
src/api/menu.ts
Normal file
49
src/api/menu.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
// src/api/menu.ts — 菜单树 API
|
||||
// GET /api/menu 返回三级树,后端可能晚于前端就绪,404/失败时优雅降级。
|
||||
import { http } from './http';
|
||||
|
||||
// 后端契约(已定死)
|
||||
export interface MenuItem {
|
||||
id: string;
|
||||
name: string;
|
||||
seq: number;
|
||||
templateId?: string | null;
|
||||
children?: MenuItem[];
|
||||
}
|
||||
|
||||
export interface MenuRoot {
|
||||
id: string;
|
||||
name: string;
|
||||
seq: number;
|
||||
children?: MenuItem[];
|
||||
}
|
||||
|
||||
export interface MenuResponse {
|
||||
roots: MenuRoot[];
|
||||
}
|
||||
|
||||
// 收集所有叶子节点(templateId 非空),携带面包屑路径
|
||||
export interface MenuLeaf {
|
||||
id: string;
|
||||
name: string;
|
||||
templateId: string;
|
||||
path: string; // 面包屑:父节点名 / ... / 叶子名
|
||||
}
|
||||
|
||||
export function collectLeaves(items: MenuItem[], breadcrumb: string[] = []): MenuLeaf[] {
|
||||
let out: MenuLeaf[] = [];
|
||||
for (const m of items) {
|
||||
if (m.templateId) {
|
||||
out.push({ id: m.id, name: m.name, templateId: m.templateId, path: [...breadcrumb, m.name].join(' / ') });
|
||||
}
|
||||
if (m.children?.length) {
|
||||
out = out.concat(collectLeaves(m.children, [...breadcrumb, m.name]));
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
export async function fetchMenu(): Promise<MenuResponse> {
|
||||
const resp = await http.get<MenuResponse>('/api/menu');
|
||||
return resp.data;
|
||||
}
|
||||
Reference in New Issue
Block a user