feat(ui): 优化密钥添加和仪表盘空状态体验

- KeyFormDialog: 添加模式下保存后不关闭对话框,清除表单以便连续添加
- KeyFormDialog: 按钮文案根据编辑/添加模式动态显示
- Dashboard: 优化统计卡片加载状态和空数据占位显示
This commit is contained in:
fawney19
2026-01-10 19:32:36 +08:00
parent ad84272084
commit 7faca5512a
2 changed files with 121 additions and 54 deletions

View File

@@ -232,7 +232,7 @@
:disabled="saving"
@click="handleSave"
>
{{ saving ? '保存中...' : '保存' }}
{{ saving ? (isEditMode ? '保存中...' : '添加中...') : (isEditMode ? '保存' : '添加') }}
</Button>
</template>
</Dialog>
@@ -408,6 +408,14 @@ function resetForm() {
}
}
// 添加成功后清除部分字段以便继续添加
function clearForNextAdd() {
formNonce.value = createFieldNonce()
apiKeyFocused.value = false
form.value.name = ''
form.value.api_key = ''
}
// 加载密钥数据(编辑模式)
function loadKeyData() {
if (!props.editingKey) return
@@ -530,6 +538,10 @@ async function handleSave() {
capabilities: capabilitiesData || undefined
})
success('密钥已添加', '成功')
// 添加模式:不关闭对话框,只清除名称和密钥以便继续添加
emit('saved')
clearForNextAdd()
return
}
emit('saved')