From 9e7197443c403e2c3df66d81739d844835e4788c Mon Sep 17 00:00:00 2001 From: Huangzhe Date: Tue, 22 Apr 2025 20:34:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=8F=AF=E9=80=89?= =?UTF-8?q?=E6=80=A7=E9=9A=90=E8=97=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 目前可以隐藏 侧边栏,导航栏,发布按钮 --- web/app/components/app-sidebar/index.tsx | 12 +++++++++++- .../components/base/portal-to-follow-elem/index.tsx | 8 +++++++- web/app/components/header/header-wrapper.tsx | 10 +++++++++- web/utils/var-basePath.js | 2 +- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/web/app/components/app-sidebar/index.tsx b/web/app/components/app-sidebar/index.tsx index 3276a1c0a..a6b882222 100644 --- a/web/app/components/app-sidebar/index.tsx +++ b/web/app/components/app-sidebar/index.tsx @@ -9,6 +9,7 @@ import DatasetInfo from './dataset-info' import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' import { useStore as useAppStore } from '@/app/components/app/store' import cn from '@/utils/classnames' +import { useSearchParams } from 'next/navigation' export type IAppDetailNavProps = { iconType?: 'app' | 'dataset' | 'notion' @@ -29,7 +30,7 @@ export type IAppDetailNavProps = { const AppDetailNav = ({ title, desc, isExternal, icon, icon_background, navigation, extraInfo, iconType = 'app' }: IAppDetailNavProps) => { const { appSidebarExpand, setAppSiderbarExpand } = useAppStore(useShallow(state => ({ appSidebarExpand: state.appSidebarExpand, - setAppSiderbarExpand: state.setAppSiderbarExpand, + setAppSiderbarExpand: state.setAppSiderbarExpand, }))) const media = useBreakpoints() const isMobile = media === MediaType.mobile @@ -46,6 +47,15 @@ const AppDetailNav = ({ title, desc, isExternal, icon, icon_background, navigati } }, [appSidebarExpand, setAppSiderbarExpand]) + const searchParams = useSearchParams() + + // 从 router 查询参数,若有 sidebar选项,按照参数设置,没有的话,默认是展示内容 + const showSidebar = !(searchParams?.get('sidebar')) || (searchParams?.get('sidebar') === '1') + + // console.log('searchParams?.get("sidebar"): ', searchParams?.get('sidebar'),!(searchParams?.get('sidebar')) , (searchParams?.get('sidebar') === '1')) + // console.log('showSidebar: ', showSidebar) + // 如果showSidebar为false,不显示 + if (!showSidebar) return null; return (
{ const pathname = usePathname() + const searchParams = useSearchParams() const isBordered = ['/apps', '/datasets', '/datasets/create', '/tools'].includes(pathname) + // 当不携带 header 参数时,或者 header 参数为 1 时,显示 header + const headerParam = searchParams.get('header') + const showHeader = !headerParam || headerParam === '1' + + // console.log('headerParam: ', headerParam, !headerParam, (headerParam === '1')) + // console.log('showHeader: ', showHeader) + if (!showHeader) return null return (