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

This commit is contained in:
伍闲犬
2025-08-26 12:00:18 +08:00
committed by GitHub
parent 3b25bf57c4
commit 3c2bf20666
8 changed files with 47 additions and 16 deletions

View File

@@ -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;

View File

@@ -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: {

View File

@@ -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",

View File

@@ -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": "首页日志",

View File

@@ -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": "未選擇應用",

View File

@@ -1,4 +1,13 @@
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';
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 {
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) => {
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) => {
> >
<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}>

View File

@@ -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);
} }
}); });

View File

@@ -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 = () => {
<Flex flexDir="column" gap={2}> <Flex flexDir="column" gap={2}>
{feConfigs.isPlus && ( {feConfigs.isPlus && (
<> <>
<ActionButton {isEnableHome && (
icon="core/chat/sidebar/home" <ActionButton
isCollapsed={true} icon="core/chat/sidebar/home"
isActive={isHomeActive} isCollapsed={true}
onClick={() => handlePaneChange(ChatSidebarPaneEnum.HOME)} isActive={isHomeActive}
/> onClick={() => handlePaneChange(ChatSidebarPaneEnum.HOME)}
/>
)}
<ActionButton <ActionButton
icon="core/chat/sidebar/star" icon="core/chat/sidebar/star"
@@ -312,13 +315,15 @@ const NavigationSection = () => {
<Flex flexDir="column" gap={2}> <Flex flexDir="column" gap={2}>
{feConfigs.isPlus && ( {feConfigs.isPlus && (
<> <>
<ActionButton {isEnableHome && (
icon="core/chat/sidebar/home" <ActionButton
text={t('chat:sidebar.home')} icon="core/chat/sidebar/home"
isCollapsed={false} text={t('chat:sidebar.home')}
isActive={isHomeActive} isCollapsed={false}
onClick={() => handlePaneChange(ChatSidebarPaneEnum.HOME)} isActive={isHomeActive}
/> onClick={() => handlePaneChange(ChatSidebarPaneEnum.HOME)}
/>
)}
<ActionButton <ActionButton
icon="core/chat/sidebar/star" icon="core/chat/sidebar/star"