fix(web,plugin): 前端审计修复 — 401 消除 + 统计卡片 crash + 销售漏斗 500 + antd 6 废弃 API

- API client: proactive token refresh(请求前 30s 检查过期,提前刷新避免 401)
- Plugin store: fetchPlugins promise 去重,防止 StrictMode 并发重复请求
- Home stats: 简化 useEffect 加载逻辑,修复 tagColor undefined crash
- PluginGraphPage: valueStyle → styles.content, Spin tip → description(antd 6)
- DashboardWidgets: trailColor → railColor(antd 6)
- data_service: build_scope_sql 参数索引修复(硬编码 $100 → 动态 values.len()+1)
- erp-core error: Internal 错误添加 tracing::error 日志输出
This commit is contained in:
iven
2026-04-18 20:31:49 +08:00
parent 790991f77c
commit 5ba11f985f
12 changed files with 308 additions and 100 deletions

View File

@@ -9,26 +9,45 @@ import type { GraphEdge } from './graphTypes';
// ── 常量 ──
/** 关系类型对应的色板 (base / light / glow) */
export const RELATIONSHIP_COLORS: Record<string, { base: string; light: string; glow: string }> = {
parent_child: { base: '#4F46E5', light: '#818CF8', glow: 'rgba(79,70,229,0.3)' },
sibling: { base: '#059669', light: '#34D399', glow: 'rgba(5,150,105,0.3)' },
partner: { base: '#D97706', light: '#FBBF24', glow: 'rgba(217,119,6,0.3)' },
supplier: { base: '#0891B2', light: '#22D3EE', glow: 'rgba(8,145,178,0.3)' },
competitor: { base: '#DC2626', light: '#F87171', glow: 'rgba(220,38,38,0.3)' },
};
/** 关系类型对应的色板 (base / light / glow) — 通用调色板自动分配 */
const EDGE_PALETTE: Array<{ base: string; light: string; glow: string }> = [
{ base: '#4F46E5', light: '#818CF8', glow: 'rgba(79,70,229,0.3)' },
{ base: '#059669', light: '#34D399', glow: 'rgba(5,150,105,0.3)' },
{ base: '#D97706', light: '#FBBF24', glow: 'rgba(217,119,6,0.3)' },
{ base: '#0891B2', light: '#22D3EE', glow: 'rgba(8,145,178,0.3)' },
{ base: '#DC2626', light: '#F87171', glow: 'rgba(220,38,38,0.3)' },
{ base: '#7C3AED', light: '#A78BFA', glow: 'rgba(124,58,237,0.3)' },
{ base: '#EA580C', light: '#FB923C', glow: 'rgba(234,88,12,0.3)' },
{ base: '#DB2777', light: '#F472B6', glow: 'rgba(219,39,119,0.3)' },
];
/** 未匹配到已知关系类型时的默认色 */
export const DEFAULT_REL_COLOR = { base: '#7C3AED', light: '#A78BFA', glow: 'rgba(124,58,237,0.3)' };
/** 关系类型 → 中文标签 */
export const REL_LABEL_MAP: Record<string, string> = {
parent_child: '母子',
sibling: '兄弟',
partner: '伙伴',
supplier: '供应商',
competitor: '竞争',
};
const edgeColorCache = new Map<string, { base: string; light: string; glow: string }>();
export function getEdgeColorGlobal(label: string) {
const cached = edgeColorCache.get(label);
if (cached) return cached;
const color = EDGE_PALETTE[edgeColorCache.size % EDGE_PALETTE.length];
edgeColorCache.set(label, color);
return color;
}
/** @deprecated 使用 getEdgeColorGlobal */
export const RELATIONSHIP_COLORS = new Proxy({} as Record<string, { base: string; light: string; glow: string }>, {
get(_, prop: string) { return getEdgeColorGlobal(prop); },
});
/** @deprecated 标签直接使用原始值 */
export const REL_LABEL_MAP = new Proxy({} as Record<string, string>, {
get(_, prop: string) { return prop; },
});
/** 通用边颜色函数 — 兼容旧路径导入 */
export function getEdgeColor(label: string) {
return getEdgeColorGlobal(label);
}
/** 普通节点基础半径 */
export const NODE_BASE_RADIUS = 18;