Merge remote-tracking branch 'origin/main' into feat/model-plugins-implementing

This commit is contained in:
yyh
2026-03-16 13:38:42 +08:00
303 changed files with 5066 additions and 2484 deletions

View File

@ -8,6 +8,10 @@
- In new or modified code, use only overlay primitives from `@/app/components/base/ui/*`.
- Do not introduce deprecated overlay imports from `@/app/components/base/*`; when touching legacy callers, prefer migrating them and keep the allowlist shrinking (never expanding).
## Query & Mutation (Mandatory)
- `frontend-query-mutation` is the source of truth for Dify frontend contracts, query and mutation call-site patterns, conditional queries, invalidation, and mutation error handling.
## Automated Test Generation
- Use `./docs/test.md` as the canonical instruction set for generating frontend automated tests.

View File

@ -1,31 +1,29 @@
import type { QueryKey } from '@tanstack/react-query'
import {
useQueryClient,
} from '@tanstack/react-query'
import { useQueryClient } from '@tanstack/react-query'
import { useCallback } from 'react'
/**
* @deprecated Convenience wrapper scheduled for removal.
* Prefer binding invalidation in `useMutation` callbacks at the service layer.
*/
export const useInvalid = (key?: QueryKey) => {
const queryClient = useQueryClient()
return () => {
return useCallback(() => {
if (!key)
return
queryClient.invalidateQueries(
{
queryKey: key,
},
)
}
queryClient.invalidateQueries({ queryKey: key })
}, [queryClient, key])
}
/**
* @deprecated Convenience wrapper scheduled for removal.
* Prefer binding reset in `useMutation` callbacks at the service layer.
*/
export const useReset = (key?: QueryKey) => {
const queryClient = useQueryClient()
return () => {
return useCallback(() => {
if (!key)
return
queryClient.resetQueries(
{
queryKey: key,
},
)
}
queryClient.resetQueries({ queryKey: key })
}, [queryClient, key])
}