mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
feat(providers): provider 摘要列表排序增加启用状态优先
后端查询和前端展示均按 is_active 降序、priority 升序、created_at 升序排列, 确保已启用的 provider 始终排在前面。
This commit is contained in:
@@ -154,7 +154,7 @@
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<ProviderTableRow
|
||||
v-for="provider in providers"
|
||||
v-for="provider in displayedProviders"
|
||||
:key="provider.id"
|
||||
:provider="provider"
|
||||
:editing-description-id="editingDescriptionId"
|
||||
@@ -189,7 +189,7 @@
|
||||
class="xl:hidden divide-y divide-border/40"
|
||||
>
|
||||
<ProviderMobileCard
|
||||
v-for="provider in providers"
|
||||
v-for="provider in displayedProviders"
|
||||
:key="provider.id"
|
||||
:provider="provider"
|
||||
:editing-description-id="editingDescriptionId"
|
||||
@@ -468,6 +468,20 @@ const opsConfigProviderWebsite = ref('')
|
||||
// 内联编辑备注
|
||||
const editingDescriptionId = ref<string | null>(null)
|
||||
|
||||
function sortProvidersByActiveAndPriority(items: ProviderWithEndpointsSummary[]) {
|
||||
return [...items].sort((a, b) => {
|
||||
if (a.is_active !== b.is_active) {
|
||||
return a.is_active ? -1 : 1
|
||||
}
|
||||
if (a.provider_priority !== b.provider_priority) {
|
||||
return a.provider_priority - b.provider_priority
|
||||
}
|
||||
return new Date(a.created_at).getTime() - new Date(b.created_at).getTime()
|
||||
})
|
||||
}
|
||||
|
||||
const displayedProviders = computed(() => sortProvidersByActiveAndPriority(providers.value))
|
||||
|
||||
function startEditDescription(_event: Event, provider: ProviderWithEndpointsSummary) {
|
||||
editingDescriptionId.value = provider.id
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user