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(
{{ uploadFile?.name ?? '选择插件包' }}
- {{ uploadFile ? formatFileSize(uploadFile.size) : 'tar.gz / tgz,最大 32 MiB' }}
+ {{ uploadFile ? formatPluginFileSize(uploadFile.size) : 'tar.gz / tgz,最大 32 MiB' }}
{{ uploadFile ? '更换' : '浏览文件' }}
- {{ release.name || release.tag }}
-
- {{ release.tag }}
-
+ 已找到版本
+ {{ release.tag }}
预发行版
-
-
+
+
{{ githubForm.asset || '此版本没有 tar.gz 或 tgz 插件包' }}
diff --git a/frontend/src/views/plugins/utils/model.ts b/frontend/src/views/plugins/utils/model.ts
index 72d906fef..9fbc85ae6 100644
--- a/frontend/src/views/plugins/utils/model.ts
+++ b/frontend/src/views/plugins/utils/model.ts
@@ -64,6 +64,14 @@ export function normalizePluginRepository(value: string) {
return value.trim().replace(/^https:\/\/github\.com\//i, '').replace(/\/$/, '').replace(/\.git$/i, '').toLowerCase()
}
+export function formatPluginFileSize(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`
+}
+
export function pluginContributionForCapability(
metadata: PluginArtifactMetadata,
capability: string,