fix: 1.接入ai_suggestion.

2. 接入合同起草功能。
This commit is contained in:
2025-12-05 00:04:45 +08:00
parent eca98fc540
commit 33f10896a0
29 changed files with 3184 additions and 981 deletions
@@ -13,7 +13,7 @@
*/
import React, { useState, useRef, useEffect } from "react";
import { DiffEditor } from "@monaco-editor/react";
import { DiffEditor, loader } from "@monaco-editor/react";
import type { editor } from "monaco-editor";
import { pdfjs } from 'react-pdf';
import mammoth from 'mammoth';
@@ -23,6 +23,33 @@ import { DOCUMENT_URL } from '~/config/api-config';
// Setup PDF.js worker
pdfjs.GlobalWorkerOptions.workerSrc = '/pdf.worker.js';
// 配置 Monaco Editor 使用本地资源(避免 CDN 加载超时)
// Monaco Editor 资源已通过 npm run copy-monaco 复制到 public/monaco-editor
if (typeof window !== 'undefined') {
console.log('[Monaco] 使用本地资源加载');
loader.config({
paths: {
vs: '/monaco-editor/vs'
}
});
// 添加加载超时监控和错误处理
const initTimeout = setTimeout(() => {
console.error('[Monaco] 加载超时(30秒)');
toastService.error('代码编辑器加载超时,请刷新页面重试');
}, 30000);
loader.init().then(() => {
clearTimeout(initTimeout);
console.log('[Monaco] ✅ 加载成功');
}).catch((error: Error) => {
clearTimeout(initTimeout);
console.error('[Monaco] ❌ 加载失败:', error);
toastService.error(`代码编辑器加载失败: ${error.message}`);
});
}
// Document type enum
type DocumentType = 'pdf' | 'docx' | 'unknown';
@@ -600,7 +627,7 @@ export function ComparePreview({ doc1Path, doc2Path }: ComparePreviewProps): JSX
<strong></strong>
<span style={{ marginLeft: '8px' }}>
<span style={{ color: '#dc3545', fontWeight: 'bold' }}></span> |
<span style={{ color: '#28a745', fontWeight: 'bold', marginLeft: '8px' }}>绿</span> |
<span style={{ color: '#28a745', fontWeight: 'bold', marginLeft: '8px' }}>绿</span> |
<span style={{ color: '#666', fontWeight: 'bold', marginLeft: '8px' }}></span>
</span>
</div>