|
@@ -15,7 +15,7 @@ addIcons({
|
|
|
@Component({
|
|
@Component({
|
|
|
selector: 'app-ai-design-analysis',
|
|
selector: 'app-ai-design-analysis',
|
|
|
standalone: true,
|
|
standalone: true,
|
|
|
- imports: [CommonModule, FormsModule, ReactiveFormsModule, IonIcon],
|
|
|
|
|
|
|
+ imports: [CommonModule, FormsModule, ReactiveFormsModule],
|
|
|
templateUrl: './ai-design-analysis.component.html',
|
|
templateUrl: './ai-design-analysis.component.html',
|
|
|
styleUrls: ['./ai-design-analysis.component.scss']
|
|
styleUrls: ['./ai-design-analysis.component.scss']
|
|
|
})
|
|
})
|
|
@@ -118,67 +118,9 @@ export class AiDesignAnalysisComponent implements OnInit {
|
|
|
event.stopPropagation();
|
|
event.stopPropagation();
|
|
|
this.aiDesignDragOver = false;
|
|
this.aiDesignDragOver = false;
|
|
|
|
|
|
|
|
- // 🔥 打印拖拽事件的完整结构(用于调试企业微信)
|
|
|
|
|
- console.log('📥 [拖拽事件] 完整dataTransfer对象:', {
|
|
|
|
|
- types: event.dataTransfer?.types,
|
|
|
|
|
- items: Array.from(event.dataTransfer?.items || []).map((item, i) => ({
|
|
|
|
|
- index: i,
|
|
|
|
|
- kind: item.kind,
|
|
|
|
|
- type: item.type,
|
|
|
|
|
- item: item
|
|
|
|
|
- })),
|
|
|
|
|
- files: Array.from(event.dataTransfer?.files || []).map((file, i) => ({
|
|
|
|
|
- index: i,
|
|
|
|
|
- name: file.name,
|
|
|
|
|
- size: file.size,
|
|
|
|
|
- type: file.type,
|
|
|
|
|
- lastModified: file.lastModified
|
|
|
|
|
- })),
|
|
|
|
|
- effectAllowed: event.dataTransfer?.effectAllowed,
|
|
|
|
|
- dropEffect: event.dataTransfer?.dropEffect
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
const files = event.dataTransfer?.files;
|
|
const files = event.dataTransfer?.files;
|
|
|
if (files && files.length > 0) {
|
|
if (files && files.length > 0) {
|
|
|
- console.log('✅ [拖拽事件] 检测到文件,数量:', files.length);
|
|
|
|
|
await this.processAIFiles(files);
|
|
await this.processAIFiles(files);
|
|
|
- } else {
|
|
|
|
|
- console.warn('⚠️ [拖拽事件] 未检测到文件,尝试从items获取...');
|
|
|
|
|
-
|
|
|
|
|
- // 🔥 企业微信可能将图片放在items中而非files中
|
|
|
|
|
- const items = event.dataTransfer?.items;
|
|
|
|
|
- if (items && items.length > 0) {
|
|
|
|
|
- const fileList: File[] = [];
|
|
|
|
|
- for (let i = 0; i < items.length; i++) {
|
|
|
|
|
- const item = items[i];
|
|
|
|
|
- console.log(`🔍 [拖拽事件] Item ${i}:`, {
|
|
|
|
|
- kind: item.kind,
|
|
|
|
|
- type: item.type
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- if (item.kind === 'file') {
|
|
|
|
|
- const file = item.getAsFile();
|
|
|
|
|
- if (file) {
|
|
|
|
|
- console.log(`✅ [拖拽事件] 从Item ${i}获取到文件:`, file.name);
|
|
|
|
|
- fileList.push(file);
|
|
|
|
|
- }
|
|
|
|
|
- } else if (item.kind === 'string') {
|
|
|
|
|
- // 企业微信可能以字符串形式传递URL或base64
|
|
|
|
|
- item.getAsString((str) => {
|
|
|
|
|
- console.log(`📝 [拖拽事件] Item ${i}字符串内容:`, str.substring(0, 200));
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (fileList.length > 0) {
|
|
|
|
|
- console.log('✅ [拖拽事件] 从items中获取到文件,数量:', fileList.length);
|
|
|
|
|
- await this.processAIFiles(fileList);
|
|
|
|
|
- } else {
|
|
|
|
|
- console.error('❌ [拖拽事件] 无法从items中提取文件');
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- console.error('❌ [拖拽事件] dataTransfer中既无files也无items');
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -303,18 +245,12 @@ export class AiDesignAnalysisComponent implements OnInit {
|
|
|
|
|
|
|
|
this.aiDesignAnalysisResult = result;
|
|
this.aiDesignAnalysisResult = result;
|
|
|
|
|
|
|
|
- // 🔥 Final update:仅标记完成,不覆盖内容(内容已通过流式输出显示)
|
|
|
|
|
|
|
+ // Final update
|
|
|
const aiMsgIndex = this.aiChatMessages.findIndex(m => m.id === aiMsgId);
|
|
const aiMsgIndex = this.aiChatMessages.findIndex(m => m.id === aiMsgId);
|
|
|
if (aiMsgIndex !== -1) {
|
|
if (aiMsgIndex !== -1) {
|
|
|
this.aiChatMessages[aiMsgIndex].isLoading = false;
|
|
this.aiChatMessages[aiMsgIndex].isLoading = false;
|
|
|
this.aiChatMessages[aiMsgIndex].isStreaming = false;
|
|
this.aiChatMessages[aiMsgIndex].isStreaming = false;
|
|
|
- // 🔥 如果流式输出的内容为空或太短,才使用完整内容
|
|
|
|
|
- if (!this.aiChatMessages[aiMsgIndex].content || this.aiChatMessages[aiMsgIndex].content.length < 100) {
|
|
|
|
|
- console.log('⚠️ 流式输出内容不足,使用完整内容');
|
|
|
|
|
- this.aiChatMessages[aiMsgIndex].content = result.formattedContent || result.rawContent || '分析完成,请查看下方详细结果。';
|
|
|
|
|
- } else {
|
|
|
|
|
- console.log('✅ 保留流式输出的完整内容,长度:', this.aiChatMessages[aiMsgIndex].content.length);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.aiChatMessages[aiMsgIndex].content = result.formattedContent || result.rawContent || '分析完成,请查看下方详细结果。';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
this.analysisComplete.emit(result);
|
|
this.analysisComplete.emit(result);
|
|
@@ -388,7 +324,6 @@ export class AiDesignAnalysisComponent implements OnInit {
|
|
|
const response = await this.designAnalysisAIService.chatWithAI({
|
|
const response = await this.designAnalysisAIService.chatWithAI({
|
|
|
userMessage: content,
|
|
userMessage: content,
|
|
|
conversationHistory: history,
|
|
conversationHistory: history,
|
|
|
- context: this.aiDesignAnalysisResult,
|
|
|
|
|
onContentStream: (streamContent) => {
|
|
onContentStream: (streamContent) => {
|
|
|
const aiMsgIndex = this.aiChatMessages.findIndex(m => m.id === aiMsgId);
|
|
const aiMsgIndex = this.aiChatMessages.findIndex(m => m.id === aiMsgId);
|
|
|
if (aiMsgIndex !== -1) {
|
|
if (aiMsgIndex !== -1) {
|