apk包下载链接调整
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
CI / CI OK (push) Has been cancelled

This commit is contained in:
hahwu 2026-05-08 16:40:05 +08:00
parent f412003d8b
commit a6427daaab
2 changed files with 21 additions and 49 deletions

View File

@ -1,5 +1,5 @@
<script setup lang="ts">
import { Page } from '@vben/common-ui';
import { Page, VbenIcon } from '@vben/common-ui';
import { Button, Card, Space, Tag } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import type { VxeGridListeners, VxeGridProps } from '#/adapter/vxe-table';
@ -252,7 +252,7 @@ async function syncCfg(){
<div class="mb-5">
<Space>
<template v-for="value in activityList" :key="value">
<Tag color="green">{{ value }}</Tag>
<Tag color="green" class="asset-log-change-tag"> <VbenIcon icon="material-symbols:av-timer" class="mr-1" />{{ value }}</Tag>
</template>
</Space>
</div>
@ -272,8 +272,17 @@ async function syncCfg(){
结束时间 <span style="color: red">(UTC+8)</span>
</template>
<template #tag="{ row }">
<Tag :color=getTagColor(row.tag)>{{ row.tag }}</Tag>
<Tag :color=getTagColor(row.tag) class="asset-log-change-tag"> <VbenIcon icon="solar:user-id-bold" class="mr-1" />{{ row.tag }}</Tag>
</template>
</Grid>
</Page>
</template>
<style lang="css">
.asset-log-change-tag {
display: inline-flex;
align-items: center;
border-radius: 999px;
font-weight: 700;
}
</style>

View File

@ -1,6 +1,5 @@
<script setup lang="ts">
import { useAppConfig } from '@vben/hooks';
import { useAccessStore } from '@vben/stores';
import { Page } from '@vben/common-ui';
import { Button, Card, Empty, Space, Tag, TypographyParagraph, message } from 'ant-design-vue';
@ -11,7 +10,6 @@ import { getApkPackagesApi } from '#/api/core/apk';
import type { ApkApi } from '#/api/core/apk';
const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
const accessStore = useAccessStore();
const loading = ref(false);
const downloadingKey = ref('');
@ -69,29 +67,14 @@ function formatTime(value: string) {
}
function resolveDownloadUrl(item: ApkApi.PackageItem) {
const staticBaseUrl = apiURL.replace(/\/api\/?$/, '').replace(/\/$/, '');
if (item.downloadPath) {
return `${apiURL.replace(/\/$/, '')}${item.downloadPath}`;
if (/^https?:\/\//i.test(item.downloadPath)) {
return item.downloadPath;
}
return `${staticBaseUrl}${item.downloadPath}`;
}
return `${apiURL.replace(/\/$/, '')}/apk/download/${item.env}?packageType=${item.packageType}`;
}
function resolveDownloadName(item: ApkApi.PackageItem, disposition: null | string) {
const fallbackName = item.fileName || `${item.env}.apk`;
if (!disposition) {
return fallbackName;
}
const utf8Match = disposition.match(/filename\*=UTF-8''([^;]+)/i);
if (utf8Match?.[1]) {
return decodeURIComponent(utf8Match[1]);
}
const basicMatch = disposition.match(/filename="?([^";]+)"?/i);
if (basicMatch?.[1]) {
return decodeURIComponent(basicMatch[1]);
}
return fallbackName;
return `${staticBaseUrl}/apk-static/${item.env}/${item.packageType}/current.apk`;
}
async function downloadPackage(item: ApkApi.PackageItem) {
@ -99,36 +82,16 @@ async function downloadPackage(item: ApkApi.PackageItem) {
return;
}
if (!accessStore.accessToken) {
message.error('登录状态已失效,请重新登录后再试。');
return;
}
downloadingKey.value = `${item.env}:${item.packageType}`;
try {
const response = await fetch(resolveDownloadUrl(item), {
headers: {
Authorization: `Bearer ${accessStore.accessToken}`,
},
});
if (!response.ok) {
throw new Error('下载失败');
}
const blob = await response.blob();
const downloadName = resolveDownloadName(
item,
response.headers.get('content-disposition'),
);
const downloadUrl = window.URL.createObjectURL(blob);
const anchor = document.createElement('a');
anchor.href = downloadUrl;
const downloadName = item.fileName || `${item.env}.apk`;
anchor.href = resolveDownloadUrl(item);
anchor.download = downloadName;
anchor.rel = 'noopener';
document.body.appendChild(anchor);
anchor.click();
anchor.remove();
window.URL.revokeObjectURL(downloadUrl);
message.success(`开始下载 ${downloadName}`);
} catch (error) {
console.error(error);