feat(file-check): 增加文件检核 Excel 下载链接解析与展示功能
This commit is contained in:
1 parent
5e7e5a8717
commit
f21216f81e
21 files changed
+885
-125
No files matched your search
@@ -6,10 +6,16 @@
|
||||
*/
|
||||
import { computed } from 'vue';
|
||||
import { marked } from 'marked';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type { ChatMessageBubbleHandlers } from '../components/messages/ChatMessageBubble.vue';
|
||||
import type { ChatMessage, InlineDownloadFile, SourceFileLink } from '../types/chat.types';
|
||||
import type { ShippingMatchResultPayload } from '../types/shipping.types';
|
||||
import type { Ref } from 'vue';
|
||||
import {
|
||||
downloadFileCheckExcelByRunId,
|
||||
parseFileCheckExcelRunId,
|
||||
rewriteFileCheckExcelLinksForDisplay,
|
||||
} from '../utils/fileCheckExcelDownload';
|
||||
|
||||
marked.setOptions({ gfm: true, breaks: true });
|
||||
|
||||
@@ -330,6 +336,8 @@ function enhanceAssetHistoryTableLinks(html: string): string {
|
||||
}
|
||||
|
||||
export function createChatPageMarkdownApi(ctx: ChatPageMarkdownContext) {
|
||||
const message = useMessage();
|
||||
|
||||
const shouldRenderMessage = (msgItem: ChatMessage): boolean => {
|
||||
if (msgItem?.role === 'user') return true;
|
||||
if (msgItem?.type === 'shipping-parse-review') return false;
|
||||
@@ -416,6 +424,15 @@ export function createChatPageMarkdownApi(ctx: ChatPageMarkdownContext) {
|
||||
void ctx.openPreview(preview);
|
||||
return;
|
||||
}
|
||||
const fileCheckRunId = parseFileCheckExcelRunId(rawHref);
|
||||
if (fileCheckRunId) {
|
||||
event.preventDefault();
|
||||
void downloadFileCheckExcelByRunId(fileCheckRunId).catch((error: unknown) => {
|
||||
const text = error instanceof Error ? error.message : '下载 Excel 失败';
|
||||
message.error(text);
|
||||
});
|
||||
return;
|
||||
}
|
||||
ctx.handleLeaveMarkdownClick(event);
|
||||
};
|
||||
|
||||
@@ -428,7 +445,9 @@ export function createChatPageMarkdownApi(ctx: ChatPageMarkdownContext) {
|
||||
const renderMarkdown = (text: string) => {
|
||||
if (!text) return '';
|
||||
const extracted = safeExtractInlineDownloadFiles(text);
|
||||
const displayText = ctx.prepareMarkdownDisplayText(extracted.cleanedText);
|
||||
const displayText = rewriteFileCheckExcelLinksForDisplay(
|
||||
ctx.prepareMarkdownDisplayText(extracted.cleanedText),
|
||||
);
|
||||
try {
|
||||
const rendered = marked.parse(displayText);
|
||||
const html = typeof rendered === 'string' ? rendered : displayText;
|
||||
|
||||
Reference in new issue
Block a user