fix(admin): 前端功能与安全修复(角色勾选/月视图新建/附件预览/考勤 late 等)
由 OCR(open-codereview.ai,deepseek-v4-flash)审查驱动修复: - Roles 多组勾选、Schedules 月视图新建、useDirtyGuard 稳定引用 - JinshujuMatchModal success:false、Attendance store 订阅、EditableCell Enter、DynamicChart 空数据、渲染期 ref - AttachmentsTab 附件预览不再 window.open(防存储型 XSS)+ 请求乱序防护 - 考勤 late 计入出勤率与主状态 Reviewed-by: OCR (open-codereview.ai)
This commit is contained in:
@@ -201,11 +201,16 @@ interface ChartPreviewProps {
|
||||
* renders an ECharts option built from it.
|
||||
*/
|
||||
const ChartPreview: React.FC<ChartPreviewProps> = ({ chart }) => {
|
||||
const option = useMemo<EChartsOption>(() => (chart ? buildOption(chart) : {}), [chart]);
|
||||
// 空/无数据时先短路,避免 buildOption 在空数据集上执行
|
||||
const hasData = !!chart && !!chart.rows && chart.rows.length > 0;
|
||||
const option = useMemo<EChartsOption>(
|
||||
() => (chart && hasData ? buildOption(chart) : {}),
|
||||
[chart, hasData],
|
||||
);
|
||||
const [instance, setInstance] = useState<EChartsType | null>(null);
|
||||
if (!chart) return null;
|
||||
// 空数据集:渲染明确占位,而不是一张空白图
|
||||
if (!chart.rows || chart.rows.length === 0) {
|
||||
if (!hasData) {
|
||||
return (
|
||||
<div className="ai-chat-chart-card">
|
||||
<div className="ai-chat-chart-card__header">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useCallback, useRef, useState } from 'react';
|
||||
import { useLayoutEffect } from 'react';
|
||||
import type { XAgentCommand_v0_9 } from '@ant-design/x-card';
|
||||
|
||||
/**
|
||||
@@ -75,11 +76,14 @@ export function useXCardSurface(surfaceId: string) {
|
||||
);
|
||||
|
||||
const surfaceKey = surfaceId;
|
||||
if (idRef.current !== surfaceKey) {
|
||||
// 组件复用到新 surface 时,清空历史命令重新初始化
|
||||
commandsRef.current = [];
|
||||
idRef.current = surfaceKey;
|
||||
}
|
||||
// 渲染期保持纯函数:ref 变更放到 layout effect 里
|
||||
useLayoutEffect(() => {
|
||||
if (idRef.current !== surfaceKey) {
|
||||
// 组件复用到新 surface 时,清空历史命令重新初始化
|
||||
commandsRef.current = [];
|
||||
idRef.current = surfaceKey;
|
||||
}
|
||||
}, [surfaceKey]);
|
||||
|
||||
return { commands, pushCommands };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user