Skip to content

Commit 059fc4f

Browse files
committed
feat: improve models ux
1 parent 7b8b2c7 commit 059fc4f

File tree

9 files changed

+46
-251
lines changed

9 files changed

+46
-251
lines changed

ui/src/components/KeysSection.vue

Lines changed: 0 additions & 206 deletions
This file was deleted.

ui/src/components/ManualConfigCard.vue

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,20 @@
11
<script setup lang="ts">
2-
import type { ManualConfig } from '@/components/ManualConfigDialog.vue'
32
import { ref } from 'vue'
43
import { useI18n } from 'vue-i18n'
5-
import { toast } from 'vue-sonner'
64
import ManualConfigDialog from '@/components/ManualConfigDialog.vue'
75
import { Button } from '@/components/ui/button'
86
import { Card, CardContent, CardFooter, CardHeader, CardTitle } from '@/components/ui/card'
9-
import { useKeysStore } from '@/stores'
107
118
const emit = defineEmits<{
129
configured: [key: string]
1310
}>()
1411
1512
const { t } = useI18n()
16-
const keysStore = useKeysStore()
1713
1814
const showEditDialog = ref(false)
1915
20-
async function handleManualConfigSave(config: ManualConfig) {
21-
const key = await keysStore.addKey({
22-
name: config.name,
23-
type: 'manual',
24-
protocol: config.protocol,
25-
baseUrl: config.baseUrl,
26-
token: config.token,
27-
})
28-
29-
emit('configured', key.id)
30-
showEditDialog.value = false
31-
toast.success(t('success'))
16+
async function handleManualConfigSave(config: string) {
17+
emit('configured', config)
3218
}
3319
</script>
3420

ui/src/components/ManualConfigDialog.vue

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
11
<script setup lang="ts">
22
import { computed, ref, watch } from 'vue'
33
import { useI18n } from 'vue-i18n'
4+
import { toast } from 'vue-sonner'
45
import { Button } from '@/components/ui/button'
56
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'
67
import { Input } from '@/components/ui/input'
7-
8-
export interface ManualConfig {
9-
name: string
10-
protocol: 'openai'
11-
baseUrl: string
12-
token: string
13-
}
8+
import { useKeysStore } from '@/stores'
149
1510
const emit = defineEmits<{
16-
save: [config: ManualConfig]
11+
configured: [id: string]
1712
}>()
1813
const { t } = useI18n()
14+
const keysStore = useKeysStore()
1915
const open = defineModel<boolean>('open')
2016
21-
const config = ref<ManualConfig>({
17+
const config = ref({
2218
name: '',
23-
protocol: 'openai',
2419
baseUrl: '',
2520
token: '',
2621
})
@@ -29,17 +24,25 @@ const isConfigValid = computed(() => {
2924
return config.value.name && config.value.baseUrl && config.value.token
3025
})
3126
32-
function handleSave() {
27+
async function handleSave() {
3328
if (isConfigValid.value) {
34-
emit('save', { ...config.value })
29+
const key = await keysStore.addKey({
30+
name: config.value.name,
31+
type: 'manual',
32+
protocol: 'openai',
33+
baseUrl: config.value.baseUrl,
34+
token: config.value.token,
35+
})
36+
toast.success(t('success'))
37+
emit('configured', key.id)
38+
open.value = false
3539
resetConfig()
3640
}
3741
}
3842
3943
function resetConfig() {
4044
config.value = {
4145
name: '',
42-
protocol: 'openai',
4346
baseUrl: '',
4447
token: '',
4548
}
@@ -113,21 +116,23 @@ watch(open, (newValue) => {
113116
zh-CN:
114117
title: 手动配置 API
115118
description: 请输入您的 API 配置信息
116-
providerName: 提供商名称
119+
providerName: 名称
117120
providerNamePlaceholder: 例如:OpenAI、Claude 等
118121
baseUrl: Base URL
119122
baseUrlPlaceholder: 例如:https://api.openai.com/v1
120123
apiKey: API Key
121124
apiKeyPlaceholder: 输入您的 API Key
122125
save: 保存配置
126+
success: 配置成功
123127
en-US:
124128
title: Manual API Configuration
125129
description: Please enter your API configuration information
126-
providerName: Provider Name
130+
providerName: Name
127131
providerNamePlaceholder: e.g., OpenAI, Claude, etc.
128132
baseUrl: Base URL
129133
baseUrlPlaceholder: e.g., https://api.openai.com/v1
130134
apiKey: API Key
131135
apiKeyPlaceholder: Enter your API Key
132136
save: Save Configuration
137+
success: Configured
133138
</i18n>

ui/src/components/ProviderCard.vue

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { useI18n } from 'vue-i18n'
66
import { toast } from 'vue-sonner'
77
import { Button } from '@/components/ui/button'
88
import { Card, CardContent, CardFooter, CardHeader, CardTitle } from '@/components/ui/card'
9-
import { Skeleton } from '@/components/ui/skeleton'
109
import ProviderPaymentDialog from './ProviderPaymentDialog.vue'
1110
import ProviderRealNameDialog from './ProviderRealNameDialog.vue'
1211
@@ -46,8 +45,7 @@ function handleRecharge() {
4645
</script>
4746

4847
<template>
49-
<Skeleton v-if="userInfo === undefined" class="h-48 w-full max-w-md mx-auto" />
50-
<component :is="provider.Login" v-else-if="userInfo === null" />
48+
<component :is="provider.Login" v-if="userInfo === null" />
5149
<Card v-else>
5250
<CardHeader>
5351
<CardTitle class="flex items-center gap-2">
@@ -63,11 +61,11 @@ function handleRecharge() {
6361
</CardHeader>
6462
<CardContent class="flex-grow">
6563
<div class="space-y-2">
66-
<div v-if="userInfo.name" class="flex justify-between items-center text-sm">
64+
<div v-if="userInfo?.name" class="flex justify-between items-center text-sm">
6765
<span class="text-muted-foreground">{{ t('userName') }}</span>
6866
<span class="font-medium text-ellipsis max-w-24 text-nowrap overflow-hidden" :title="userInfo.name">{{ userInfo.name }}</span>
6967
</div>
70-
<div v-if="userInfo.verified != null" class="flex justify-between items-center text-sm">
68+
<div v-if="userInfo?.verified != null" class="flex justify-between items-center text-sm">
7169
<span class="text-muted-foreground">{{ t('realname') }}</span>
7270
<button
7371
class="font-medium border-b border-dashed border-primary text-primary hover:bg-muted/50 transition-colors"
@@ -76,17 +74,17 @@ function handleRecharge() {
7674
{{ userInfo.verified ? t('verified') : t('unverified') }}
7775
</button>
7876
</div>
79-
<div v-if="userInfo.phone" class="flex justify-between items-center text-sm">
77+
<div v-if="userInfo?.phone" class="flex justify-between items-center text-sm">
8078
<span class="text-muted-foreground">{{ t('phone') }}</span>
8179
<span class="font-medium">{{ userInfo.phone }}</span>
8280
</div>
83-
<div v-if="userInfo.balance != null" class="flex justify-between items-center text-sm">
81+
<div v-if="userInfo?.balance != null" class="flex justify-between items-center text-sm">
8482
<span class="text-muted-foreground">{{ t('balance') }}</span>
8583
<span class="font-medium">
8684
{{ userInfo.balance.currency === 'USD' ? '$' : '' }}{{ userInfo.balance.amount }}
8785
{{ userInfo.balance.currency === 'CNY' ? t('yuan') : userInfo.balance.currency === 'USD' ? '' : `(${userInfo.balance.currency})` }}
8886
</span>
89-
</div>
87+
</div>
9088
</div>
9189
</CardContent>
9290
<CardFooter class="pt-2 flex gap-2">

ui/src/components/ProvidersSection.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ const showProviderDialog = shallowRef<Provider | null>(null)
3939
<CardContent>
4040
<div class="text-sm text-muted-foreground">
4141
<p>
42-
{{ t('description1') }}
43-
<a :href="provider.homepage" target="_blank" class="text-blue-900 dark:text-blue-200 hover:underline" @click.stop>
44-
{{ provider.name }}
45-
</a>
46-
{{ t('description2') }}
42+
{{ provider.description }}
4743
</p>
4844
</div>
4945
</CardContent>

0 commit comments

Comments
 (0)