mirror of
https://github.com/langgenius/dify.git
synced 2026-05-13 08:57:28 +08:00
fix(skill): use nuqs query state for fileId param
This commit is contained in:
parent
d3b32645f4
commit
287c1bbc35
@ -1,6 +1,6 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useSearchParams } from 'next/navigation'
|
import { parseAsString, useQueryState } from 'nuqs'
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
import { useStore as useAppStore } from '@/app/components/app/store'
|
||||||
import { useStore, useWorkflowStore } from '@/app/components/workflow/store'
|
import { useStore, useWorkflowStore } from '@/app/components/workflow/store'
|
||||||
@ -33,17 +33,16 @@ const ContentRouter = () => {
|
|||||||
const SkillMain = () => {
|
const SkillMain = () => {
|
||||||
const appDetail = useAppStore(s => s.appDetail)
|
const appDetail = useAppStore(s => s.appDetail)
|
||||||
const appId = appDetail?.id || ''
|
const appId = appDetail?.id || ''
|
||||||
const searchParams = useSearchParams()
|
const [queryFileId] = useQueryState('fileId', parseAsString)
|
||||||
const storeApi = useWorkflowStore()
|
const storeApi = useWorkflowStore()
|
||||||
const openedFileRef = React.useRef<string | null>(null)
|
const openedFileRef = React.useRef<string | null>(null)
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const fileId = searchParams.get('fileId')
|
if (!queryFileId || openedFileRef.current === queryFileId)
|
||||||
if (!fileId || openedFileRef.current === fileId)
|
|
||||||
return
|
return
|
||||||
openedFileRef.current = fileId
|
openedFileRef.current = queryFileId
|
||||||
storeApi.getState().openTab(fileId, { pinned: true })
|
storeApi.getState().openTab(queryFileId, { pinned: true })
|
||||||
}, [searchParams, storeApi])
|
}, [queryFileId, storeApi])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full bg-workflow-canvas-workflow-top-bar-1 pl-3 pt-[52px]">
|
<div className="h-full bg-workflow-canvas-workflow-top-bar-1 pl-3 pt-[52px]">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user