dify/web/app/components/plugins/install-plugin/base/use-get-icon.ts
2024-10-29 11:47:23 +08:00

25 lines
541 B
TypeScript

import { fetchIcon } from '@/service/plugins'
import { fetchWorkspaces } from '@/service/common'
let tenantId: string | null | undefined = null
const useGetIcon = () => {
const getIcon = async (fileName: string) => {
if (!tenantId) {
const { workspaces } = await fetchWorkspaces({
url: '/workspaces',
params: {},
})
tenantId = workspaces.find(v => v.current)?.id
}
const res = await fetchIcon(tenantId!, fileName)
return res
}
return {
getIcon,
}
}
export default useGetIcon