mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 18:19:17 +00:00
feat: 支持Gemini-Api接入
This commit is contained in:
@@ -128,7 +128,9 @@
|
||||
? 'OpenAI 专属账号'
|
||||
: platform === 'droid'
|
||||
? 'Droid 专属账号'
|
||||
: 'OAuth 专属账号'
|
||||
: platform === 'gemini'
|
||||
? 'Gemini OAuth 专属账号'
|
||||
: 'OAuth 专属账号'
|
||||
}}
|
||||
</div>
|
||||
<div
|
||||
@@ -239,6 +241,45 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Gemini-API 账号(仅 Gemini) -->
|
||||
<div v-if="platform === 'gemini' && filteredGeminiApiAccounts.length > 0">
|
||||
<div
|
||||
class="bg-gray-50 px-4 py-2 text-xs font-semibold text-gray-500 dark:bg-gray-700 dark:text-gray-400"
|
||||
>
|
||||
Gemini-API 专属账号
|
||||
</div>
|
||||
<div
|
||||
v-for="account in filteredGeminiApiAccounts"
|
||||
:key="account.id"
|
||||
class="cursor-pointer px-4 py-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-700"
|
||||
:class="{
|
||||
'bg-blue-50 dark:bg-blue-900/20': modelValue === `api:${account.id}`
|
||||
}"
|
||||
@click="selectAccount(`api:${account.id}`)"
|
||||
>
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<span class="text-gray-700 dark:text-gray-300">{{ account.name }}</span>
|
||||
<span
|
||||
class="ml-2 rounded-full px-2 py-0.5 text-xs"
|
||||
:class="
|
||||
account.isActive === 'true' || account.isActive === true
|
||||
? 'bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400'
|
||||
: account.status === 'rate_limited'
|
||||
? 'bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400'
|
||||
: 'bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400'
|
||||
"
|
||||
>
|
||||
{{ getAccountStatusText(account) }}
|
||||
</span>
|
||||
</div>
|
||||
<span class="text-xs text-gray-400 dark:text-gray-500">
|
||||
{{ formatDate(account.createdAt) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 无搜索结果 -->
|
||||
<div
|
||||
v-if="searchQuery && !hasResults"
|
||||
@@ -341,6 +382,13 @@ const selectedLabel = computed(() => {
|
||||
return account ? `${account.name} (${getAccountStatusText(account)})` : ''
|
||||
}
|
||||
|
||||
// Gemini-API 账号
|
||||
if (props.modelValue.startsWith('api:')) {
|
||||
const accountId = props.modelValue.substring(4)
|
||||
const account = props.accounts.find((a) => a.id === accountId && a.platform === 'gemini-api')
|
||||
return account ? `${account.name} (${getAccountStatusText(account)})` : ''
|
||||
}
|
||||
|
||||
// OAuth 账号
|
||||
const account = props.accounts.find((a) => a.id === props.modelValue)
|
||||
return account ? `${account.name} (${getAccountStatusText(account)})` : ''
|
||||
@@ -421,10 +469,14 @@ const filteredOAuthAccounts = computed(() => {
|
||||
accounts = sortedAccounts.value.filter((a) => a.platform === 'openai')
|
||||
} else if (props.platform === 'droid') {
|
||||
accounts = sortedAccounts.value.filter((a) => a.platform === 'droid')
|
||||
} else if (props.platform === 'gemini') {
|
||||
// 对于 Gemini,只显示 OAuth 类型的账号(排除 gemini-api)
|
||||
accounts = sortedAccounts.value.filter((a) => a.platform === 'gemini')
|
||||
} else {
|
||||
// 其他平台显示所有非特殊类型的账号
|
||||
accounts = sortedAccounts.value.filter(
|
||||
(a) => !['claude-oauth', 'claude-console', 'openai-responses'].includes(a.platform)
|
||||
(a) =>
|
||||
!['claude-oauth', 'claude-console', 'openai-responses', 'gemini-api'].includes(a.platform)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -464,13 +516,28 @@ const filteredOpenAIResponsesAccounts = computed(() => {
|
||||
return accounts
|
||||
})
|
||||
|
||||
// 过滤的 Gemini-API 账号
|
||||
const filteredGeminiApiAccounts = computed(() => {
|
||||
if (props.platform !== 'gemini') return []
|
||||
|
||||
let accounts = sortedAccounts.value.filter((a) => a.platform === 'gemini-api')
|
||||
|
||||
if (searchQuery.value) {
|
||||
const query = searchQuery.value.toLowerCase()
|
||||
accounts = accounts.filter((account) => account.name.toLowerCase().includes(query))
|
||||
}
|
||||
|
||||
return accounts
|
||||
})
|
||||
|
||||
// 是否有搜索结果
|
||||
const hasResults = computed(() => {
|
||||
return (
|
||||
filteredGroups.value.length > 0 ||
|
||||
filteredOAuthAccounts.value.length > 0 ||
|
||||
filteredConsoleAccounts.value.length > 0 ||
|
||||
filteredOpenAIResponsesAccounts.value.length > 0
|
||||
filteredOpenAIResponsesAccounts.value.length > 0 ||
|
||||
filteredGeminiApiAccounts.value.length > 0
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user