F1-3: 工作台首页与待办中心成品化
- 新增 WorkbenchPage (/workbench):KPI 卡片(待办数接真实 API)、待办快照(最近 5 条)、常用功能(localStorage 最近访问优先,回退菜单叶子) - 升级 TodoPage:待办/已办 Tab、关键字本地筛选、pageUrl 优先跳转、Pagination 组件复用 - 新增 api/done.ts:GET /api/done 已办接口,与待办接口同样的 503 降级逻辑 - 新增 utils/recentPages.ts:localStorage 常用功能工具,MAX_RECENT=8 LRU - 新增 utils/recentPages.test.ts:5 个单测覆盖写入/提升/截断/清空逻辑 - AppShell:顶栏铃铛接真实待办数(60s 轮询);默认 Tab 改为工作台 - App.tsx:新增 /workbench 路由,根路径重定向目标改为 /workbench Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
44
src/api/done.ts
Normal file
44
src/api/done.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
// 已办聚合 API —— GET /api/done
|
||||
// 与待办接口同网关,引擎不可达时同样返回 503;前端据此降级。
|
||||
import { http } from './http';
|
||||
|
||||
export interface DoneItem {
|
||||
taskId?: string;
|
||||
taskName?: string;
|
||||
assignee?: string;
|
||||
businessKey?: string;
|
||||
businessTable?: string | null;
|
||||
businessSummary?: Record<string, unknown>;
|
||||
/** 办理结果:agree / reject / transfer 等后端枚举,显示时做映射 */
|
||||
result?: string;
|
||||
/** 办理时间 */
|
||||
endTime?: string;
|
||||
processInstanceId?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface DoneResult {
|
||||
items: DoneItem[];
|
||||
unavailable: boolean;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export async function fetchDone(firstResult = 0, maxResults = 20): Promise<DoneResult> {
|
||||
try {
|
||||
const { data } = await http.get<DoneItem[] | { items: DoneItem[] }>('/api/done', {
|
||||
params: { firstResult, maxResults },
|
||||
});
|
||||
const items = Array.isArray(data) ? data : (data?.items ?? []);
|
||||
return { items, unavailable: false };
|
||||
} catch (err) {
|
||||
const e = err as { response?: { status?: number; data?: { message?: string } } };
|
||||
if (e.response?.status === 503) {
|
||||
return {
|
||||
items: [],
|
||||
unavailable: true,
|
||||
message: e.response.data?.message || '工作流引擎服务暂不可达,请稍后重试',
|
||||
};
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user