fix: 1.接入ai_suggestion.
2. 接入合同起草功能。
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user