|
| 1 | +<script setup lang="ts"> |
| 2 | +import type { Provider } from '@/lib/providers' |
| 3 | +import { shallowRef } from 'vue' |
| 4 | +import { useI18n } from 'vue-i18n' |
| 5 | +import ManualConfigCard from '@/components/ManualConfigCard.vue' |
| 6 | +import ProviderConfigDialog from '@/components/ProviderConfigDialog.vue' |
| 7 | +import { Button } from '@/components/ui/button' |
| 8 | +import { Card, CardContent, CardFooter, CardHeader, CardTitle } from '@/components/ui/card' |
| 9 | +import { useProviders } from '@/lib/providers' |
| 10 | +
|
| 11 | +const { t } = useI18n() |
| 12 | +const providers = useProviders() |
| 13 | +
|
| 14 | +const showProviderDialog = shallowRef<Provider | null>(null) |
| 15 | +</script> |
| 16 | + |
| 17 | +<template> |
| 18 | + <div class="space-y-6 flex-grow flex flex-col min-h-100"> |
| 19 | + <div class="flex items-center justify-between"> |
| 20 | + <h2 class="text-2xl font-bold"> |
| 21 | + {{ t('title') }} |
| 22 | + </h2> |
| 23 | + </div> |
| 24 | + |
| 25 | + <div class="flex-grow flex flex-col"> |
| 26 | + <!-- Static cards for configuration (not draggable) --> |
| 27 | + <div class="grid gap-4 grid-cols-2 lg:grid-cols-3 mb-4"> |
| 28 | + <!-- SiliconFlow configuration card (if not configured) --> |
| 29 | + <Card v-for="provider in providers" :key="provider.id" class="relative gap-2"> |
| 30 | + <CardHeader> |
| 31 | + <div class="flex items-center justify-between"> |
| 32 | + <CardTitle class="text-lg"> |
| 33 | + {{ provider.name }} |
| 34 | + </CardTitle> |
| 35 | + <div v-show="provider.user !== undefined" class="flex items-center gap-2"> |
| 36 | + <span |
| 37 | + class="inline-flex items-center rounded-full px-2 py-1 text-xs font-medium text-accent-foreground" |
| 38 | + :class="{ |
| 39 | + 'bg-emerald-200 dark:bg-green-500/60': !!provider.user, |
| 40 | + 'bg-accent': !provider.user, |
| 41 | + }" |
| 42 | + > |
| 43 | + {{ provider.user ? t('loggedIn') : t('loggedOut') }} |
| 44 | + </span> |
| 45 | + </div> |
| 46 | + </div> |
| 47 | + </CardHeader> |
| 48 | + |
| 49 | + <CardContent> |
| 50 | + <div class="text-sm text-muted-foreground"> |
| 51 | + <p> |
| 52 | + {{ t('description1') }} |
| 53 | + <a :href="provider.homepage" target="_blank" class="text-blue-900 dark:text-blue-200 hover:underline"> |
| 54 | + {{ provider.name }} |
| 55 | + </a> |
| 56 | + {{ t('description2') }} |
| 57 | + </p> |
| 58 | + </div> |
| 59 | + </CardContent> |
| 60 | + |
| 61 | + <CardFooter> |
| 62 | + <Button class="w-full" @click="showProviderDialog = provider"> |
| 63 | + {{ t('configure', [provider.name]) }} |
| 64 | + </Button> |
| 65 | + </CardFooter> |
| 66 | + </Card> |
| 67 | + |
| 68 | + <!-- Manual Configuration Provider Card --> |
| 69 | + <ManualConfigCard class="relative gap-2" /> |
| 70 | + </div> |
| 71 | + </div> |
| 72 | + |
| 73 | + <ProviderConfigDialog |
| 74 | + v-if="showProviderDialog != null" |
| 75 | + :provider="showProviderDialog" |
| 76 | + @close="showProviderDialog = null" |
| 77 | + /> |
| 78 | + </div> |
| 79 | +</template> |
| 80 | + |
| 81 | +<i18n lang="yaml"> |
| 82 | +zh-CN: |
| 83 | + title: 模型供应商 |
| 84 | + loadFailed: 加载失败 |
| 85 | + description1: 通过 |
| 86 | + description2: 购买和配置 API |
| 87 | + loggedIn: 已登录 |
| 88 | + loggedOut: 未登录 |
| 89 | + configure: 配置 {0} |
| 90 | +
|
| 91 | +en-US: |
| 92 | + title: Model Providers |
| 93 | + loadFailed: Failed to load |
| 94 | + description1: Purchase and configure API through |
| 95 | + description2: '' |
| 96 | + loggedIn: Logged In |
| 97 | + loggedOut: Logged Out |
| 98 | + configure: Configure {0} |
| 99 | +</i18n> |
0 commit comments