fix(gateway): support claude_code cross-format Claude messages

This commit is contained in:
zhefox
2026-08-05 13:57:20 +08:00
parent 1aab31a148
commit 4d67569873
13 changed files with 349 additions and 46 deletions
+1 -1
View File
@@ -1530,7 +1530,7 @@ async function deleteApiKey() {
async function toggleApiKey(apiKey: ApiKey) {
try {
const updated = await meApi.toggleApiKey(apiKey.id)
const updated = await meApi.toggleApiKey(apiKey.id, !apiKey.is_active)
const index = apiKeys.value.findIndex(k => k.id === apiKey.id)
if (index !== -1) {
apiKeys.value[index].is_active = updated.is_active
@@ -224,4 +224,19 @@ describe('MyApiKeys CC Switch import', () => {
expect(meApiMock.getFullApiKey).not.toHaveBeenCalled()
expect(document.body.textContent).toContain('导入到 CC Switch')
})
it('sends the desired inactive state when disabling an active key', async () => {
meApiMock.getApiKeys.mockResolvedValue([apiKey()])
meApiMock.toggleApiKey.mockResolvedValue({
id: 'user-key-1',
is_active: false,
})
await mountMyApiKeys()
document.querySelector<HTMLButtonElement>('[title="禁用"]')?.click()
await flushPromises()
expect(meApiMock.toggleApiKey).toHaveBeenCalledWith('user-key-1', false)
expect(toastMock.success).toHaveBeenCalledWith('密钥已禁用')
})
})