...
|
...
|
@@ -52,7 +52,7 @@ import HeadphoneIcon from "../icons/headphone.svg"; |
|
|
//20250317新增word excel图标
|
|
|
import ExcelIcon from "../icons/excel.svg";
|
|
|
import WordIcon from "../icons/word.svg";
|
|
|
import MindIcon from "../icons/mind.svg"
|
|
|
import MindIcon from "../icons/mind.svg";
|
|
|
|
|
|
import {
|
|
|
BOT_HELLO,
|
...
|
...
|
@@ -66,6 +66,7 @@ import { |
|
|
useAppConfig,
|
|
|
useChatStore,
|
|
|
usePluginStore,
|
|
|
useMindMapStore, //新增消息仓库用于存储上下文至思维导图页面
|
|
|
} from "../store";
|
|
|
|
|
|
import {
|
...
|
...
|
@@ -134,7 +135,8 @@ import { getAvailableClientsCount, isMcpEnabled } from "../mcp/actions"; |
|
|
|
|
|
//20250317新增
|
|
|
import { toExcel } from "../utils/excelAndWordUtils/export2Excel";
|
|
|
import {exportWord} from "../utils/excelAndWordUtils/word";
|
|
|
import { exportWord } from "../utils/excelAndWordUtils/word";
|
|
|
import { getMindPrompt } from "../utils/prompt";
|
|
|
const localStorage = safeLocalStorage();
|
|
|
|
|
|
const ttsPlayer = createTTSPlayer();
|
...
|
...
|
@@ -181,7 +183,9 @@ function isTableContent(content: string): boolean { |
|
|
const hasTableSeparator = tablePattern.test(content);
|
|
|
|
|
|
// 检查是否包含至少一行表格内容
|
|
|
const hasTableRows = content.split("\n").some((line) => rowPattern.test(line));
|
|
|
const hasTableRows = content
|
|
|
.split("\n")
|
|
|
.some((line) => rowPattern.test(line));
|
|
|
|
|
|
// 如果同时包含分隔符行和表格内容行,则认为是表格
|
|
|
return hasTableSeparator && hasTableRows;
|
...
|
...
|
@@ -709,10 +713,11 @@ export function ChatActions(props: { |
|
|
<Selector
|
|
|
defaultSelectedValue={`${currentModel}@${currentProviderName}`}
|
|
|
items={models.map((m) => ({
|
|
|
title: `${m.displayName}${m?.provider?.providerName
|
|
|
? " (" + m?.provider?.providerName + ")"
|
|
|
: ""
|
|
|
}`,
|
|
|
title: `${m.displayName}${
|
|
|
m?.provider?.providerName
|
|
|
? " (" + m?.provider?.providerName + ")"
|
|
|
: ""
|
|
|
}`,
|
|
|
value: `${m.name}@${m?.provider?.providerName}`,
|
|
|
}))}
|
|
|
onClose={() => setShowModelSelector(false)}
|
...
|
...
|
@@ -1029,9 +1034,9 @@ function _Chat() { |
|
|
const scrollRef = useRef<HTMLDivElement>(null);
|
|
|
const isScrolledToBottom = scrollRef?.current
|
|
|
? Math.abs(
|
|
|
scrollRef.current.scrollHeight -
|
|
|
(scrollRef.current.scrollTop + scrollRef.current.clientHeight),
|
|
|
) <= 1
|
|
|
scrollRef.current.scrollHeight -
|
|
|
(scrollRef.current.scrollTop + scrollRef.current.clientHeight),
|
|
|
) <= 1
|
|
|
: false;
|
|
|
const isAttachWithTop = useMemo(() => {
|
|
|
const lastMessage = scrollRef.current?.lastElementChild as HTMLElement;
|
...
|
...
|
@@ -1377,27 +1382,27 @@ function _Chat() { |
|
|
.concat(
|
|
|
isLoading
|
|
|
? [
|
|
|
{
|
|
|
...createMessage({
|
|
|
role: "assistant",
|
|
|
content: "……",
|
|
|
}),
|
|
|
preview: true,
|
|
|
},
|
|
|
]
|
|
|
{
|
|
|
...createMessage({
|
|
|
role: "assistant",
|
|
|
content: "……",
|
|
|
}),
|
|
|
preview: true,
|
|
|
},
|
|
|
]
|
|
|
: [],
|
|
|
)
|
|
|
.concat(
|
|
|
userInput.length > 0 && config.sendPreviewBubble
|
|
|
? [
|
|
|
{
|
|
|
...createMessage({
|
|
|
role: "user",
|
|
|
content: userInput,
|
|
|
}),
|
|
|
preview: true,
|
|
|
},
|
|
|
]
|
|
|
{
|
|
|
...createMessage({
|
|
|
role: "user",
|
|
|
content: userInput,
|
|
|
}),
|
|
|
preview: true,
|
|
|
},
|
|
|
]
|
|
|
: [],
|
|
|
);
|
|
|
}, [
|
...
|
...
|
@@ -1494,7 +1499,7 @@ function _Chat() { |
|
|
if (payload.key || payload.url) {
|
|
|
showConfirm(
|
|
|
Locale.URLCommand.Settings +
|
|
|
`\n${JSON.stringify(payload, null, 4)}`,
|
|
|
`\n${JSON.stringify(payload, null, 4)}`,
|
|
|
).then((res) => {
|
|
|
if (!res) return;
|
|
|
if (payload.key) {
|
...
|
...
|
@@ -1704,6 +1709,36 @@ function _Chat() { |
|
|
|
|
|
const [showChatSidePanel, setShowChatSidePanel] = useState(false);
|
|
|
|
|
|
// 20250327新增思维导图导出
|
|
|
function toMind(messages: RenderMessage[], content: string) {
|
|
|
const newMessages = [];
|
|
|
const { setMindMapData } = useMindMapStore.getState();
|
|
|
// 遍历 messages 数组
|
|
|
for (const message of messages) {
|
|
|
// 检查 content 类型并正确存储
|
|
|
if (typeof message.content === "string") {
|
|
|
newMessages.push({
|
|
|
role: message.role,
|
|
|
content: message.content,
|
|
|
});
|
|
|
} else {
|
|
|
newMessages.push({
|
|
|
role: message.role,
|
|
|
content: JSON.stringify(message.content),
|
|
|
});
|
|
|
}
|
|
|
if (message.content === content) {
|
|
|
newMessages.push({
|
|
|
role: "user",
|
|
|
content: getMindPrompt(content, true),
|
|
|
});
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
setMindMapData(newMessages, content);
|
|
|
navigate("/mind", { state: { msg: true } });
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
<>
|
|
|
<div className={styles.chat} key={session.id}>
|
...
|
...
|
@@ -1939,7 +1974,7 @@ function _Chat() { |
|
|
}
|
|
|
/>
|
|
|
{/* 以下 20250317 新增Word excel导出按钮 */}
|
|
|
{isTableContent(getMessageTextContent(message)) && (
|
|
|
{/* {isTableContent(getMessageTextContent(message)) && (
|
|
|
<>
|
|
|
<ChatAction
|
|
|
text={Locale.Chat.Actions.Excel}
|
...
|
...
|
@@ -1949,23 +1984,38 @@ function _Chat() { |
|
|
}
|
|
|
/>
|
|
|
</>
|
|
|
)}
|
|
|
|
|
|
{!isTableContent(getMessageTextContent(message)) && (
|
|
|
)} */}
|
|
|
<ChatAction
|
|
|
text={Locale.Chat.Actions.Excel}
|
|
|
icon={<ExcelIcon />}
|
|
|
onClick={() =>
|
|
|
toExcel(
|
|
|
getMessageTextContent(message),
|
|
|
)
|
|
|
}
|
|
|
/>
|
|
|
{!isTableContent(
|
|
|
getMessageTextContent(message),
|
|
|
) && (
|
|
|
<>
|
|
|
<ChatAction
|
|
|
text={Locale.Chat.Actions.Word}
|
|
|
icon={<WordIcon />}
|
|
|
onClick={() => exportWord(
|
|
|
getMessageTextContent(message),
|
|
|
)}
|
|
|
onClick={() =>
|
|
|
exportWord(
|
|
|
getMessageTextContent(message),
|
|
|
)
|
|
|
}
|
|
|
/>
|
|
|
<ChatAction
|
|
|
text={Locale.Chat.Actions.Mind}
|
|
|
icon={<MindIcon />}
|
|
|
onClick={() => exportWord(
|
|
|
getMessageTextContent(message),
|
|
|
)}
|
|
|
onClick={() => {
|
|
|
toMind(
|
|
|
messages,
|
|
|
getMessageTextContent(message),
|
|
|
);
|
|
|
}}
|
|
|
/>
|
|
|
</>
|
|
|
)}
|
...
|
...
|
@@ -2065,7 +2115,7 @@ function _Chat() { |
|
|
<img
|
|
|
className={
|
|
|
styles[
|
|
|
"chat-message-item-image-multi"
|
|
|
"chat-message-item-image-multi"
|
|
|
]
|
|
|
}
|
|
|
key={index}
|
...
|
...
|
|