feat: show downgrade warning logic

This commit is contained in:
Joel
2025-06-24 11:21:57 +08:00
parent 825fbcc6f8
commit 7ec5816513
2 changed files with 20 additions and 2 deletions

View File

@ -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'>