mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 23:49:19 +08:00
feat: 添加浏览器扩展下载功能
This commit is contained in:
@@ -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 }">
|
||||
|
||||
Reference in New Issue
Block a user