refactor: 移除 ModelsTab 单个删除按钮,简化表格样式

Close #119
This commit is contained in:
fawney19
2026-01-28 13:17:50 +08:00
parent e7fda0eadd
commit 5e81a0b581
2 changed files with 7 additions and 72 deletions

View File

@@ -403,7 +403,6 @@
:provider="provider" :provider="provider"
:endpoints="endpoints" :endpoints="endpoints"
@edit-model="handleEditModel" @edit-model="handleEditModel"
@delete-model="handleDeleteModel"
@batch-assign="handleBatchAssign" @batch-assign="handleBatchAssign"
/> />
@@ -480,20 +479,6 @@
@saved="handleModelSaved" @saved="handleModelSaved"
/> />
<!-- 删除模型确认对话框 -->
<AlertDialog
v-if="open"
:model-value="deleteModelConfirmOpen"
title="移除模型支持"
:description="`确定要移除提供商 ${provider?.name} 对模型 ${modelToDelete?.global_model_display_name || modelToDelete?.provider_model_name} 的支持吗?这不会删除全局模型,只是该提供商将不再支持此模型。`"
confirm-text="移除"
cancel-text="取消"
type="danger"
@update:model-value="deleteModelConfirmOpen = $event"
@confirm="confirmDeleteModel"
@cancel="deleteModelConfirmOpen = false"
/>
<!-- 批量关联模型对话框 --> <!-- 批量关联模型对话框 -->
<BatchAssignModelsDialog <BatchAssignModelsDialog
v-if="open && provider" v-if="open && provider"
@@ -551,7 +536,6 @@ import {
API_FORMAT_SHORT, API_FORMAT_SHORT,
sortApiFormats, sortApiFormats,
} from '@/api/endpoints' } from '@/api/endpoints'
import { deleteModel as deleteModelAPI } from '@/api/endpoints/models'
// 扩展端点类型,包含密钥列表 // 扩展端点类型,包含密钥列表
interface ProviderEndpointWithKeys extends ProviderEndpoint { interface ProviderEndpointWithKeys extends ProviderEndpoint {
@@ -599,8 +583,6 @@ const revealedKeys = ref<Map<string, string>>(new Map())
// 模型相关状态 // 模型相关状态
const modelFormDialogOpen = ref(false) const modelFormDialogOpen = ref(false)
const editingModel = ref<Model | null>(null) const editingModel = ref<Model | null>(null)
const deleteModelConfirmOpen = ref(false)
const modelToDelete = ref<Model | null>(null)
const batchAssignDialogOpen = ref(false) const batchAssignDialogOpen = ref(false)
const modelsTabRef = ref<InstanceType<typeof ModelsTab> | null>(null) const modelsTabRef = ref<InstanceType<typeof ModelsTab> | null>(null)
const modelMappingTabRef = ref<InstanceType<typeof ModelMappingTab> | null>(null) const modelMappingTabRef = ref<InstanceType<typeof ModelMappingTab> | null>(null)
@@ -632,7 +614,6 @@ const hasBlockingDialogOpen = computed(() =>
keyPermissionsDialogOpen.value || keyPermissionsDialogOpen.value ||
deleteKeyConfirmOpen.value || deleteKeyConfirmOpen.value ||
modelFormDialogOpen.value || modelFormDialogOpen.value ||
deleteModelConfirmOpen.value ||
batchAssignDialogOpen.value || batchAssignDialogOpen.value ||
modelMappingTabRef.value?.dialogOpen modelMappingTabRef.value?.dialogOpen
) )
@@ -876,29 +857,6 @@ async function handleModelSaved() {
emit('refresh') emit('refresh')
} }
// 处理删除模型 - 打开确认对话框
function handleDeleteModel(model: Model) {
modelToDelete.value = model
deleteModelConfirmOpen.value = true
}
// 确认删除模型
async function confirmDeleteModel() {
if (!provider.value || !modelToDelete.value) return
try {
await deleteModelAPI(provider.value.id, modelToDelete.value.id)
showSuccess('已移除该提供商对此模型的支持')
deleteModelConfirmOpen.value = false
modelToDelete.value = null
// 重新加载 Provider 数据以刷新模型列表
await loadProvider()
emit('refresh')
} catch (err: any) {
showError(err.response?.data?.detail || '删除失败', '错误')
}
}
// ===== 点击编辑优先级 ===== // ===== 点击编辑优先级 =====
function startEditPriority(key: EndpointAPIKey) { function startEditPriority(key: EndpointAPIKey) {
editingPriorityKey.value = key.id editingPriorityKey.value = key.id

View File

@@ -32,19 +32,11 @@
class="overflow-hidden" class="overflow-hidden"
> >
<table class="w-full text-sm table-fixed"> <table class="w-full text-sm table-fixed">
<thead class="bg-muted/50 text-xs uppercase tracking-wide text-muted-foreground"> <colgroup>
<tr> <col class="w-[45%]">
<th class="text-left px-4 py-3 font-semibold w-[45%]"> <col class="w-[30%]">
模型 <col class="w-[25%]">
</th> </colgroup>
<th class="text-left px-4 py-3 font-semibold w-[30%]">
价格 ($/M)
</th>
<th class="text-center px-4 py-3 font-semibold w-[25%]">
操作
</th>
</tr>
</thead>
<tbody> <tbody>
<tr <tr
v-for="model in sortedModels" v-for="model in sortedModels"
@@ -118,7 +110,7 @@
</div> </div>
</td> </td>
<td class="align-top px-4 py-3"> <td class="align-top px-4 py-3">
<div class="flex justify-center gap-1"> <div class="flex justify-end gap-1">
<!-- 测试按钮支持多格式选择 --> <!-- 测试按钮支持多格式选择 -->
<DropdownMenu <DropdownMenu
v-if="availableApiFormats.length > 1" v-if="availableApiFormats.length > 1"
@@ -189,15 +181,6 @@
> >
<Power class="w-3.5 h-3.5" /> <Power class="w-3.5 h-3.5" />
</Button> </Button>
<Button
variant="ghost"
size="icon"
class="h-8 w-8 hover:text-destructive"
title="删除"
@click="deleteModel(model)"
>
<Trash2 class="w-3.5 h-3.5" />
</Button>
</div> </div>
</td> </td>
</tr> </tr>
@@ -223,7 +206,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, computed, onMounted } from 'vue' import { ref, computed, onMounted } from 'vue'
import { Box, Edit, Trash2, Layers, Power, Copy, Loader2, Play } from 'lucide-vue-next' import { Box, Edit, Layers, Power, Copy, Loader2, Play } from 'lucide-vue-next'
import Card from '@/components/ui/card.vue' import Card from '@/components/ui/card.vue'
import Button from '@/components/ui/button.vue' import Button from '@/components/ui/button.vue'
import { import {
@@ -258,7 +241,6 @@ const props = defineProps<{
const emit = defineEmits<{ const emit = defineEmits<{
'editModel': [model: Model] 'editModel': [model: Model]
'deleteModel': [model: Model]
'batchAssign': [] 'batchAssign': []
}>() }>()
@@ -393,11 +375,6 @@ function editModel(model: Model) {
emit('editModel', model) emit('editModel', model)
} }
// 删除模型
function deleteModel(model: Model) {
emit('deleteModel', model)
}
// 打开批量关联对话框 // 打开批量关联对话框
function openBatchAssignDialog() { function openBatchAssignDialog() {
emit('batchAssign') emit('batchAssign')