Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor: remove manual set query logic (#31039)

Stephen Zhouab1c5a202737
diff --git a/web/app/components/apps/list.tsx b/web/app/components/apps/list.tsx
index 095ed3f696a..84150ad4809 100644
--- a/web/app/components/apps/list.tsx
+++ b/web/app/components/apps/list.tsx
@@ -12,7 +12,6 @@ import { useDebounceFn } from 'ahooks'
import dynamic from 'next/dynamic'
import {
useRouter,
- useSearchParams,
} from 'next/navigation'
import { parseAsString, useQueryState } from 'nuqs'
import { useCallback, useEffect, useRef, useState } from 'react'
@@ -29,7 +28,6 @@ import { CheckModal } from '@/hooks/use-pay'
import { useInfiniteAppList } from '@/service/use-apps'
import { AppModeEnum } from '@/types/app'
import { cn } from '@/utils/classnames'
-import { isServer } from '@/utils/client'
import AppCard from './app-card'
import { AppCardSkeleton } from './app-card-skeleton'
import Empty from './empty'
@@ -59,7 +57,6 @@ const List = () => {
const { t } = useTranslation()
const { systemFeatures } = useGlobalPublicStore()
const router = useRouter()
- const searchParams = useSearchParams()
const { isCurrentWorkspaceEditor, isCurrentWorkspaceDatasetOperator, isLoadingCurrentWorkspace } = useAppContext()
const showTagManagementModal = useTagStore(s => s.showTagManagementModal)
const [activeTab, setActiveTab] = useQueryState(
@@ -67,33 +64,6 @@ const List = () => {
parseAsString.withDefault('all').withOptions({ history: 'push' }),
)
- // valid tabs for apps list; anything else should fallback to 'all'
-
- // 1) Normalize legacy/incorrect query params like ?mode=discover -> ?category=all
- useEffect(() => {
- // avoid running on server
- if (isServer)
- return
- const mode = searchParams.get('mode')
- if (!mode)
- return
- const url = new URL(window.location.href)
- url.searchParams.delete('mode')
- if (validTabs.has(mode)) {
- // migrate to category key
- url.searchParams.set('category', mode)
- }
- else {
- url.searchParams.set('category', 'all')
- }
- router.replace(url.pathname + url.search)
- }, [router, searchParams])
-
- // 2) If category has an invalid value (e.g., 'discover'), reset to 'all'
- useEffect(() => {
- if (!validTabs.has(activeTab))
- setActiveTab('all')
- }, [activeTab, setActiveTab])
const { query: { tagIDs = [], keywords = '', isCreatedByMe: queryIsCreatedByMe = false }, setQuery } = useAppsQueryState()
const [isCreatedByMe, setIsCreatedByMe] = useState(queryIsCreatedByMe)
const [tagFilterValue, setTagFilterValue] = useState<string[]>(tagIDs)
diff --git a/web/app/components/header/nav/index.tsx b/web/app/components/header/nav/index.tsx
index 83e75b85135..2edc64486ee 100644
--- a/web/app/components/header/nav/index.tsx
+++ b/web/app/components/header/nav/index.tsx
@@ -2,9 +2,9 @@
import type { INavSelectorProps } from './nav-selector'
import Link from 'next/link'
-import { usePathname, useSearchParams, useSelectedLayoutSegment } from 'next/navigation'
+import { useSelectedLayoutSegment } from 'next/navigation'
import * as React from 'react'
-import { useEffect, useState } from 'react'
+import { useState } from 'react'
import { useStore as useAppStore } from '@/app/components/app/store'
import { ArrowNarrowLeft } from '@/app/components/base/icons/src/vender/line/arrows'
import { cn } from '@/utils/classnames'
@@ -36,14 +36,6 @@ const Nav = ({
const [hovered, setHovered] = useState(false)
const segment = useSelectedLayoutSegment()
const isActivated = Array.isArray(activeSegment) ? activeSegment.includes(segment!) : segment === activeSegment
- const pathname = usePathname()
- const searchParams = useSearchParams()
- const [linkLastSearchParams, setLinkLastSearchParams] = useState('')
-
- useEffect(() => {
- if (pathname === link)
- setLinkLastSearchParams(searchParams.toString())
- }, [pathname, searchParams])
return (
<div className={`
@@ -52,7 +44,7 @@ const Nav = ({
${!curNav && !isActivated && 'hover:bg-components-main-nav-nav-button-bg-hover'}
`}
>
- <Link href={link + (linkLastSearchParams && `?${linkLastSearchParams}`)}>
+ <Link href={link}>
<div
onClick={(e) => {
// Don't clear state if opening in new tab/window