修复其他tab下修改应用没触发问题

This commit is contained in:
北枳 2025-08-14 20:57:37 +08:00
parent e60ec8b61a
commit 2bd27ef7f6
2 changed files with 12 additions and 5 deletions

View File

@ -117,9 +117,6 @@ const [pendingSwitchTabId, setPendingSwitchTabId] = useState<string | null>(null
// 切换前 检查是否更新 // 切换前 检查是否更新
const isUpdate = checkUpdate(tabId); const isUpdate = checkUpdate(tabId);
if (isUpdate) { if (isUpdate) {
// setPendingSwitchTabId(tabId); // 记录要切换到的目标tab
// setRemindFallbackText('You must click Apply button to save the current changes.');
// setIsRemindFallbackOpen(true);
return; return;
} }
setActiveTab(tabId); setActiveTab(tabId);
@ -129,8 +126,12 @@ const [pendingSwitchTabId, setPendingSwitchTabId] = useState<string | null>(null
const handleSave = () => { const handleSave = () => {
console.log('handleSave'); console.log('handleSave');
// setIsRemindFallbackOpen(true); // setIsRemindFallbackOpen(true);
if (activeTab === '1') { if (activeTab === '0') {
scriptTabContentRef.current.saveBefore();
} else if (activeTab === '1') {
characterTabContentRef.current.saveBefore(); characterTabContentRef.current.saveBefore();
} else if (activeTab === '3') {
handleConfirmGotoFallback();
} }
} }

View File

@ -15,7 +15,7 @@ interface ScriptTabContentProps {
} }
export const ScriptTabContent = forwardRef< export const ScriptTabContent = forwardRef<
{ switchBefore: (tabId: string) => boolean }, { switchBefore: (tabId: string) => boolean, saveBefore: () => void },
ScriptTabContentProps ScriptTabContentProps
>((props, ref) => { >((props, ref) => {
const { setIsPauseWorkFlow, isPauseWorkFlow, originalText, onApply, setActiveTab } = props; const { setIsPauseWorkFlow, isPauseWorkFlow, originalText, onApply, setActiveTab } = props;
@ -39,6 +39,12 @@ export const ScriptTabContent = forwardRef<
} }
return isUpdate; return isUpdate;
}, },
saveBefore: () => {
console.log('saveBefore');
if (isUpdate) {
onApply();
}
}
})); }));
const handleApply = () => { const handleApply = () => {