feat(admin): AI 预检卡片交互与消息组件完善
- 预检卡支持列映射、导入策略确认与生成导入向导 - 消息组件/API 契约配套更新,含集成测试
This commit is contained in:
@@ -6,7 +6,7 @@ import { App } from 'antd';
|
||||
import type { UploadFile, UploadProps } from 'antd';
|
||||
import { message } from '../../ui/app-message';
|
||||
import { useSettingsStore } from '../../store/settings/settingsStore';
|
||||
import { aiChatApi } from './api';
|
||||
import { aiChatApi, resolveImportPreflight, type ResolveImportPreflightInput } from './api';
|
||||
import { AiMessageContent } from './AiMessageContent';
|
||||
import { mapHistoryMessage } from './message-mappers';
|
||||
import { GongxueAiChatProvider } from './provider';
|
||||
@@ -24,6 +24,7 @@ import type {
|
||||
AiChatMessage,
|
||||
AiChatMessageStatus,
|
||||
AiFormSchema,
|
||||
AiImportPreflight,
|
||||
AiReviewSchema,
|
||||
AiReviewSection,
|
||||
AiReviewSectionType,
|
||||
@@ -409,6 +410,31 @@ export function useAiChatMessageActions({
|
||||
[provider, setMessage],
|
||||
);
|
||||
|
||||
const resolvePreflight = useCallback(
|
||||
async (
|
||||
messageId: number | undefined,
|
||||
_preflight: AiImportPreflight,
|
||||
input: ResolveImportPreflightInput,
|
||||
): Promise<void> => {
|
||||
if (typeof messageId !== 'number') {
|
||||
throw new Error('消息尚未完成生成,请稍后再试');
|
||||
}
|
||||
await resolveImportPreflight(messageId, input, (update) => {
|
||||
setMessage(messageId, (info) => ({
|
||||
message: {
|
||||
...info.message,
|
||||
metadata: {
|
||||
...info.message.metadata,
|
||||
...(update.preflight ? { a2uiImportPreflight: update.preflight } : {}),
|
||||
...(update.wizard ? { a2uiImportWizard: update.wizard } : {}),
|
||||
},
|
||||
},
|
||||
}));
|
||||
});
|
||||
},
|
||||
[setMessage],
|
||||
);
|
||||
|
||||
const customUpload = useCallback<NonNullable<UploadProps['customRequest']>>(async (options) => {
|
||||
const file = options.file as File;
|
||||
if (attachmentsRef.current.length >= 5) {
|
||||
@@ -524,6 +550,7 @@ export function useAiChatMessageActions({
|
||||
onConfirmReviewStep={confirmReviewStep}
|
||||
onConfirmReviewGroup={confirmReviewGroup}
|
||||
onOpenImportWizard={setImportWizardRunId}
|
||||
onResolveImportPreflight={resolvePreflight}
|
||||
/>
|
||||
),
|
||||
})),
|
||||
@@ -537,6 +564,7 @@ export function useAiChatMessageActions({
|
||||
isRequesting,
|
||||
messages,
|
||||
reloadMessage,
|
||||
resolvePreflight,
|
||||
setImportWizardRunId,
|
||||
submitForm,
|
||||
submitReview,
|
||||
|
||||
Reference in New Issue
Block a user