|
|
@@ -1035,25 +1035,14 @@ function _Chat() {
|
|
|
}
|
|
|
})
|
|
|
setAppList(list);
|
|
|
- let appValue = '';
|
|
|
const search = location.search;
|
|
|
const params = new URLSearchParams(search);
|
|
|
- const appId = params.get('appId');
|
|
|
+ const appId = params.get('appId') || '';
|
|
|
if (appId) {
|
|
|
- const value = appId;
|
|
|
- if (list.find((item: any) => item.value === value)) {
|
|
|
- appValue = value;
|
|
|
- } else {
|
|
|
- appValue = list[0]?.value;
|
|
|
- }
|
|
|
+ setAppValue(appId);
|
|
|
} else {
|
|
|
- appValue = list[0]?.value;
|
|
|
+ setAppValue(list[0]?.value);
|
|
|
}
|
|
|
- setAppValue(appValue);
|
|
|
- globalStore.setSelectedAppId(appValue);
|
|
|
- chatStore.updateCurrentSession((session) => {
|
|
|
- session.appId = appValue;
|
|
|
- });
|
|
|
} catch (error) {
|
|
|
console.error(error);
|
|
|
} finally {
|
|
|
@@ -1083,6 +1072,15 @@ function _Chat() {
|
|
|
await fetchApplicationList();
|
|
|
}
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ const search = location.search;
|
|
|
+ const params = new URLSearchParams(search);
|
|
|
+ const chatMode = params.get('chatMode');
|
|
|
+ if (!chatMode) {
|
|
|
+ init();
|
|
|
+ }
|
|
|
+ }, [selectedFruit])
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
const search = location.search;
|
|
|
const params = new URLSearchParams(search);
|
|
|
@@ -1090,6 +1088,15 @@ function _Chat() {
|
|
|
|
|
|
if (chatMode) {
|
|
|
setSelectedFruit(chatMode as "ONLINE" | "LOCAL");
|
|
|
+ const appId = params.get('appId');
|
|
|
+ if (appId) {
|
|
|
+ setAppValue(appId);
|
|
|
+ globalStore.setSelectedAppId(appId);
|
|
|
+ chatStore.updateCurrentSession((session) => {
|
|
|
+ session.appId = appId;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ init();
|
|
|
}
|
|
|
}, [])
|
|
|
|
|
|
@@ -1099,20 +1106,6 @@ function _Chat() {
|
|
|
}
|
|
|
}, [appValue, chatStore.chatMode])
|
|
|
|
|
|
- useEffect(() => {
|
|
|
- init();
|
|
|
- const search = location.search;
|
|
|
- const params = new URLSearchParams(search);
|
|
|
- const appId = params.get('appId');
|
|
|
- if (appId) {
|
|
|
- setAppValue(appId);
|
|
|
- globalStore.setSelectedAppId(appId);
|
|
|
- chatStore.updateCurrentSession((session) => {
|
|
|
- session.appId = appId;
|
|
|
- });
|
|
|
- }
|
|
|
- }, [chatStore.chatMode])
|
|
|
-
|
|
|
const [inputRows, setInputRows] = useState(2);
|
|
|
const measure = useDebouncedCallback(
|
|
|
() => {
|
|
|
@@ -1607,15 +1600,21 @@ function _Chat() {
|
|
|
}
|
|
|
|
|
|
const getAppName = () => {
|
|
|
- const item = appList.find(item => item.value === appValue);
|
|
|
+ const appId = globalStore.selectedAppId;
|
|
|
+ const item = appList.find(item => item.value === appId);
|
|
|
if (!item) {
|
|
|
- return
|
|
|
+ return '';
|
|
|
}
|
|
|
return item.label;
|
|
|
}
|
|
|
|
|
|
- const getDesc = (value: string) => {
|
|
|
- return appList.find(item => item.value === value)?.desc;
|
|
|
+ const getDesc = () => {
|
|
|
+ const appId = globalStore.selectedAppId;
|
|
|
+ const item = appList.find(item => item.value === appId);
|
|
|
+ if (!item) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ return item.desc;
|
|
|
}
|
|
|
|
|
|
const couldStop = ChatControllerPool.hasPending();
|
|
|
@@ -2116,11 +2115,8 @@ function _Chat() {
|
|
|
<h1 style={{ textAlign: 'center' }}>
|
|
|
{getAppName()}
|
|
|
</h1>
|
|
|
- {/* <p style={{ textAlign: 'center' }}>
|
|
|
- 您好,欢迎使用建科·小智使用知识库创建的{getAppName()}
|
|
|
- </p> */}
|
|
|
<p style={{ textAlign: 'center' }}>
|
|
|
- {appValue ? getDesc(appValue) : ''}
|
|
|
+ {getDesc()}
|
|
|
</p>
|
|
|
<p>我猜您可能想问:</p>
|
|
|
{
|