prioritize displaying file types

This commit is contained in:
汐殇 2024-11-27 00:07:50 +08:00
parent ceb89d28c8
commit 2b42f68a30
2 changed files with 19 additions and 7 deletions

View File

@ -47,11 +47,16 @@ const ProxyProvider: React.FC = () => {
const { data, mutate } = useSWR('mihomoProxyProviders', mihomoProxyProviders)
const providers = useMemo(() => {
if (!data) return []
if (!data.providers) return []
return Object.keys(data.providers)
.map((key) => data.providers[key])
.filter((provider) => {
return 'subscriptionInfo' in provider
return Object.values(data.providers)
.filter(provider => 'subscriptionInfo' in provider)
.sort((a, b) => {
if (a.vehicleType === 'File' && b.vehicleType !== 'File') {
return -1
}
if (a.vehicleType !== 'File' && b.vehicleType === 'File') {
return 1
}
return 0
})
}, [data])
const [updating, setUpdating] = useState(Array(providers.length).fill(false))

View File

@ -47,8 +47,15 @@ const RuleProvider: React.FC = () => {
const { data, mutate } = useSWR('mihomoRuleProviders', mihomoRuleProviders)
const providers = useMemo(() => {
if (!data) return []
if (!data.providers) return []
return Object.keys(data.providers).map((key) => data.providers[key])
return Object.values(data.providers).sort((a, b) => {
if (a.vehicleType === 'File' && b.vehicleType !== 'File') {
return -1
}
if (a.vehicleType !== 'File' && b.vehicleType === 'File') {
return 1
}
return 0
})
}, [data])
const [updating, setUpdating] = useState(Array(providers.length).fill(false))