mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-06 17:36:50 +08:00
feat: 增加可选性隐藏功能
- 目前可以隐藏 侧边栏,导航栏,发布按钮
This commit is contained in:
@@ -9,6 +9,7 @@ import DatasetInfo from './dataset-info'
|
|||||||
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
|
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
|
||||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
import { useStore as useAppStore } from '@/app/components/app/store'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
|
import { useSearchParams } from 'next/navigation'
|
||||||
|
|
||||||
export type IAppDetailNavProps = {
|
export type IAppDetailNavProps = {
|
||||||
iconType?: 'app' | 'dataset' | 'notion'
|
iconType?: 'app' | 'dataset' | 'notion'
|
||||||
@@ -46,6 +47,15 @@ const AppDetailNav = ({ title, desc, isExternal, icon, icon_background, navigati
|
|||||||
}
|
}
|
||||||
}, [appSidebarExpand, setAppSiderbarExpand])
|
}, [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 (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`
|
className={`
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
useMergeRefs,
|
useMergeRefs,
|
||||||
useRole,
|
useRole,
|
||||||
} from '@floating-ui/react'
|
} from '@floating-ui/react'
|
||||||
|
import { useSearchParams } from 'next/navigation'
|
||||||
import type { OffsetOptions, Placement } from '@floating-ui/react'
|
import type { OffsetOptions, Placement } from '@floating-ui/react'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
export type PortalToFollowElemOptions = {
|
export type PortalToFollowElemOptions = {
|
||||||
@@ -139,6 +139,12 @@ export const PortalToFollowElemTrigger = (
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检测是否开启 publish 功能
|
||||||
|
const searchParams = useSearchParams()
|
||||||
|
const publishParam = searchParams.get('publish')
|
||||||
|
const showPublish = !publishParam || publishParam === '1'
|
||||||
|
if (!showPublish) return null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import { usePathname } from 'next/navigation'
|
import { usePathname, useSearchParams } from 'next/navigation'
|
||||||
import s from './index.module.css'
|
import s from './index.module.css'
|
||||||
import classNames from '@/utils/classnames'
|
import classNames from '@/utils/classnames'
|
||||||
|
|
||||||
@@ -11,8 +11,16 @@ const HeaderWrapper = ({
|
|||||||
children,
|
children,
|
||||||
}: HeaderWrapperProps) => {
|
}: HeaderWrapperProps) => {
|
||||||
const pathname = usePathname()
|
const pathname = usePathname()
|
||||||
|
const searchParams = useSearchParams()
|
||||||
const isBordered = ['/apps', '/datasets', '/datasets/create', '/tools'].includes(pathname)
|
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 (
|
return (
|
||||||
<div className={classNames(
|
<div className={classNames(
|
||||||
'sticky top-0 left-0 right-0 z-30 flex flex-col grow-0 shrink-0 basis-auto min-h-[56px]',
|
'sticky top-0 left-0 right-0 z-30 flex flex-col grow-0 shrink-0 basis-auto min-h-[56px]',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// export basePath to next.config.js
|
// export basePath to next.config.js
|
||||||
// same as the one exported from var.ts
|
// same as the one exported from var.ts
|
||||||
module.exports = {
|
module.exports = {
|
||||||
basePath: '',
|
basePath: '/dify',
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user