From 00a1956df72cd488fb2e50abc531c406345c17fa Mon Sep 17 00:00:00 2001 From: Zyy Date: Fri, 25 Sep 2026 06:53:10 +0800 Subject: [PATCH] fix(plugins): clarify release asset selection Show release assets with filename tooltips, size tags, and a compact selection state. Remove duplicate release version labels. Co-authored-by: Codex --- .../plugins/components/PluginAssetPicker.vue | 118 ++++++++++++++++++ .../plugins/components/PluginInstallModal.vue | 33 ++--- frontend/src/views/plugins/utils/model.ts | 8 ++ 3 files changed, 136 insertions(+), 23 deletions(-) create mode 100644 frontend/src/views/plugins/components/PluginAssetPicker.vue diff --git a/frontend/src/views/plugins/components/PluginAssetPicker.vue b/frontend/src/views/plugins/components/PluginAssetPicker.vue new file mode 100644 index 000000000..8cc4fac65 --- /dev/null +++ b/frontend/src/views/plugins/components/PluginAssetPicker.vue @@ -0,0 +1,118 @@ + + + diff --git a/frontend/src/views/plugins/components/PluginInstallModal.vue b/frontend/src/views/plugins/components/PluginInstallModal.vue index 2a97edb00..3e9b6d224 100644 --- a/frontend/src/views/plugins/components/PluginInstallModal.vue +++ b/frontend/src/views/plugins/components/PluginInstallModal.vue @@ -13,14 +13,15 @@ import type { } from '@/api' import { Github } from '@boxicons/vue' -import { BaseButton, BaseCheckbox, BaseForm, BaseFormItem, BaseInput, BaseModal, BaseSegmented, BaseSelect, BaseTag, toast } from '@codex-proxy/ui' +import { BaseButton, BaseCheckbox, BaseForm, BaseFormItem, BaseInput, BaseModal, BaseSegmented, BaseTag, toast } from '@codex-proxy/ui' import { CheckCircle2, Download, FileArchive, Link, PackageOpen } from '@lucide/vue' import { useEventListener, useSessionStorage } from '@vueuse/core' import { isEqual } from 'es-toolkit' import { computed, nextTick, reactive, shallowRef, watch } from 'vue' import { formatDateTime } from '@/utils/date' -import { normalizePluginRepository, pluginInstallSelectionKey } from '../utils/model' +import { formatPluginFileSize, normalizePluginRepository, pluginInstallSelectionKey } from '../utils/model' +import PluginAssetPicker from './PluginAssetPicker.vue' import PluginDownloadAuthentication from './PluginDownloadAuthentication.vue' import PluginHelpPopover from './PluginHelpPopover.vue' import PluginPermissionSummary from './PluginPermissionSummary.vue' @@ -99,11 +100,7 @@ function changeMode(value: string) { return emit('changeMode', value) } -const assetOptions = computed(() => (props.release?.assets ?? []).filter(asset => /\.(?:tar\.gz|tgz)$/i.test(asset.name)).map(asset => ({ - label: `${asset.name} · ${formatFileSize(asset.size)}`, - value: asset.name, - description: asset.sha256 ? `SHA-256 ${asset.sha256}` : undefined, -}))) +const releaseAssets = computed(() => (props.release?.assets ?? []).filter(asset => /\.(?:tar\.gz|tgz)$/i.test(asset.name))) const digestPattern = /^[a-f0-9]{64}$/ const digestError = computed(() => { const digest = connectionForm.value.sha256.trim().toLowerCase() @@ -381,14 +378,6 @@ function githubQueryKey() { }) } -function formatFileSize(bytes: number) { - if (bytes < 1024) - return `${bytes} B` - if (bytes < 1024 * 1024) - return `${(bytes / 1024).toFixed(1)} KiB` - return `${(bytes / 1024 / 1024).toFixed(1)} MiB` -} - watch(open, (isOpen) => { if (isOpen) { reset() @@ -422,7 +411,7 @@ watch( () => props.release, async (release) => { // 唯一归档可直接解析,多个归档交给用户选择,平台兼容性仍由包检查器确认。 - githubForm.asset = release && assetOptions.value.length === 1 ? assetOptions.value[0]!.value : '' + githubForm.asset = release && releaseAssets.value.length === 1 ? releaseAssets.value[0]!.name : '' if (githubForm.asset) { await nextTick() await verifySelected() @@ -458,7 +447,7 @@ watch(