feat: AI写作模块4项优化(20260419_2226)

- 修复 diff 颜色残留: confirmAiInjection 使用 cleanHtml 而非 newHtml
- 更新默认快捷指令: 4条外科专用 -> 2条通用短语
- 新增发送按钮: 输入框旁显式发送按钮
- 导出AI日志: 快捷指令区域新增调试日志导出(JSON)
This commit is contained in:
2026-04-19 22:29:43 +08:00
parent 1ec25065ad
commit 2e634ff832
2 changed files with 49 additions and 2 deletions

View File

@@ -69,7 +69,7 @@ export default function ReportEditor() {
const [aiUploadedImages, setAiUploadedImages] = useState<{id: number, dataUrl: string}[]>([]);
const speechRecognitionRef = useRef<any>(null);
const [quickPrompts, setQuickPrompts] = useState<string[]>([
'请详细描述手术步骤', '提取术中关键病灶信息', '生成简短的术后总结', '根据截图描述游离过程'
'请完善报告内容', '请对内容做如下修改:'
]);
const [isEditingPrompts, setIsEditingPrompts] = useState(false);
const [diffModal, setDiffModal] = useState<{isOpen: boolean, originalHtml: string, newHtml: string, targetId: string} | null>(null);
@@ -1016,7 +1016,7 @@ export default function ReportEditor() {
range.selectNodeContents(targetContent);
sel?.removeAllRanges();
sel?.addRange(range);
document.execCommand('insertHTML', false, newHtml);
document.execCommand('insertHTML', false, cleanHtml);
targetContent.style.transition = 'background-color 0.3s ease';
targetContent.style.backgroundColor = '#bfdbfe';
setTimeout(() => {
@@ -2381,6 +2381,31 @@ export default function ReportEditor() {
{isEditingPrompts ? '+ 添加' : '⚙️'}
</button>
{isEditingPrompts && <button onClick={() => setIsEditingPrompts(false)} className="px-2 py-1 bg-blue-100 text-blue-600 text-[11px] rounded-full"></button>}
<button onClick={() => {
const data = {
exportAt: new Date().toISOString(),
url: window.location.href,
messages: chatMessages,
metadata: {
user: currentUser?.username || 'anonymous',
activeProvider: (() => { const s = storage.get<SystemSettings>('systemSettings', {} as SystemSettings); return s.activeAiProvider || 'kimi'; })(),
targetRegion: aiTargetRegion,
modifyEnabled: aiModifyEnabled,
chatInput,
uploadedImagesCount: aiUploadedImages.length,
selectedFramesCount: aiSelectedFrames.length
}
};
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `ai-logs-${Date.now()}.json`;
a.click();
URL.revokeObjectURL(url);
}} className="px-2 py-1 bg-slate-100 text-slate-500 text-[11px] rounded-full hover:bg-slate-200 ml-auto" title="导出 AI 日志(调试用)">
AI
</button>
</div>
{/* 沉浸式输入框 */}
@@ -2420,6 +2445,9 @@ export default function ReportEditor() {
<button onClick={toggleListening} className={`p-1.5 rounded-lg transition-colors ${isListening ? 'text-red-500 bg-red-50 animate-pulse' : 'text-slate-400 hover:text-blue-600 bg-slate-50 hover:bg-blue-50'}`}>
{isListening ? <Mic size={16} /> : <MicOff size={16} />}
</button>
<button onClick={() => { if (!isGenerating && chatInput.trim()) handleAIGenerate(chatInput); }} disabled={isGenerating || !chatInput.trim()} className="p-1.5 rounded-lg transition-colors text-slate-400 hover:text-blue-600 bg-slate-50 hover:bg-blue-50 disabled:opacity-40 disabled:cursor-not-allowed" title="发送">
<Send size={16} />
</button>
</div>
</div>
</div>