mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 09:38:02 +00:00
feat: 新增支持Azure OpenAI账户
This commit is contained in:
@@ -9,6 +9,7 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
const bedrockAccounts = ref([])
|
||||
const geminiAccounts = ref([])
|
||||
const openaiAccounts = ref([])
|
||||
const azureOpenaiAccounts = ref([])
|
||||
const loading = ref(false)
|
||||
const error = ref(null)
|
||||
const sortBy = ref('')
|
||||
@@ -111,6 +112,25 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取Azure OpenAI账户列表
|
||||
const fetchAzureOpenAIAccounts = async () => {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const response = await apiClient.get('/admin/azure-openai-accounts')
|
||||
if (response.success) {
|
||||
azureOpenaiAccounts.value = response.data || []
|
||||
} else {
|
||||
throw new Error(response.message || '获取Azure OpenAI账户失败')
|
||||
}
|
||||
} catch (err) {
|
||||
error.value = err.message
|
||||
throw err
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 获取所有账户
|
||||
const fetchAllAccounts = async () => {
|
||||
loading.value = true
|
||||
@@ -121,7 +141,8 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
fetchClaudeConsoleAccounts(),
|
||||
fetchBedrockAccounts(),
|
||||
fetchGeminiAccounts(),
|
||||
fetchOpenAIAccounts()
|
||||
fetchOpenAIAccounts(),
|
||||
fetchAzureOpenAIAccounts()
|
||||
])
|
||||
} catch (err) {
|
||||
error.value = err.message
|
||||
@@ -231,6 +252,26 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 创建Azure OpenAI账户
|
||||
const createAzureOpenAIAccount = async (data) => {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const response = await apiClient.post('/admin/azure-openai-accounts', data)
|
||||
if (response.success) {
|
||||
await fetchAzureOpenAIAccounts()
|
||||
return response.data
|
||||
} else {
|
||||
throw new Error(response.message || '创建Azure OpenAI账户失败')
|
||||
}
|
||||
} catch (err) {
|
||||
error.value = err.message
|
||||
throw err
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 更新Claude账户
|
||||
const updateClaudeAccount = async (id, data) => {
|
||||
loading.value = true
|
||||
@@ -331,6 +372,26 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 更新Azure OpenAI账户
|
||||
const updateAzureOpenAIAccount = async (id, data) => {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const response = await apiClient.put(`/admin/azure-openai-accounts/${id}`, data)
|
||||
if (response.success) {
|
||||
await fetchAzureOpenAIAccounts()
|
||||
return response
|
||||
} else {
|
||||
throw new Error(response.message || '更新Azure OpenAI账户失败')
|
||||
}
|
||||
} catch (err) {
|
||||
error.value = err.message
|
||||
throw err
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 切换账户状态
|
||||
const toggleAccount = async (platform, id) => {
|
||||
loading.value = true
|
||||
@@ -345,6 +406,10 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
endpoint = `/admin/bedrock-accounts/${id}/toggle`
|
||||
} else if (platform === 'gemini') {
|
||||
endpoint = `/admin/gemini-accounts/${id}/toggle`
|
||||
} else if (platform === 'openai') {
|
||||
endpoint = `/admin/openai-accounts/${id}/toggle`
|
||||
} else if (platform === 'azure_openai') {
|
||||
endpoint = `/admin/azure-openai-accounts/${id}/toggle`
|
||||
} else {
|
||||
endpoint = `/admin/openai-accounts/${id}/toggle`
|
||||
}
|
||||
@@ -359,6 +424,10 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
await fetchBedrockAccounts()
|
||||
} else if (platform === 'gemini') {
|
||||
await fetchGeminiAccounts()
|
||||
} else if (platform === 'openai') {
|
||||
await fetchOpenAIAccounts()
|
||||
} else if (platform === 'azure_openai') {
|
||||
await fetchAzureOpenAIAccounts()
|
||||
} else {
|
||||
await fetchOpenAIAccounts()
|
||||
}
|
||||
@@ -388,6 +457,10 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
endpoint = `/admin/bedrock-accounts/${id}`
|
||||
} else if (platform === 'gemini') {
|
||||
endpoint = `/admin/gemini-accounts/${id}`
|
||||
} else if (platform === 'openai') {
|
||||
endpoint = `/admin/openai-accounts/${id}`
|
||||
} else if (platform === 'azure_openai') {
|
||||
endpoint = `/admin/azure-openai-accounts/${id}`
|
||||
} else {
|
||||
endpoint = `/admin/openai-accounts/${id}`
|
||||
}
|
||||
@@ -402,6 +475,10 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
await fetchBedrockAccounts()
|
||||
} else if (platform === 'gemini') {
|
||||
await fetchGeminiAccounts()
|
||||
} else if (platform === 'openai') {
|
||||
await fetchOpenAIAccounts()
|
||||
} else if (platform === 'azure_openai') {
|
||||
await fetchAzureOpenAIAccounts()
|
||||
} else {
|
||||
await fetchOpenAIAccounts()
|
||||
}
|
||||
@@ -580,6 +657,7 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
bedrockAccounts.value = []
|
||||
geminiAccounts.value = []
|
||||
openaiAccounts.value = []
|
||||
azureOpenaiAccounts.value = []
|
||||
loading.value = false
|
||||
error.value = null
|
||||
sortBy.value = ''
|
||||
@@ -593,6 +671,7 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
bedrockAccounts,
|
||||
geminiAccounts,
|
||||
openaiAccounts,
|
||||
azureOpenaiAccounts,
|
||||
loading,
|
||||
error,
|
||||
sortBy,
|
||||
@@ -604,17 +683,20 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
fetchBedrockAccounts,
|
||||
fetchGeminiAccounts,
|
||||
fetchOpenAIAccounts,
|
||||
fetchAzureOpenAIAccounts,
|
||||
fetchAllAccounts,
|
||||
createClaudeAccount,
|
||||
createClaudeConsoleAccount,
|
||||
createBedrockAccount,
|
||||
createGeminiAccount,
|
||||
createOpenAIAccount,
|
||||
createAzureOpenAIAccount,
|
||||
updateClaudeAccount,
|
||||
updateClaudeConsoleAccount,
|
||||
updateBedrockAccount,
|
||||
updateGeminiAccount,
|
||||
updateOpenAIAccount,
|
||||
updateAzureOpenAIAccount,
|
||||
toggleAccount,
|
||||
deleteAccount,
|
||||
refreshClaudeToken,
|
||||
|
||||
Reference in New Issue
Block a user