fix(console): 修复看板与作品详情加载并限制只读请求等待

This commit is contained in:
zhanjunhao
2026-11-25 11:30:40 +08:00
parent a532b860c8
commit f896495048
6 changed files with 57 additions and 26 deletions
@@ -9,6 +9,7 @@ import { useNavigate } from 'react-router-dom';
import { ERROR_ACTIONS } from '../../../helpers/creationError';
import { copy, renderQuota, showSuccess } from '../../../helpers';
import { useIsMobile } from '../../../hooks/common/useIsMobile';
import { useEffectEvent } from '../../../hooks/common/useEffectEvent';
import { adapterOf } from '../../../hooks/creation/creationForm';
import {
elapsedSeconds,
@@ -101,24 +102,18 @@ const WorkDetailDrawer = ({
}, [taskId]);
// 打开时拉取一次详情(快照 / 播放地址 / regenerate_supported)
const fetchedRef = useRef('');
const loadDetail = useEffectEvent(() => fetchDetail(task));
useEffect(() => {
if (!visible || !task || fetchedRef.current === task.id) return;
fetchedRef.current = task.id;
if (!visible || !taskId) return;
let alive = true;
setLoadingDetail(true);
fetchDetail(task).finally(() => {
loadDetail().finally(() => {
if (alive) setLoadingDetail(false);
});
return () => {
alive = false;
};
// 只按作品 id 触发
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [visible, taskId]);
useEffect(() => {
if (!visible) fetchedRef.current = '';
}, [visible]);
}, [visible, taskId, loadDetail]);
if (!task) return null;