diff --git a/ui/src/components/COMPONENT_README.md b/ui/src/components/COMPONENT_README.md index c92401ae7ee..30657d83045 100644 --- a/ui/src/components/COMPONENT_README.md +++ b/ui/src/components/COMPONENT_README.md @@ -712,7 +712,10 @@ Model 配置器的默认模型也使用 `SelectModel`,仅展示已选的可选 启停成功后刷新,失败保留原状态。查询与列表操作共用 loading,编辑抽屉单独管理保存状态。 密钥默认隐藏,翻页或刷新恢复隐藏,复制始终使用完整值,隐藏状态不通过 Tooltip 暴露明文。 -`EditApiKeyDrawer` 是本功能内部抽屉,按永不过期、预设有效期或自定义日期编辑,预设有效期 +创建入口与结果 Dialog 封装在内部 `create-api-key/index.vue`(`ButtonCreateApiKey`),接收完整 API、 +可选 `applicationId`、共享 `v-model:loading` 和异步 `refresh` 回调;创建成功展示密钥,并等待列表回到第一页刷新后释放 loading。 +编辑入口与 Drawer 封装在内部 `edit-api-key/index.vue`(`ButtonEditApiKey`),接收完整 API、可选 `applicationId` +和当前 `record`,保存成功通过 `refresh` 事件通知列表。按永不过期、预设有效期或自定义日期编辑,预设有效期 从保存时起算;跨域地址逐行去空白后提交数组。保存失败保留草稿,成功刷新列表。 备注按 `remark` 预留,当前后端尚未持久化。Base URL 或 API 文档地址由调用方在列表外展示。 diff --git a/ui/src/components/business/api-key-list/create-api-key/index.vue b/ui/src/components/business/api-key-list/create-api-key/index.vue new file mode 100644 index 00000000000..18a73f47113 --- /dev/null +++ b/ui/src/components/business/api-key-list/create-api-key/index.vue @@ -0,0 +1,61 @@ + + + diff --git a/ui/src/components/business/api-key-list/EditApiKeyDrawer.vue b/ui/src/components/business/api-key-list/edit-api-key/index.vue similarity index 91% rename from ui/src/components/business/api-key-list/EditApiKeyDrawer.vue rename to ui/src/components/business/api-key-list/edit-api-key/index.vue index d6116b4a49a..c272a34265d 100644 --- a/ui/src/components/business/api-key-list/EditApiKeyDrawer.vue +++ b/ui/src/components/business/api-key-list/edit-api-key/index.vue @@ -5,17 +5,19 @@ import type { ApiKeyPayload, ApiKeyRecord } from '@/api/types' import type ApplicationApiKeyApi from '@/api/admin/workspace/application/api-key' import type SystemResourceApiKeyApi from '@/api/admin/system/resource-management/application/api-key' import type SystemApiKeyApi from '@/api/admin/system/api-key' -import { expirationOptions, getApiKeyExpireTime, type ExpirationType } from './expiration' +import { expirationOptions, getApiKeyExpireTime, type ExpirationType } from '../expiration' import { copyText } from '@/utils/clipboard' import { MsgSuccess } from '@/utils/message' -defineOptions({ name: 'EditApiKeyDrawer' }) +defineOptions({ name: 'ButtonEditApiKey' }) const props = defineProps<{ api: typeof ApplicationApiKeyApi | typeof SystemResourceApiKeyApi | typeof SystemApiKeyApi applicationId?: string + record: ApiKeyRecord }>() const emit = defineEmits<{ refresh: [] }>() +/* 编辑 API Key 与配置抽屉 */ const visible = ref(false) const saving = ref(false) const apiKeyId = ref('') @@ -54,10 +56,10 @@ const rules: FormRules = { trigger: 'change', }, ], - remark: [{ max: 256, message: '备注最多 256 个字符', trigger: 'blur' }], } -function open(record: ApiKeyRecord) { +function handleOpenEdit() { + const record = props.record apiKeyId.value = record.id Object.assign(form, { secret_key: record.secret_key, @@ -119,11 +121,15 @@ function handleClosed() { form.is_active = true formRef.value?.clearValidate() } - -defineExpose({ open })