...
|
...
|
@@ -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,7 +713,8 @@ export function ChatActions(props: { |
|
|
<Selector
|
|
|
defaultSelectedValue={`${currentModel}@${currentProviderName}`}
|
|
|
items={models.map((m) => ({
|
|
|
title: `${m.displayName}${m?.provider?.providerName
|
|
|
title: `${m.displayName}${
|
|
|
m?.provider?.providerName
|
|
|
? " (" + m?.provider?.providerName + ")"
|
|
|
: ""
|
|
|
}`,
|
...
|
...
|
@@ -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(
|
|
|
onClick={() =>
|
|
|
exportWord(
|
|
|
getMessageTextContent(message),
|
|
|
)}
|
|
|
)
|
|
|
}
|
|
|
/>
|
|
|
<ChatAction
|
|
|
text={Locale.Chat.Actions.Mind}
|
|
|
icon={<MindIcon />}
|
|
|
onClick={() => exportWord(
|
|
|
onClick={() => {
|
|
|
toMind(
|
|
|
messages,
|
|
|
getMessageTextContent(message),
|
|
|
)}
|
|
|
);
|
|
|
}}
|
|
|
/>
|
|
|
</>
|
|
|
)}
|
...
|
...
|
|