no message

This commit is contained in:
kuaifan 2025-11-08 23:43:25 +00:00
parent 8e518a044a
commit 3ffdce5e7a
7 changed files with 60 additions and 45 deletions

View File

@ -36,6 +36,7 @@
"element-sea": "^2.15.10-9", "element-sea": "^2.15.10-9",
"file-loader": "^6.2.0", "file-loader": "^6.2.0",
"highlight.js": "^11.7.0", "highlight.js": "^11.7.0",
"html-to-md": "^0.8.8",
"inquirer": "^8.2.0", "inquirer": "^8.2.0",
"internal-ip": "^6.2.0", "internal-ip": "^6.2.0",
"jquery": "^3.6.4", "jquery": "^3.6.4",

View File

@ -514,6 +514,7 @@ export default {
if (!responseEntry) { if (!responseEntry) {
return; return;
} }
const stickToBottom = this.shouldStickToBottom();
const payload = this.parseStreamPayload(event); const payload = this.parseStreamPayload(event);
const chunk = this.resolveStreamContent(payload); const chunk = this.resolveStreamContent(payload);
if (type === 'replace') { if (type === 'replace') {
@ -523,7 +524,9 @@ export default {
} }
this.updateResponseDisplayOutput(responseEntry); this.updateResponseDisplayOutput(responseEntry);
responseEntry.status = 'streaming'; responseEntry.status = 'streaming';
this.scrollResponsesToBottom(); if (stickToBottom) {
this.scrollResponsesToBottom();
}
}, },
/** /**
@ -777,6 +780,22 @@ export default {
} }
}); });
}, },
/**
* 判断是否需要保持滚动到底部
*/
shouldStickToBottom(threshold = 20) {
const container = this.$refs.responseContainer;
if (!container) {
return true;
}
const currentBottom = container.scrollTop + container.clientHeight;
const distance = container.scrollHeight - currentBottom;
if (Number.isNaN(distance)) {
return true;
}
return distance <= threshold;
},
}, },
} }
</script> </script>

View File

@ -343,7 +343,7 @@ import longpress from "../../../../directives/longpress";
import {inputLoadAdd, inputLoadIsLast, inputLoadRemove} from "./one"; import {inputLoadAdd, inputLoadIsLast, inputLoadRemove} from "./one";
import {languageList, languageName} from "../../../../language"; import {languageList, languageName} from "../../../../language";
import {isMarkdownFormat, MarkdownConver} from "../../../../utils/markdown"; import {isMarkdownFormat, MarkdownConver} from "../../../../utils/markdown";
import {extractPlainText} from "../../../../utils/text"; import {cutText, extractPlainText} from "../../../../utils/text";
import {MESSAGE_AI_SYSTEM_PROMPT} from "../../../../utils/ai"; import {MESSAGE_AI_SYSTEM_PROMPT} from "../../../../utils/ai";
import emitter from "../../../../store/events"; import emitter from "../../../../store/events";
import historyMixin from "./history"; import historyMixin from "./history";
@ -1947,14 +1947,14 @@ export default {
const sections = []; const sections = [];
const infoLines = []; const infoLines = [];
if (this.dialogData?.name) { if (this.dialogData?.name) {
infoLines.push(`名称:${this.cutText(this.dialogData.name, 60)}`); infoLines.push(`名称:${cutText(this.dialogData.name, 60)}`);
} }
if (this.dialogData?.type) { if (this.dialogData?.type) {
const typeMap = {group: this.$L('群聊'), user: this.$L('单聊')}; const typeMap = {group: this.$L('群聊'), user: this.$L('单聊')};
infoLines.push(`类型:${typeMap[this.dialogData.type] || this.dialogData.type}`); infoLines.push(`类型:${typeMap[this.dialogData.type] || this.dialogData.type}`);
} }
if (this.dialogData?.group_type) { if (this.dialogData?.group_type) {
infoLines.push(`分类:${this.cutText(this.dialogData.group_type, 60)}`); infoLines.push(`分类:${cutText(this.dialogData.group_type, 60)}`);
} }
if (infoLines.length) { if (infoLines.length) {
sections.push('## 会话信息'); sections.push('## 会话信息');
@ -1987,10 +1987,10 @@ export default {
} }
} }
const draftText = extractPlainText(this.value); const draftText = extractPlainText(this.value, 500);
if (draftText) { if (draftText) {
sections.push('## 当前草稿'); sections.push('## 当前草稿');
sections.push(this.cutText(draftText, 200)); sections.push(draftText);
} }
return sections.join('\n'); return sections.join('\n');
@ -2003,7 +2003,7 @@ export default {
const result = []; const result = [];
const seen = new Set(); const seen = new Set();
const pushName = (name) => { const pushName = (name) => {
const clean = this.cutText((name || '').trim(), 30); const clean = cutText((name || '').trim(), 30);
if (!clean || seen.has(clean)) { if (!clean || seen.has(clean)) {
return; return;
} }
@ -2058,25 +2058,12 @@ export default {
} }
try { try {
const preview = $A.getMsgSimpleDesc(message); const preview = $A.getMsgSimpleDesc(message);
const plain = extractPlainText(preview || ''); return extractPlainText(preview || '', 300);
return this.cutText(plain, 160);
} catch (error) { } catch (error) {
return ''; return '';
} }
}, },
cutText(text, limit = 60) {
const value = (text || '').trim();
if (!value) {
return '';
}
const units = Array.from(value);
if (units.length <= limit) {
return value;
}
return units.slice(0, limit).join('') + '…';
},
resolveUserNickname(userid) { resolveUserNickname(userid) {
if (!userid) { if (!userid) {
return ''; return '';

View File

@ -168,7 +168,7 @@ export default {
$A.messageWarning("当前没有可分析的汇报"); $A.messageWarning("当前没有可分析的汇报");
return; return;
} }
const plain = extractPlainText(this.currentDetail.content || ''); const plain = extractPlainText(this.currentDetail.content, null, true);
if (!plain) { if (!plain) {
$A.messageWarning("汇报内容为空,无法分析"); $A.messageWarning("汇报内容为空,无法分析");
return; return;
@ -178,6 +178,7 @@ export default {
onBeforeSend: this.handleReportAnalysisBeforeSend, onBeforeSend: this.handleReportAnalysisBeforeSend,
onApply: this.handleReportAnalysisApply, onApply: this.handleReportAnalysisApply,
autoSubmit: true, autoSubmit: true,
applyButtonText: this.$L('保存分析'),
}); });
}, },
@ -292,14 +293,10 @@ export default {
viewerMeta.forEach(line => sections.push(`- ${line}`)); viewerMeta.forEach(line => sections.push(`- ${line}`));
} }
const bodyText = extractPlainText(detail.content || ''); const bodyText = extractPlainText(detail.content, 8000, true);
if (bodyText) { if (bodyText) {
const limit = 5000;
const trimmed = bodyText.length > limit
? `${bodyText.slice(0, limit)}...`
: bodyText;
sections.push('## 汇报正文'); sections.push('## 汇报正文');
sections.push(trimmed); sections.push(bodyText);
} }
const previous = this.aiAnalysis?.text || detail.ai_analysis?.text; const previous = this.aiAnalysis?.text || detail.ai_analysis?.text;

View File

@ -291,12 +291,10 @@ export default {
sections.push(...meta); sections.push(...meta);
} }
const plain = extractPlainText(this.reportData.content || ''); const plain = extractPlainText(this.reportData.content, 8000, true);
if (plain) { if (plain) {
const limit = 3200;
const slice = plain.slice(0, limit);
sections.push('## 当前汇报正文'); sections.push('## 当前汇报正文');
sections.push(slice + (plain.length > limit ? '...' : '')); sections.push(plain);
} }
return sections.join('\n').trim(); return sections.join('\n').trim();

View File

@ -639,16 +639,8 @@ export default {
buildTaskAIContextData() { buildTaskAIContextData() {
const prompts = []; const prompts = [];
const plainText = (value, limit = 600) => {
const text = extractPlainText(value || '');
if (!text) {
return '';
}
return text.slice(0, limit).trim();
};
const currentTitle = (this.addData.name || '').trim(); const currentTitle = (this.addData.name || '').trim();
const currentContent = plainText(this.addData.content, 600); const currentContent = extractPlainText(this.addData.content, 2000, true);
if (currentTitle || currentContent) { if (currentTitle || currentContent) {
prompts.push('## 当前任务信息'); prompts.push('## 当前任务信息');
if (currentTitle) { if (currentTitle) {
@ -665,7 +657,7 @@ export default {
: null; : null;
if (currentTemplate) { if (currentTemplate) {
const templateName = (currentTemplate.name || currentTemplate.title || '').trim(); const templateName = (currentTemplate.name || currentTemplate.title || '').trim();
const templateContent = plainText(nostyle(currentTemplate.content, {sanitize: false}), 800); const templateContent = extractPlainText(nostyle(currentTemplate.content, {sanitize: false}), 1200, true);
prompts.push('## 任务模板要求'); prompts.push('## 任务模板要求');
if (templateName) { if (templateName) {
prompts.push(`模板名称:${templateName}`); prompts.push(`模板名称:${templateName}`);

View File

@ -1,13 +1,34 @@
export function extractPlainText(content) { import html2md from 'html-to-md'
const cutText = (text, limit = 60, ellipsis = '...') => {
const value = (text || '').trim();
if (!value) {
return '';
}
const units = Array.from(value);
if (units.length <= limit) {
return value;
}
return units.slice(0, limit).join('') + ellipsis;
}
const extractPlainText = (content, cutLength = null, convertHtmlToMarkdownMode = false) => {
if (!content) { if (!content) {
return ''; return '';
} }
const value = typeof content === 'string' ? content : JSON.stringify(content); const value = typeof content === 'string' ? content : JSON.stringify(content);
if (convertHtmlToMarkdownMode) {
const newValue = html2md(value).trim();
return cutLength ? cutText(newValue, cutLength) : newValue;
}
if (typeof window === 'undefined' || !window.document) { if (typeof window === 'undefined' || !window.document) {
return value.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim(); const newValue = value.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim();
return cutLength ? cutText(newValue, cutLength) : newValue;
} }
const div = document.createElement('div'); const div = document.createElement('div');
div.innerHTML = value; div.innerHTML = value;
return (div.textContent || div.innerText || '').replace(/\s+/g, ' ').trim(); const newValue = (div.textContent || div.innerText || '').replace(/\s+/g, ' ').trim();
return cutLength ? cutText(newValue, cutLength) : newValue;
} }
export {cutText, extractPlainText}