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;
slogan: string;
dialogTips: string;
enableHome: boolean;
homeTabTitle: string;
wideLogoUrl?: string;
squareLogoUrl?: string;

View File

@@ -18,6 +18,10 @@ const ChatSettingSchema = new Schema({
ref: AppCollectionName,
required: true
},
enableHome: {
type: Boolean,
default: true
},
slogan: String,
dialogTips: String,
selectedTools: {

View File

@@ -135,6 +135,7 @@
"setting.home.dialogue_tips": "Dialog prompt text",
"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.enable": "Enable home page",
"setting.home.home_tab_title": "Home Page Title",
"setting.home.home_tab_title_placeholder": "Please enter the title of the homepage",
"setting.home.no_selected_app": "No selected App",

View File

@@ -147,6 +147,7 @@
"setting.home.cancel_button": "取消",
"setting.home.confirm_button": "确定",
"setting.home.no_selected_app": "未选择应用",
"setting.home.enable": "启用首页",
"setting.incorrect_plan": "当前套餐不支持该功能,请升级订阅套餐",
"setting.incorrect_version": "当前版本不支持该功能",
"setting.log_details.title": "首页日志",

View File

@@ -134,6 +134,7 @@
"setting.home.dialogue_tips": "對話框提示文字",
"setting.home.dialogue_tips.default": "你可以問我任何問題",
"setting.home.dialogue_tips_placeholder": "請輸入對話框提示文字",
"setting.home.enable": "啟用首頁",
"setting.home.home_tab_title": "首頁標題",
"setting.home.home_tab_title_placeholder": "請輸入首頁標題",
"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 MyInput from '@/components/MyInput';
import { useCallback, useState } from 'react';
@@ -8,7 +17,6 @@ import { updateChatSetting } from '@/web/core/chat/api';
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
import ImageUpload from '@/pageComponents/chat/ChatSetting/ImageUpload';
import type {
ChatSettingSchema,
ChatSettingUpdateParams,
QuickAppType,
SelectedToolType
@@ -28,6 +36,7 @@ import {
import { useSystem } from '@fastgpt/web/hooks/useSystem';
import dynamic from 'next/dynamic';
import type { ChatSettingReturnType } from '@fastgpt/global/core/chat/setting/type';
import MyPopover from '@fastgpt/web/components/common/MyPopover';
const AddQuickAppModal = dynamic(
() => import('@/pageComponents/chat/ChatSetting/HomepageSetting/AddQuickAppModal')
@@ -54,6 +63,7 @@ const HomepageSetting = ({ Header, onDiagramShow }: Props) => {
const chatSettings2Form = useCallback(
(data?: ChatSettingReturnType) => {
return {
enableHome: data?.enableHome,
slogan: data?.slogan || t('chat:setting.home.slogan.default'),
dialogTips: data?.dialogTips || t('chat:setting.home.dialogue_tips.default'),
homeTabTitle: data?.homeTabTitle || 'FastGPT',
@@ -168,6 +178,14 @@ const HomepageSetting = ({ Header, onDiagramShow }: Props) => {
>
<Flex w={['100%', '630px']}>
<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 */}
<Box fontWeight={'500'}>
<Flex fontWeight={'500'} fontSize="14px" mb={2} alignItems={'center'} gap={2}>

View File

@@ -190,7 +190,7 @@ const HomeChatWindow = ({ myApps }: Props) => {
};
useMount(() => {
if (!feConfigs?.isPlus) {
if (!feConfigs?.isPlus || !chatSettings?.enableHome) {
handlePaneChange(ChatSidebarPaneEnum.TEAM_APPS);
}
});

View File

@@ -255,6 +255,7 @@ const NavigationSection = () => {
const { t } = useTranslation();
const { feConfigs } = useSystemStore();
const isEnableHome = useContextSelector(ChatSettingContext, (v) => v.chatSettings?.enableHome);
const isCollapsed = useContextSelector(ChatSettingContext, (v) => v.collapse === 1);
const onTriggerCollapse = useContextSelector(ChatSettingContext, (v) => v.onTriggerCollapse);
const isHomeActive = useContextSelector(
@@ -283,12 +284,14 @@ const NavigationSection = () => {
<Flex flexDir="column" gap={2}>
{feConfigs.isPlus && (
<>
{isEnableHome && (
<ActionButton
icon="core/chat/sidebar/home"
isCollapsed={true}
isActive={isHomeActive}
onClick={() => handlePaneChange(ChatSidebarPaneEnum.HOME)}
/>
)}
<ActionButton
icon="core/chat/sidebar/star"
@@ -312,6 +315,7 @@ const NavigationSection = () => {
<Flex flexDir="column" gap={2}>
{feConfigs.isPlus && (
<>
{isEnableHome && (
<ActionButton
icon="core/chat/sidebar/home"
text={t('chat:sidebar.home')}
@@ -319,6 +323,7 @@ const NavigationSection = () => {
isActive={isHomeActive}
onClick={() => handlePaneChange(ChatSidebarPaneEnum.HOME)}
/>
)}
<ActionButton
icon="core/chat/sidebar/star"