提取UI工作流通知文案工具
拆分通知类型与文案辅助函数 修复组件快速刷新导出约束
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { ThemedModal } from '../../../components/modal/ThemedModal';
|
||||
import type { WorkflowCompletionNotice } from './workflowCompletionNotice';
|
||||
import { workflowStepLabel } from './workflowCompletionNotice';
|
||||
|
||||
export function WorkflowCompletionModal({
|
||||
notice,
|
||||
onClose,
|
||||
}: {
|
||||
notice: WorkflowCompletionNotice | null;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
if (!notice) return null;
|
||||
const stepLabel = workflowStepLabel(notice.step);
|
||||
const outcomeLabel = notice.outcome === 'success' ? '完成' : '失败';
|
||||
return (
|
||||
<ThemedModal
|
||||
open
|
||||
onClose={onClose}
|
||||
ariaLabel={`${stepLabel}${outcomeLabel}`}
|
||||
panelClassName="w-[min(440px,calc(100vw-2rem))] rounded-2xl p-5"
|
||||
>
|
||||
<h2 className="m-0 text-base font-semibold">
|
||||
{stepLabel}
|
||||
{outcomeLabel}
|
||||
</h2>
|
||||
<p className="mt-3 text-sm leading-6 text-(--platform-text-soft)">
|
||||
{notice.message}
|
||||
</p>
|
||||
<div className="mt-5 flex justify-end">
|
||||
<button
|
||||
type="button"
|
||||
className="rounded-lg border border-(--platform-subpanel-border) px-3 py-2 text-xs"
|
||||
onClick={onClose}
|
||||
>
|
||||
关闭
|
||||
</button>
|
||||
</div>
|
||||
</ThemedModal>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import type { UiEditorStepId } from '../model';
|
||||
|
||||
export type WorkflowCompletionNotice = {
|
||||
step: UiEditorStepId;
|
||||
outcome: 'success' | 'failure';
|
||||
message: string;
|
||||
};
|
||||
|
||||
export function appendWorkflowCheckPrompt(message: string): string {
|
||||
const trimmed = message.trim();
|
||||
if (!trimmed) return '请检查。';
|
||||
if (trimmed.includes('请检查')) return trimmed;
|
||||
return `${trimmed.replace(/[。!?!?]+$/u, '')},请检查。`;
|
||||
}
|
||||
|
||||
export function workflowStepLabel(step: UiEditorStepId): string {
|
||||
if (step === 'reference-analysis') return '分析参考图';
|
||||
if (step === 'structure-recognition') return '识别界面结构';
|
||||
return '绑定视觉素材';
|
||||
}
|
||||
Reference in New Issue
Block a user