fix: plugins task (#12662)

This commit is contained in:
zxhlyh 2025-01-13 10:59:34 +08:00 committed by GitHub
parent 51947575c2
commit f0a3c14adb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 14 deletions

View File

@ -12,6 +12,7 @@ const Description = async ({
const localeDefault = getLocaleOnServer()
const { t } = await translate(localeFromProps || localeDefault, 'plugin')
const { t: tCommon } = await translate(localeFromProps || localeDefault, 'common')
const isZhHans = localeFromProps === 'zh-Hans'
return (
<>
@ -19,7 +20,22 @@ const Description = async ({
{t('marketplace.empower')}
</h1>
<h2 className='shrink-0 flex justify-center items-center text-center body-md-regular text-text-tertiary'>
{t('marketplace.discover')}
{
isZhHans && (
<>
<span className='mr-1'>{tCommon('operation.in')}</span>
{t('marketplace.difyMarketplace')}
{t('marketplace.discover')}
</>
)
}
{
!isZhHans && (
<>
{t('marketplace.discover')}
</>
)
}
<span className="relative ml-1 body-md-medium text-text-secondary after:content-[''] after:absolute after:left-0 after:bottom-[1.5px] after:w-full after:h-2 after:bg-text-text-selected z-[1]">
<span className='relative z-[2] lowercase'>{t('category.models')}</span>
</span>
@ -39,8 +55,14 @@ const Description = async ({
<span className="relative ml-1 mr-1 body-md-medium text-text-secondary after:content-[''] after:absolute after:left-0 after:bottom-[1.5px] after:w-full after:h-2 after:bg-text-text-selected z-[1]">
<span className='relative z-[2] lowercase'>{t('category.bundles')}</span>
</span>
<span className='mr-1'>{tCommon('operation.in')}</span>
{t('marketplace.difyMarketplace')}
{
!isZhHans && (
<>
<span className='mr-1'>{tCommon('operation.in')}</span>
{t('marketplace.difyMarketplace')}
</>
)
}
</h2>
</>
)

View File

@ -1,4 +1,4 @@
import { useCallback, useState } from 'react'
import { useCallback } from 'react'
import type {
DebugInfo as DebugInfoTypes,
Dependency,
@ -356,7 +356,6 @@ export const useFetchPluginsInMarketPlaceByInfo = (infos: Record<string, any>[])
const usePluginTaskListKey = [NAME_SPACE, 'pluginTaskList']
export const usePluginTaskList = () => {
const [enabled, setEnabled] = useState(true)
const {
data,
isFetched,
@ -364,20 +363,17 @@ export const usePluginTaskList = () => {
...rest
} = useQuery({
queryKey: usePluginTaskListKey,
queryFn: async () => {
const currentData = await get<{ tasks: PluginTask[] }>('/workspaces/current/plugin/tasks?page=1&page_size=100')
const taskDone = currentData.tasks.every(task => task.status === TaskStatus.success || task.status === TaskStatus.failed)
queryFn: () => get<{ tasks: PluginTask[] }>('/workspaces/current/plugin/tasks?page=1&page_size=100'),
refetchInterval: (lastQuery) => {
const lastData = lastQuery.state.data
const taskDone = lastData?.tasks.every(task => task.status === TaskStatus.success || task.status === TaskStatus.failed)
if (taskDone)
setEnabled(false)
return false
return currentData
return 5000
},
refetchInterval: 5000,
enabled,
})
const handleRefetch = useCallback(() => {
setEnabled(true)
refetch()
}, [refetch])