mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-05 06:35:39 +00:00
v4.6 -1 (#459)
This commit is contained in:
@@ -5,7 +5,7 @@ import MyIcon from '@/components/Icon';
|
||||
import Tag from '@/components/Tag';
|
||||
import Avatar from '@/components/Avatar';
|
||||
import ToolMenu from './ToolMenu';
|
||||
import { ChatItemType } from '@/types/chat';
|
||||
import type { ChatItemType } from '@fastgpt/global/core/chat/type';
|
||||
import { useRouter } from 'next/router';
|
||||
|
||||
const ChatHeader = ({
|
||||
|
@@ -21,6 +21,8 @@ import { useConfirm } from '@/web/common/hooks/useConfirm';
|
||||
import Tabs from '@/components/Tabs';
|
||||
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useAppStore } from '@/web/core/app/store/useAppStore';
|
||||
import { TeamMemberRoleEnum } from '@fastgpt/global/support/user/team/constant';
|
||||
|
||||
type HistoryItemType = {
|
||||
id: string;
|
||||
@@ -63,7 +65,8 @@ const ChatHistorySlider = ({
|
||||
const router = useRouter();
|
||||
const { t } = useTranslation();
|
||||
const { isPc } = useSystemStore();
|
||||
const { myApps, loadMyApps, userInfo } = useUserStore();
|
||||
const { myApps, loadMyApps } = useAppStore();
|
||||
const { userInfo } = useUserStore();
|
||||
|
||||
const [currentTab, setCurrentTab] = useState<`${TabEnum}`>(TabEnum.history);
|
||||
|
||||
@@ -76,7 +79,7 @@ const ChatHistorySlider = ({
|
||||
});
|
||||
const { openConfirm, ConfirmModal } = useConfirm({
|
||||
content: isShare
|
||||
? t('chat.Confirm to clear share chat histroy')
|
||||
? t('chat.Confirm to clear share chat history')
|
||||
: t('chat.Confirm to clear history')
|
||||
});
|
||||
|
||||
@@ -94,6 +97,11 @@ const ChatHistorySlider = ({
|
||||
return loadMyApps(false);
|
||||
});
|
||||
|
||||
const canRouteToDetail = useMemo(
|
||||
() => appId && userInfo?.team.role !== TeamMemberRoleEnum.visitor,
|
||||
[appId, userInfo?.team.role]
|
||||
);
|
||||
|
||||
return (
|
||||
<Flex
|
||||
position={'relative'}
|
||||
@@ -105,15 +113,15 @@ const ChatHistorySlider = ({
|
||||
whiteSpace={'nowrap'}
|
||||
>
|
||||
{isPc && (
|
||||
<MyTooltip label={appId ? t('app.App Detail') : ''} offset={[0, 0]}>
|
||||
<MyTooltip label={canRouteToDetail ? t('app.App Detail') : ''} offset={[0, 0]}>
|
||||
<Flex
|
||||
pt={5}
|
||||
pb={2}
|
||||
px={[2, 5]}
|
||||
alignItems={'center'}
|
||||
cursor={appId ? 'pointer' : 'default'}
|
||||
cursor={canRouteToDetail ? 'pointer' : 'default'}
|
||||
onClick={() =>
|
||||
appId &&
|
||||
canRouteToDetail &&
|
||||
router.replace({
|
||||
pathname: '/app/detail',
|
||||
query: { appId }
|
||||
|
@@ -1,16 +1,16 @@
|
||||
import React from 'react';
|
||||
import { Flex, Box, IconButton } from '@chakra-ui/react';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import MyIcon from '@/components/Icon';
|
||||
import Avatar from '@/components/Avatar';
|
||||
import { useAppStore } from '@/web/core/app/store/useAppStore';
|
||||
|
||||
const SliderApps = ({ appId }: { appId: string }) => {
|
||||
const { t } = useTranslation();
|
||||
const router = useRouter();
|
||||
const { myApps, loadMyApps } = useUserStore();
|
||||
const { myApps, loadMyApps } = useAppStore();
|
||||
|
||||
useQuery(['loadModels'], () => loadMyApps(false));
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import { useChatBox } from '@/components/ChatBox';
|
||||
import { ChatItemType } from '@/types/chat';
|
||||
import type { ChatItemType } from '@fastgpt/global/core/chat/type.d';
|
||||
import { Menu, MenuButton, MenuList, MenuItem, Box } from '@chakra-ui/react';
|
||||
import MyIcon from '@/components/Icon';
|
||||
import { useRouter } from 'next/router';
|
||||
|
@@ -19,7 +19,7 @@ import { useLoading } from '@/web/common/hooks/useLoading';
|
||||
import { useToast } from '@/web/common/hooks/useToast';
|
||||
import { customAlphabet } from 'nanoid';
|
||||
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz1234567890', 12);
|
||||
import type { ChatHistoryItemType } from '@/types/chat';
|
||||
import type { ChatHistoryItemType } from '@fastgpt/global/core/chat/type.d';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import ChatBox, { type ComponentRef, type StartChatFnProps } from '@/components/ChatBox';
|
||||
@@ -31,6 +31,7 @@ import ChatHeader from './components/ChatHeader';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||
import { serviceSideProps } from '@/web/common/utils/i18n';
|
||||
import { useAppStore } from '@/web/core/app/store/useAppStore';
|
||||
|
||||
const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
|
||||
const router = useRouter();
|
||||
@@ -54,7 +55,8 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
|
||||
chatData,
|
||||
setChatData
|
||||
} = useChatStore();
|
||||
const { myApps, loadMyApps, userInfo } = useUserStore();
|
||||
const { myApps, loadMyApps } = useAppStore();
|
||||
const { userInfo } = useUserStore();
|
||||
|
||||
const { isPc } = useSystemStore();
|
||||
const { Loading, setIsLoading } = useLoading();
|
||||
@@ -188,7 +190,7 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
|
||||
[setIsLoading, setChatData, router, setLastChatAppId, setLastChatId, toast]
|
||||
);
|
||||
// 初始化聊天框
|
||||
useQuery(['init', appId, chatId], () => {
|
||||
useQuery(['init', { appId, chatId }], () => {
|
||||
// pc: redirect to latest model chat
|
||||
if (!appId && lastChatAppId) {
|
||||
return router.replace({
|
||||
|
@@ -11,7 +11,7 @@ import { useShareChatStore, defaultHistory } from '@/web/core/chat/storeShareCha
|
||||
import SideBar from '@/components/SideBar';
|
||||
import { gptMessage2ChatType } from '@/utils/adapt';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import { ChatSiteItemType } from '@/types/chat';
|
||||
import type { ChatSiteItemType } from '@fastgpt/global/core/chat/type.d';
|
||||
import { customAlphabet } from 'nanoid';
|
||||
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz1234567890', 12);
|
||||
|
||||
|
Reference in New Issue
Block a user