feat: 添加浏览器扩展下载功能

This commit is contained in:
2026-08-30 23:32:26 +08:00
parent 7fcb9abf69
commit c5de3499c0
15 changed files with 293 additions and 74 deletions
@@ -15,12 +15,15 @@ import {
disableOpenApiKeyApi,
enableOpenApiKeyApi,
getOpenApiKeyListApi,
OPEN_EXTENSION_DOWNLOAD_PATH,
OPEN_EXTENSION_ZIP_NAME,
} from '#/api/open/api-key';
import { PermissionGate } from '#/components/permission';
import {
syncVxeGridColumns,
useActionColumnVisible,
} from '#/composables/use-vxe-action-column';
import { exportByGet } from '#/utils/export';
import CreateApiKeyModal from './components/CreateApiKeyModal.vue';
import OpenApiBaseUrlDisplay from './components/OpenApiBaseUrlDisplay.vue';
@@ -28,7 +31,9 @@ import OpenApiBaseUrlDisplay from './components/OpenApiBaseUrlDisplay.vue';
defineOptions({ name: 'OpenApiKeyManagement' });
const PlusIcon = createIconifyIcon('lucide:plus');
const DownloadIcon = createIconifyIcon('lucide:download');
const loading = ref(false);
const downloading = ref(false);
const createModalRef = ref<InstanceType<typeof CreateApiKeyModal>>();
function formatExpireAt(cellValue?: null | string) {
@@ -139,6 +144,16 @@ function openCreateModal() {
createModalRef.value?.open();
}
async function handleDownloadExtension() {
if (downloading.value) return;
downloading.value = true;
try {
await exportByGet(OPEN_EXTENSION_DOWNLOAD_PATH, OPEN_EXTENSION_ZIP_NAME);
} finally {
downloading.value = false;
}
}
function getPermissionCount(row: OpenApiKeyVO.OpenApiKeyInfoVO) {
return row.permissionCodes?.length ?? row.permissions?.length ?? 0;
}
@@ -157,12 +172,20 @@ function getPermissionTooltip(row: OpenApiKeyVO.OpenApiKeyInfoVO) {
<Grid :loading="loading">
<template #toolbar-tools>
<PermissionGate code="open:api-key:create">
<Button type="primary" @click="openCreateModal">
<PlusIcon class="size-4" />
创建 API Key
</Button>
</PermissionGate>
<Space>
<PermissionGate code="open:api-key:read">
<Button :loading="downloading" @click="handleDownloadExtension">
<DownloadIcon class="size-4" />
下载浏览器扩展
</Button>
</PermissionGate>
<PermissionGate code="open:api-key:create">
<Button type="primary" @click="openCreateModal">
<PlusIcon class="size-4" />
创建 API Key
</Button>
</PermissionGate>
</Space>
</template>
<template #permissions="{ row }">