chore: plugin icon not show

This commit is contained in:
Joel 2024-10-29 11:57:21 +08:00
parent f2765b9d31
commit e135707f88
2 changed files with 6 additions and 8 deletions

View File

@ -1,10 +1,10 @@
import { fetchIcon } from '@/service/plugins'
import { apiPrefix } from '@/config'
import { fetchWorkspaces } from '@/service/common'
let tenantId: string | null | undefined = null
const useGetIcon = () => {
const getIcon = async (fileName: string) => {
const getIconUrl = async (fileName: string) => {
if (!tenantId) {
const { workspaces } = await fetchWorkspaces({
url: '/workspaces',
@ -12,12 +12,11 @@ const useGetIcon = () => {
})
tenantId = workspaces.find(v => v.current)?.id
}
const res = await fetchIcon(tenantId!, fileName)
return res
return `${apiPrefix}/workspaces/current/plugin/icon?tenant_id=${tenantId}&filename=${fileName}`
}
return {
getIcon,
getIconUrl,
}
}

View File

@ -39,7 +39,7 @@ const InstallFromLocalPackage: React.FC<InstallFromLocalPackageProps> = ({
return t(`${i18nPrefix}.installPlugin`)
}, [step])
const { getIcon } = useGetIcon()
const { getIconUrl } = useGetIcon()
const handleUploaded = useCallback(async (result: {
uniqueIdentifier: string
@ -49,8 +49,7 @@ const InstallFromLocalPackage: React.FC<InstallFromLocalPackageProps> = ({
manifest,
uniqueIdentifier,
} = result
// TODO: wait for api to fix result
const icon: any = await getIcon(manifest!.icon)
const icon = await getIconUrl(manifest!.icon)
setUniqueIdentifier(uniqueIdentifier)
setManifest({
...manifest,