remove dead proxy service and sora storage action
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
/**
|
||||
* Admin Sora API
|
||||
* 管理员 Sora 统计和用户配额管理接口
|
||||
*/
|
||||
|
||||
import { apiClient } from '../client'
|
||||
@@ -46,17 +45,11 @@ export interface SoraGenerationAdmin {
|
||||
}
|
||||
|
||||
const soraAdminAPI = {
|
||||
/**
|
||||
* 获取 Sora 系统统计
|
||||
*/
|
||||
async getSystemStats(): Promise<SoraSystemStats> {
|
||||
const { data } = await apiClient.get<{ data: SoraSystemStats }>('/admin/sora/stats')
|
||||
return data.data
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取用户 Sora 使用统计列表
|
||||
*/
|
||||
async listUserStats(params?: {
|
||||
page?: number
|
||||
page_size?: number
|
||||
@@ -68,9 +61,6 @@ const soraAdminAPI = {
|
||||
return data
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取 Sora 生成记录列表(管理员视角)
|
||||
*/
|
||||
async listGenerations(params?: {
|
||||
page?: number
|
||||
page_size?: number
|
||||
@@ -82,14 +72,7 @@ const soraAdminAPI = {
|
||||
}): Promise<BasePaginationResponse<SoraGenerationAdmin>> {
|
||||
const { data } = await apiClient.get<BasePaginationResponse<SoraGenerationAdmin>>('/admin/sora/generations', { params })
|
||||
return data
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除用户的 Sora 存储空间(管理员操作)
|
||||
*/
|
||||
async clearUserStorage(userId: number): Promise<void> {
|
||||
await apiClient.delete(`/admin/sora/users/${userId}/storage`)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default soraAdminAPI
|
||||
|
||||
@@ -5,7 +5,6 @@ import soraAdminAPI, { type SoraSystemStats, type SoraUserStats, type SoraGenera
|
||||
import AppLayout from '@/components/layout/AppLayout.vue'
|
||||
import LoadingSpinner from '@/components/common/LoadingSpinner.vue'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
import ConfirmDialog from '@/components/common/ConfirmDialog.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
@@ -16,11 +15,6 @@ const userStats = ref<SoraUserStats[]>([])
|
||||
const generations = ref<SoraGenerationAdmin[]>([])
|
||||
const activeTab = ref<'overview' | 'users' | 'generations'>('overview')
|
||||
|
||||
// Confirm dialog state
|
||||
const showConfirmDialog = ref(false)
|
||||
const confirmDialogMessage = ref('')
|
||||
const pendingClearUserId = ref<number | null>(null)
|
||||
|
||||
// Pagination
|
||||
const userPage = ref(1)
|
||||
const userPageSize = ref(20)
|
||||
@@ -102,33 +96,6 @@ async function fetchGenerations() {
|
||||
}
|
||||
}
|
||||
|
||||
// Confirm dialog handlers
|
||||
function confirmClearStorage(userId: number) {
|
||||
pendingClearUserId.value = userId
|
||||
confirmDialogMessage.value = t('admin.sora.confirmClearStorage')
|
||||
showConfirmDialog.value = true
|
||||
}
|
||||
|
||||
async function handleConfirmClear() {
|
||||
if (pendingClearUserId.value === null) return
|
||||
const userId = pendingClearUserId.value
|
||||
showConfirmDialog.value = false
|
||||
pendingClearUserId.value = null
|
||||
|
||||
try {
|
||||
await soraAdminAPI.clearUserStorage(userId)
|
||||
await fetchUserStats()
|
||||
} catch (err) {
|
||||
console.error('Failed to clear user storage:', err)
|
||||
alert(t('common.error'))
|
||||
}
|
||||
}
|
||||
|
||||
function handleCancelClear() {
|
||||
showConfirmDialog.value = false
|
||||
pendingClearUserId.value = null
|
||||
}
|
||||
|
||||
async function loadAll() {
|
||||
loading.value = true
|
||||
await Promise.all([
|
||||
@@ -359,14 +326,7 @@ onMounted(loadAll)
|
||||
<td class="px-4 py-3 text-sm text-gray-900 dark:text-white">{{ formatBytes(user.quota_bytes) }}</td>
|
||||
<td class="px-4 py-3 text-sm text-gray-900 dark:text-white">{{ formatBytes(user.used_bytes) }}</td>
|
||||
<td class="px-4 py-3 text-sm text-gray-900 dark:text-white">{{ user.generations_count }}</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<button
|
||||
class="btn btn-danger btn-sm"
|
||||
@click="confirmClearStorage(user.user_id)"
|
||||
>
|
||||
{{ t('admin.sora.clearStorage') }}
|
||||
</button>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm text-gray-500 dark:text-gray-400">-</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -453,15 +413,5 @@ onMounted(loadAll)
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- Confirm Dialog -->
|
||||
<ConfirmDialog
|
||||
:show="showConfirmDialog"
|
||||
:title="t('admin.sora.clearStorage')"
|
||||
:message="confirmDialogMessage"
|
||||
:danger="true"
|
||||
@confirm="handleConfirmClear"
|
||||
@cancel="handleCancelClear"
|
||||
/>
|
||||
</AppLayout>
|
||||
</template>
|
||||
|
||||
@@ -8,21 +8,18 @@ import type { SoraSystemStats, SoraUserStats, SoraGenerationAdmin } from '@/api/
|
||||
const {
|
||||
mockGetSystemStats,
|
||||
mockListUserStats,
|
||||
mockListGenerations,
|
||||
mockClearUserStorage
|
||||
mockListGenerations
|
||||
} = vi.hoisted(() => ({
|
||||
mockGetSystemStats: vi.fn(),
|
||||
mockListUserStats: vi.fn(),
|
||||
mockListGenerations: vi.fn(),
|
||||
mockClearUserStorage: vi.fn()
|
||||
mockListGenerations: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('@/api/admin/sora', () => ({
|
||||
default: {
|
||||
getSystemStats: mockGetSystemStats,
|
||||
listUserStats: mockListUserStats,
|
||||
listGenerations: mockListGenerations,
|
||||
clearUserStorage: mockClearUserStorage
|
||||
listGenerations: mockListGenerations
|
||||
}
|
||||
}))
|
||||
|
||||
@@ -209,6 +206,18 @@ describe('SoraAdminView', () => {
|
||||
expect(wrapper.text()).toContain('user1')
|
||||
expect(wrapper.text()).toContain('user1@example.com')
|
||||
})
|
||||
|
||||
it('does not render the deprecated clear storage action', async () => {
|
||||
const wrapper = mountComponent()
|
||||
await flushPromises()
|
||||
|
||||
const tabs = wrapper.findAll('button')
|
||||
const userTab = tabs.find(b => b.text().includes('admin.sora.userStats'))
|
||||
await userTab?.trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
expect(wrapper.text()).not.toContain('admin.sora.clearStorage')
|
||||
})
|
||||
})
|
||||
|
||||
describe('生成记录标签页', () => {
|
||||
|
||||
Reference in New Issue
Block a user