|
@@ -43,6 +43,7 @@ import RobotIcon from "../icons/robot.svg";
|
|
|
import AddIcon from "../icons/add.svg";
|
|
import AddIcon from "../icons/add.svg";
|
|
|
import SizeIcon from "../icons/size.svg";
|
|
import SizeIcon from "../icons/size.svg";
|
|
|
import PluginIcon from "../icons/plugin.svg";
|
|
import PluginIcon from "../icons/plugin.svg";
|
|
|
|
|
+import avatarSrc from "../icons/avatar.png";
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
|
ChatMessage,
|
|
ChatMessage,
|
|
@@ -90,7 +91,7 @@ import {
|
|
|
showPrompt,
|
|
showPrompt,
|
|
|
showToast,
|
|
showToast,
|
|
|
} from "./ui-lib";
|
|
} from "./ui-lib";
|
|
|
-import { useNavigate } from "react-router-dom";
|
|
|
|
|
|
|
+import { useNavigate, useLocation } from "react-router-dom";
|
|
|
import {
|
|
import {
|
|
|
CHAT_PAGE_SIZE,
|
|
CHAT_PAGE_SIZE,
|
|
|
LAST_INPUT_KEY,
|
|
LAST_INPUT_KEY,
|
|
@@ -108,7 +109,7 @@ import { prettyObject } from "../utils/format";
|
|
|
import { ExportMessageModal } from "./exporter";
|
|
import { ExportMessageModal } from "./exporter";
|
|
|
import { getClientConfig } from "../config/client";
|
|
import { getClientConfig } from "../config/client";
|
|
|
import { useAllModels } from "../utils/hooks";
|
|
import { useAllModels } from "../utils/hooks";
|
|
|
-import { Select } from 'antd';
|
|
|
|
|
|
|
+import { Button, message, Popover, Select } from 'antd';
|
|
|
import { RightOutlined } from '@ant-design/icons';
|
|
import { RightOutlined } from '@ant-design/icons';
|
|
|
import api from "@/app/api/api";
|
|
import api from "@/app/api/api";
|
|
|
|
|
|
|
@@ -912,10 +913,7 @@ function _Chat() {
|
|
|
const globalStore = useGlobalStore();
|
|
const globalStore = useGlobalStore();
|
|
|
type QuestionList = any[];
|
|
type QuestionList = any[];
|
|
|
const [questionList, setQuestionList] = useState<QuestionList>([]);
|
|
const [questionList, setQuestionList] = useState<QuestionList>([]);
|
|
|
-
|
|
|
|
|
- useEffect(() => {
|
|
|
|
|
- console.log(questionList, 'questionList');
|
|
|
|
|
- }, [questionList]);
|
|
|
|
|
|
|
+ const location = useLocation();
|
|
|
|
|
|
|
|
// 获取应用列表
|
|
// 获取应用列表
|
|
|
const fetchApplicationList = async () => {
|
|
const fetchApplicationList = async () => {
|
|
@@ -929,11 +927,23 @@ function _Chat() {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
setAppList(list);
|
|
setAppList(list);
|
|
|
- let newAppValue = '';
|
|
|
|
|
- setAppValue(list[0]?.value);
|
|
|
|
|
- newAppValue = list[0]?.value;
|
|
|
|
|
- globalStore.setSelectedAppId(newAppValue);
|
|
|
|
|
- chatStore.updateCurrentSession((session) => (session.appId = newAppValue));
|
|
|
|
|
|
|
+ let appValue = '';
|
|
|
|
|
+ const search = location.search;
|
|
|
|
|
+ if (search.startsWith('?appId=')) {
|
|
|
|
|
+ const value = search.slice(7);
|
|
|
|
|
+ if (list.find((item: any) => item.value === value)) {
|
|
|
|
|
+ appValue = value;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ appValue = list[0]?.value;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ appValue = list[0]?.value;
|
|
|
|
|
+ }
|
|
|
|
|
+ setAppValue(appValue);
|
|
|
|
|
+ globalStore.setSelectedAppId(appValue);
|
|
|
|
|
+ chatStore.updateCurrentSession((session) => {
|
|
|
|
|
+ session.appId = appValue;
|
|
|
|
|
+ });
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error(error);
|
|
console.error(error);
|
|
|
} finally {
|
|
} finally {
|
|
@@ -1534,15 +1544,30 @@ function _Chat() {
|
|
|
</div>
|
|
</div>
|
|
|
)} */}
|
|
)} */}
|
|
|
<div className="window-action-button">
|
|
<div className="window-action-button">
|
|
|
- <IconButton
|
|
|
|
|
- icon={<ExportIcon />}
|
|
|
|
|
- bordered
|
|
|
|
|
- title={Locale.Chat.Actions.Export}
|
|
|
|
|
- onClick={() => {
|
|
|
|
|
- // setShowExport(true);
|
|
|
|
|
- console.log('分享聊天记录');
|
|
|
|
|
- }}
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <Popover
|
|
|
|
|
+ trigger="click"
|
|
|
|
|
+ title="分享"
|
|
|
|
|
+ content={() => {
|
|
|
|
|
+ const url = `${window.location.origin}/#/chat?appId=${appValue}`
|
|
|
|
|
+ return <div>
|
|
|
|
|
+ <div style={{ marginBottom: 10 }}>
|
|
|
|
|
+ {url}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <Button onClick={() => {
|
|
|
|
|
+ navigator.clipboard.writeText(url);
|
|
|
|
|
+ message.success('分享链接已复制到剪贴板');
|
|
|
|
|
+ }}>
|
|
|
|
|
+ 复制
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ }
|
|
|
|
|
+ }>
|
|
|
|
|
+ <IconButton
|
|
|
|
|
+ icon={<ExportIcon />}
|
|
|
|
|
+ bordered
|
|
|
|
|
+ title={Locale.Chat.Actions.Export}
|
|
|
|
|
+ />
|
|
|
|
|
+ </Popover>
|
|
|
</div>
|
|
</div>
|
|
|
{/* {showMaxIcon && (
|
|
{/* {showMaxIcon && (
|
|
|
<div className="window-action-button">
|
|
<div className="window-action-button">
|
|
@@ -1791,35 +1816,39 @@ function _Chat() {
|
|
|
</>
|
|
</>
|
|
|
:
|
|
:
|
|
|
<>
|
|
<>
|
|
|
- <div style={{ position: 'absolute', width: '800px', height: '550px', top: '0', left: '0', right: '0', bottom: '0', margin: 'auto' }}>
|
|
|
|
|
- <h1 style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
|
|
|
|
|
|
+ <div style={{ padding: '0 20px' }}>
|
|
|
|
|
+ <div style={{ display: 'flex', justifyContent: 'center' }}>
|
|
|
|
|
+ <img style={{ width: 80, height: 80 }} src={avatarSrc.src} />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <h1 style={{ textAlign: 'center' }}>
|
|
|
{getAppName()}
|
|
{getAppName()}
|
|
|
</h1>
|
|
</h1>
|
|
|
- <p style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>创建人: admin</p>
|
|
|
|
|
- <p style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
|
|
|
|
- 您好,欢迎使用建科·小智使用知识库创建的
|
|
|
|
|
- <span>
|
|
|
|
|
- {getAppName()}
|
|
|
|
|
- </span>
|
|
|
|
|
|
|
+ <p style={{ textAlign: 'center' }}>创建人: admin</p>
|
|
|
|
|
+ <p style={{ textAlign: 'center' }}>
|
|
|
|
|
+ 您好,欢迎使用建科·小智使用知识库创建的{getAppName()}
|
|
|
</p>
|
|
</p>
|
|
|
- <p style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>如果需要问本企业相关的其他问题请点击左上角,选中切换的知识库问答应用使用</p>
|
|
|
|
|
|
|
+ <p style={{ textAlign: 'center' }}>如果需要问本企业相关的其他问题请点击左上角,选中切换的知识库问答应用使用</p>
|
|
|
<p>我猜您可能想问:</p>
|
|
<p>我猜您可能想问:</p>
|
|
|
{
|
|
{
|
|
|
- questionList.map((item) => {
|
|
|
|
|
|
|
+ questionList.map((item, index) => {
|
|
|
return (
|
|
return (
|
|
|
- <div style={{
|
|
|
|
|
- padding: '10px',
|
|
|
|
|
- marginBottom: '10px',
|
|
|
|
|
- border: '1px solid #e6e8f1',
|
|
|
|
|
- borderRadius: '10px',
|
|
|
|
|
- fontSize: '16px',
|
|
|
|
|
- display: 'flex',
|
|
|
|
|
- justifyContent: 'space-between',
|
|
|
|
|
- alignItems: 'center',
|
|
|
|
|
- cursor: 'pointer'
|
|
|
|
|
- }} onClick={() => {
|
|
|
|
|
- setUserInput(item)
|
|
|
|
|
- }}>
|
|
|
|
|
|
|
+ <div
|
|
|
|
|
+ style={{
|
|
|
|
|
+ padding: '10px',
|
|
|
|
|
+ marginBottom: '10px',
|
|
|
|
|
+ border: '1px solid #e6e8f1',
|
|
|
|
|
+ borderRadius: '10px',
|
|
|
|
|
+ fontSize: '16px',
|
|
|
|
|
+ display: 'flex',
|
|
|
|
|
+ justifyContent: 'space-between',
|
|
|
|
|
+ alignItems: 'center',
|
|
|
|
|
+ cursor: 'pointer'
|
|
|
|
|
+ }}
|
|
|
|
|
+ onClick={() => {
|
|
|
|
|
+ setUserInput(item)
|
|
|
|
|
+ }}
|
|
|
|
|
+ key={index}
|
|
|
|
|
+ >
|
|
|
<div>
|
|
<div>
|
|
|
{item}
|
|
{item}
|
|
|
</div>
|
|
</div>
|
|
@@ -1835,7 +1864,6 @@ function _Chat() {
|
|
|
|
|
|
|
|
<div className={styles["chat-input-panel"]}>
|
|
<div className={styles["chat-input-panel"]}>
|
|
|
{/* <PromptHints prompts={promptHints} onPromptSelect={onPromptSelect} /> */}
|
|
{/* <PromptHints prompts={promptHints} onPromptSelect={onPromptSelect} /> */}
|
|
|
-
|
|
|
|
|
<ChatActions
|
|
<ChatActions
|
|
|
setUserInput={setUserInput}
|
|
setUserInput={setUserInput}
|
|
|
doSubmit={doSubmit}
|
|
doSubmit={doSubmit}
|