feat: plugin auto upgrade strategy (#19758)
Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: crazywoola <427733928@qq.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Novice <novice12185727@gmail.com>
This commit is contained in:

committed by
GitHub

parent
e6913744ae
commit
eaae79a581
@@ -15,6 +15,7 @@ import type {
|
||||
import { useVersionListOfPlugin } from '@/service/use-plugins'
|
||||
import useTimestamp from '@/hooks/use-timestamp'
|
||||
import cn from '@/utils/classnames'
|
||||
import { lt } from 'semver'
|
||||
|
||||
type Props = {
|
||||
disabled?: boolean
|
||||
@@ -28,9 +29,11 @@ type Props = {
|
||||
onSelect: ({
|
||||
version,
|
||||
unique_identifier,
|
||||
isDowngrade,
|
||||
}: {
|
||||
version: string
|
||||
unique_identifier: string
|
||||
isDowngrade: boolean
|
||||
}) => void
|
||||
}
|
||||
|
||||
@@ -59,13 +62,14 @@ const PluginVersionPicker: FC<Props> = ({
|
||||
|
||||
const { data: res } = useVersionListOfPlugin(pluginID)
|
||||
|
||||
const handleSelect = useCallback(({ version, unique_identifier }: {
|
||||
const handleSelect = useCallback(({ version, unique_identifier, isDowngrade }: {
|
||||
version: string
|
||||
unique_identifier: string
|
||||
isDowngrade: boolean
|
||||
}) => {
|
||||
if (currentVersion === version)
|
||||
return
|
||||
onSelect({ version, unique_identifier })
|
||||
onSelect({ version, unique_identifier, isDowngrade })
|
||||
onShowChange(false)
|
||||
}, [currentVersion, onSelect, onShowChange])
|
||||
|
||||
@@ -99,6 +103,7 @@ const PluginVersionPicker: FC<Props> = ({
|
||||
onClick={() => handleSelect({
|
||||
version: version.version,
|
||||
unique_identifier: version.unique_identifier,
|
||||
isDowngrade: lt(version.version, currentVersion),
|
||||
})}
|
||||
>
|
||||
<div className='flex grow items-center'>
|
||||
|
Reference in New Issue
Block a user