diff --git a/frontend/src/components/ApiKeyPanel.vue b/frontend/src/components/ApiKeyPanel.vue index 7e831da..61764f5 100644 --- a/frontend/src/components/ApiKeyPanel.vue +++ b/frontend/src/components/ApiKeyPanel.vue @@ -20,7 +20,7 @@ const createModalOpen = ref(false) const createLoading = ref(false) const createForm = reactive({ name: '', - expires_at: null as string | null, + expires_at: undefined as string | undefined, }) // Plain key modal @@ -50,7 +50,7 @@ const readonlyColumns = columns.filter((c) => c.key !== 'enabled' && c.key !== ' function showCreateModal() { createForm.name = '' - createForm.expires_at = null + createForm.expires_at = undefined createModalOpen.value = true } @@ -84,9 +84,10 @@ async function handleDelete(record: ApiKeyRecord) { } function handleCopyKey() { - navigator.clipboard.writeText(plainKey.value).then(() => { - message.success('已复制') - }) + navigator.clipboard.writeText(plainKey.value).then( + () => message.success('已复制'), + () => message.error('复制失败,请手动复制'), + ) } function handlePlainKeyModalClose() { @@ -97,6 +98,10 @@ function handlePlainKeyModalClose() { onMounted(() => { apiKeyStore.fetchMyKeys() }) + +onBeforeUnmount(() => { + plainKey.value = '' +})