Commit 3c2bf206 by 伍闲犬 Committed by GitHub

feat: add switch to control if enable `home` (#5531)

parent 3b25bf57
...@@ -4,6 +4,7 @@ export type ChatSettingSchema = { ...@@ -4,6 +4,7 @@ export type ChatSettingSchema = {
teamId: string; teamId: string;
slogan: string; slogan: string;
dialogTips: string; dialogTips: string;
enableHome: boolean;
homeTabTitle: string; homeTabTitle: string;
wideLogoUrl?: string; wideLogoUrl?: string;
squareLogoUrl?: string; squareLogoUrl?: string;
......
...@@ -18,6 +18,10 @@ const ChatSettingSchema = new Schema({ ...@@ -18,6 +18,10 @@ const ChatSettingSchema = new Schema({
ref: AppCollectionName, ref: AppCollectionName,
required: true required: true
}, },
enableHome: {
type: Boolean,
default: true
},
slogan: String, slogan: String,
dialogTips: String, dialogTips: String,
selectedTools: { selectedTools: {
......
...@@ -135,6 +135,7 @@ ...@@ -135,6 +135,7 @@
"setting.home.dialogue_tips": "Dialog prompt text", "setting.home.dialogue_tips": "Dialog prompt text",
"setting.home.dialogue_tips.default": "You can ask me any questions", "setting.home.dialogue_tips.default": "You can ask me any questions",
"setting.home.dialogue_tips_placeholder": "Please enter the prompt text of the dialog box", "setting.home.dialogue_tips_placeholder": "Please enter the prompt text of the dialog box",
"setting.home.enable": "Enable home page",
"setting.home.home_tab_title": "Home Page Title", "setting.home.home_tab_title": "Home Page Title",
"setting.home.home_tab_title_placeholder": "Please enter the title of the homepage", "setting.home.home_tab_title_placeholder": "Please enter the title of the homepage",
"setting.home.no_selected_app": "No selected App", "setting.home.no_selected_app": "No selected App",
......
...@@ -147,6 +147,7 @@ ...@@ -147,6 +147,7 @@
"setting.home.cancel_button": "取消", "setting.home.cancel_button": "取消",
"setting.home.confirm_button": "确定", "setting.home.confirm_button": "确定",
"setting.home.no_selected_app": "未选择应用", "setting.home.no_selected_app": "未选择应用",
"setting.home.enable": "启用首页",
"setting.incorrect_plan": "当前套餐不支持该功能,请升级订阅套餐", "setting.incorrect_plan": "当前套餐不支持该功能,请升级订阅套餐",
"setting.incorrect_version": "当前版本不支持该功能", "setting.incorrect_version": "当前版本不支持该功能",
"setting.log_details.title": "首页日志", "setting.log_details.title": "首页日志",
......
...@@ -134,6 +134,7 @@ ...@@ -134,6 +134,7 @@
"setting.home.dialogue_tips": "對話框提示文字", "setting.home.dialogue_tips": "對話框提示文字",
"setting.home.dialogue_tips.default": "你可以問我任何問題", "setting.home.dialogue_tips.default": "你可以問我任何問題",
"setting.home.dialogue_tips_placeholder": "請輸入對話框提示文字", "setting.home.dialogue_tips_placeholder": "請輸入對話框提示文字",
"setting.home.enable": "啟用首頁",
"setting.home.home_tab_title": "首頁標題", "setting.home.home_tab_title": "首頁標題",
"setting.home.home_tab_title_placeholder": "請輸入首頁標題", "setting.home.home_tab_title_placeholder": "請輸入首頁標題",
"setting.home.no_selected_app": "未選擇應用", "setting.home.no_selected_app": "未選擇應用",
......
import { Box, Button, Flex, Grid, IconButton, Input, useDisclosure } from '@chakra-ui/react'; import {
Switch,
Box,
Button,
Flex,
Grid,
IconButton,
Input,
useDisclosure
} from '@chakra-ui/react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import MyInput from '@/components/MyInput'; import MyInput from '@/components/MyInput';
import { useCallback, useState } from 'react'; import { useCallback, useState } from 'react';
...@@ -8,7 +17,6 @@ import { updateChatSetting } from '@/web/core/chat/api'; ...@@ -8,7 +17,6 @@ import { updateChatSetting } from '@/web/core/chat/api';
import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
import ImageUpload from '@/pageComponents/chat/ChatSetting/ImageUpload'; import ImageUpload from '@/pageComponents/chat/ChatSetting/ImageUpload';
import type { import type {
ChatSettingSchema,
ChatSettingUpdateParams, ChatSettingUpdateParams,
QuickAppType, QuickAppType,
SelectedToolType SelectedToolType
...@@ -28,6 +36,7 @@ import { ...@@ -28,6 +36,7 @@ import {
import { useSystem } from '@fastgpt/web/hooks/useSystem'; import { useSystem } from '@fastgpt/web/hooks/useSystem';
import dynamic from 'next/dynamic'; import dynamic from 'next/dynamic';
import type { ChatSettingReturnType } from '@fastgpt/global/core/chat/setting/type'; import type { ChatSettingReturnType } from '@fastgpt/global/core/chat/setting/type';
import MyPopover from '@fastgpt/web/components/common/MyPopover';
const AddQuickAppModal = dynamic( const AddQuickAppModal = dynamic(
() => import('@/pageComponents/chat/ChatSetting/HomepageSetting/AddQuickAppModal') () => import('@/pageComponents/chat/ChatSetting/HomepageSetting/AddQuickAppModal')
...@@ -54,6 +63,7 @@ const HomepageSetting = ({ Header, onDiagramShow }: Props) => { ...@@ -54,6 +63,7 @@ const HomepageSetting = ({ Header, onDiagramShow }: Props) => {
const chatSettings2Form = useCallback( const chatSettings2Form = useCallback(
(data?: ChatSettingReturnType) => { (data?: ChatSettingReturnType) => {
return { return {
enableHome: data?.enableHome,
slogan: data?.slogan || t('chat:setting.home.slogan.default'), slogan: data?.slogan || t('chat:setting.home.slogan.default'),
dialogTips: data?.dialogTips || t('chat:setting.home.dialogue_tips.default'), dialogTips: data?.dialogTips || t('chat:setting.home.dialogue_tips.default'),
homeTabTitle: data?.homeTabTitle || 'FastGPT', homeTabTitle: data?.homeTabTitle || 'FastGPT',
...@@ -168,6 +178,14 @@ const HomepageSetting = ({ Header, onDiagramShow }: Props) => { ...@@ -168,6 +178,14 @@ const HomepageSetting = ({ Header, onDiagramShow }: Props) => {
> >
<Flex w={['100%', '630px']}> <Flex w={['100%', '630px']}>
<Flex flexDir="column" gap={6} w="100%"> <Flex flexDir="column" gap={6} w="100%">
{/* ENABLE HOME */}
<Box fontWeight={'500'}>
<Flex fontWeight={'500'} fontSize="14px" alignItems={'center'} gap={2}>
<Box>{t('chat:setting.home.enable')}</Box>
<Switch size="sm" {...register('enableHome')} />
</Flex>
</Box>
{/* QUICK APPS */} {/* QUICK APPS */}
<Box fontWeight={'500'}> <Box fontWeight={'500'}>
<Flex fontWeight={'500'} fontSize="14px" mb={2} alignItems={'center'} gap={2}> <Flex fontWeight={'500'} fontSize="14px" mb={2} alignItems={'center'} gap={2}>
......
...@@ -190,7 +190,7 @@ const HomeChatWindow = ({ myApps }: Props) => { ...@@ -190,7 +190,7 @@ const HomeChatWindow = ({ myApps }: Props) => {
}; };
useMount(() => { useMount(() => {
if (!feConfigs?.isPlus) { if (!feConfigs?.isPlus || !chatSettings?.enableHome) {
handlePaneChange(ChatSidebarPaneEnum.TEAM_APPS); handlePaneChange(ChatSidebarPaneEnum.TEAM_APPS);
} }
}); });
......
...@@ -255,6 +255,7 @@ const NavigationSection = () => { ...@@ -255,6 +255,7 @@ const NavigationSection = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const { feConfigs } = useSystemStore(); const { feConfigs } = useSystemStore();
const isEnableHome = useContextSelector(ChatSettingContext, (v) => v.chatSettings?.enableHome);
const isCollapsed = useContextSelector(ChatSettingContext, (v) => v.collapse === 1); const isCollapsed = useContextSelector(ChatSettingContext, (v) => v.collapse === 1);
const onTriggerCollapse = useContextSelector(ChatSettingContext, (v) => v.onTriggerCollapse); const onTriggerCollapse = useContextSelector(ChatSettingContext, (v) => v.onTriggerCollapse);
const isHomeActive = useContextSelector( const isHomeActive = useContextSelector(
...@@ -283,12 +284,14 @@ const NavigationSection = () => { ...@@ -283,12 +284,14 @@ const NavigationSection = () => {
<Flex flexDir="column" gap={2}> <Flex flexDir="column" gap={2}>
{feConfigs.isPlus && ( {feConfigs.isPlus && (
<> <>
{isEnableHome && (
<ActionButton <ActionButton
icon="core/chat/sidebar/home" icon="core/chat/sidebar/home"
isCollapsed={true} isCollapsed={true}
isActive={isHomeActive} isActive={isHomeActive}
onClick={() => handlePaneChange(ChatSidebarPaneEnum.HOME)} onClick={() => handlePaneChange(ChatSidebarPaneEnum.HOME)}
/> />
)}
<ActionButton <ActionButton
icon="core/chat/sidebar/star" icon="core/chat/sidebar/star"
...@@ -312,6 +315,7 @@ const NavigationSection = () => { ...@@ -312,6 +315,7 @@ const NavigationSection = () => {
<Flex flexDir="column" gap={2}> <Flex flexDir="column" gap={2}>
{feConfigs.isPlus && ( {feConfigs.isPlus && (
<> <>
{isEnableHome && (
<ActionButton <ActionButton
icon="core/chat/sidebar/home" icon="core/chat/sidebar/home"
text={t('chat:sidebar.home')} text={t('chat:sidebar.home')}
...@@ -319,6 +323,7 @@ const NavigationSection = () => { ...@@ -319,6 +323,7 @@ const NavigationSection = () => {
isActive={isHomeActive} isActive={isHomeActive}
onClick={() => handlePaneChange(ChatSidebarPaneEnum.HOME)} onClick={() => handlePaneChange(ChatSidebarPaneEnum.HOME)}
/> />
)}
<ActionButton <ActionButton
icon="core/chat/sidebar/star" icon="core/chat/sidebar/star"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment