11<script setup lang="ts">
2+ import type { Provider } from ' @/lib/providers'
23import type { APIKey } from ' @/stores'
34import { Edit } from ' lucide-vue-next'
4- import { onMounted , ref } from ' vue'
5+ import { onMounted , ref , shallowRef } from ' vue'
56import { VueDraggable } from ' vue-draggable-plus'
67import { useI18n } from ' vue-i18n'
78import EditKeyDialog from ' @/components/EditKeyDialog.vue'
89import ManualConfigCard from ' @/components/ManualConfigCard.vue'
9- import SiliconFlowConfigDialog from ' @/components/SiliconFlowConfigDialog .vue'
10+ import ProviderConfigDialog from ' @/components/ProviderConfigDialog .vue'
1011import { Badge } from ' @/components/ui/badge'
1112import { Button } from ' @/components/ui/button'
1213import { Card , CardContent , CardFooter , CardHeader , CardTitle } from ' @/components/ui/card'
1314import { Skeleton } from ' @/components/ui/skeleton'
14- import { useKeysStore , useSiliconFlowStore } from ' @/stores'
15+ import { useKeysStore , useProvidersStore } from ' @/stores'
1516
1617const { t } = useI18n ()
1718const keysStore = useKeysStore ()
18- const siliconFlowStore = useSiliconFlowStore ()
19- const showSiliconFlowConfig = ref (false )
19+ const providersStore = useProvidersStore ()
20+
21+ const showProviderDialog = shallowRef <Provider | null >(null )
2022const showEditDialog = ref (false )
2123const editingKey = ref <APIKey | null >(null )
2224
2325function editKey(key : APIKey ) {
24- if (key .type === ' siliconflow ' ) {
25- showSiliconFlowConfig .value = true
26+ if (providersStore . map [ key .type ] ) {
27+ showProviderDialog .value = providersStore . map [ key . type ]
2628 return
2729 }
2830 editingKey .value = key
@@ -36,7 +38,6 @@ function formatUrl(url: string): string {
3638
3739onMounted (() => {
3840 keysStore .loadKeys ()
39- siliconFlowStore .checkLoginStatus ()
4041})
4142 </script >
4243
@@ -65,21 +66,21 @@ onMounted(() => {
6566 <!-- Static cards for configuration (not draggable) -->
6667 <div class =" grid gap-4 grid-cols-2 mb-4" >
6768 <!-- SiliconFlow configuration card (if not configured) -->
68- <Card class =" relative gap-2" >
69+ <Card v-for = " provider in providersStore.list " :key = " provider.id " class =" relative gap-2" >
6970 <CardHeader >
7071 <div class =" flex items-center justify-between" >
7172 <CardTitle class =" text-lg" >
7273 {{ t('siliconFlow') }}
7374 </CardTitle >
74- <div v-show =" !siliconFlowStore.isLoading " class =" flex items-center gap-2" >
75+ <div v-show =" provider.user !== undefined " class =" flex items-center gap-2" >
7576 <span
7677 class =" inline-flex items-center rounded-full px-2 py-1 text-xs font-medium text-accent-foreground"
7778 :class =" {
78- 'bg-emerald-200 dark:bg-green-500/60': siliconFlowStore.isLoggedIn ,
79- 'bg-accent': !siliconFlowStore.isLoggedIn ,
79+ 'bg-emerald-200 dark:bg-green-500/60': !!provider.user ,
80+ 'bg-accent': !provider.user ,
8081 }"
8182 >
82- {{ siliconFlowStore.isLoggedIn ? t('loggedIn') : t('loggedOut') }}
83+ {{ provider.user ? t('loggedIn') : t('loggedOut') }}
8384 </span >
8485 </div >
8586 </div >
@@ -98,7 +99,7 @@ onMounted(() => {
9899 </CardContent >
99100
100101 <CardFooter >
101- <Button class =" w-full" @click =" showSiliconFlowConfig = true " >
102+ <Button class =" w-full" @click =" showProviderDialog = provider " >
102103 {{ t('configureSiliconFlow') }}
103104 </Button >
104105 </CardFooter >
@@ -158,9 +159,10 @@ onMounted(() => {
158159 </VueDraggable >
159160 </div >
160161
161- <!-- Dialog Components -->
162- <SiliconFlowConfigDialog
163- v-model:open =" showSiliconFlowConfig"
162+ <ProviderConfigDialog
163+ v-if =" showProviderDialog != null"
164+ :provider =" showProviderDialog"
165+ @close =" showProviderDialog = null"
164166 />
165167
166168 <EditKeyDialog
0 commit comments