mirror of
https://github.com/langgenius/dify.git
synced 2026-05-10 14:14:17 +08:00
chore: struct to wrap with content
This commit is contained in:
parent
021f055c36
commit
245567118c
@ -1,6 +1,5 @@
|
||||
import type {
|
||||
AppAssetDeleteResponse,
|
||||
AppAssetFileContentResponse,
|
||||
AppAssetFileDownloadUrlResponse,
|
||||
AppAssetNode,
|
||||
AppAssetPublishResponse,
|
||||
@ -9,7 +8,6 @@ import type {
|
||||
MoveNodePayload,
|
||||
RenameNodePayload,
|
||||
ReorderNodePayload,
|
||||
UpdateFileContentPayload,
|
||||
} from '@/types/app-asset'
|
||||
import { type } from '@orpc/contract'
|
||||
import { base } from '../base'
|
||||
@ -53,7 +51,7 @@ export const getFileContentContract = base
|
||||
.input(type<{
|
||||
params: { appId: string, nodeId: string }
|
||||
}>())
|
||||
.output(type<AppAssetFileContentResponse>())
|
||||
.output(type<{ content: string }>())
|
||||
|
||||
export const getFileDownloadUrlContract = base
|
||||
.route({
|
||||
@ -72,7 +70,7 @@ export const updateFileContentContract = base
|
||||
})
|
||||
.input(type<{
|
||||
params: { appId: string, nodeId: string }
|
||||
body: UpdateFileContentPayload
|
||||
body: { content: string }
|
||||
}>())
|
||||
.output(type<AppAssetNode>())
|
||||
|
||||
|
||||
@ -100,6 +100,17 @@ export const useGetAppAssetFileContent = (appId: string, nodeId: string) => {
|
||||
return useQuery({
|
||||
queryKey: consoleQuery.appAsset.getFileContent.queryKey({ input: { params: { appId, nodeId } } }),
|
||||
queryFn: () => consoleClient.appAsset.getFileContent({ params: { appId, nodeId } }),
|
||||
select: (data) => {
|
||||
try {
|
||||
const result = JSON.parse(data.content)
|
||||
return result
|
||||
}
|
||||
catch {
|
||||
return {
|
||||
content: '',
|
||||
}
|
||||
}
|
||||
},
|
||||
enabled: !!appId && !!nodeId,
|
||||
})
|
||||
}
|
||||
@ -127,7 +138,7 @@ export const useUpdateAppAssetFileContent = () => {
|
||||
}) => {
|
||||
return consoleClient.appAsset.updateFileContent({
|
||||
params: { appId, nodeId },
|
||||
body: payload,
|
||||
body: { content: JSON.stringify(payload) },
|
||||
})
|
||||
},
|
||||
onSuccess: (_, variables) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user