refactor: 移除min_version/base_version_id,后端自动确定基础版本

This commit is contained in:
2026-05-08 23:17:53 +08:00
parent a39e994a2e
commit de0de10b8d
5 changed files with 19 additions and 75 deletions
@@ -47,7 +47,6 @@ const formData = ref({
update_method: 'manual' as 'manual' | 'hot' | 'full',
changelog: '',
entry_file: '',
base_version_id: '',
file: null as File | null,
})
@@ -96,7 +95,6 @@ async function fetchVersion() {
formData.value.description = ver.description || ''
formData.value.update_strategy = ver.update_strategy || 'optional'
formData.value.update_method = ver.update_method || 'manual'
formData.value.base_version_id = ver.base_version_id ? String(ver.base_version_id) : ''
formData.value.changelog = ver.changelog || ''
formData.value.entry_file = ver.entry_file || ''
}
+1 -56
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { CheckCircle, Eye, FileArchive, FilePlus, GitBranch, Loader2, Rocket, Upload, UploadCloud, X } from 'lucide-vue-next'
import { computed, onMounted, ref, watch } from 'vue'
import { computed, onMounted, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { useRoute, useRouter } from 'vue-router'
import { toast } from 'vue-sonner'
@@ -15,11 +15,6 @@ interface Application {
name: string
}
interface VersionOption {
id: number
version: string
}
interface VersionFileInfo {
file_path: string
file_name: string
@@ -42,7 +37,6 @@ const loading = ref(false)
const saving = ref(false)
const uploading = ref(false)
const applications = ref<Application[]>([])
const previousVersions = ref<VersionOption[]>([])
const formData = ref({
application_id: '',
@@ -52,7 +46,6 @@ const formData = ref({
update_method: 'manual' as 'manual' | 'hot' | 'full',
changelog: '',
entry_file: '',
base_version_id: '',
file: null as File | null,
})
@@ -119,21 +112,6 @@ async function fetchApplications() {
}
}
async function fetchPreviousVersions(appId: string) {
if (!appId)
return
try {
const params = new URLSearchParams()
params.append('application_id', appId)
params.append('page_size', '100')
const data = await api.get<{ versions: VersionOption[] }>(`/dev/versions?${params.toString()}`)
previousVersions.value = data?.versions || []
}
catch (error) {
console.error('获取历史版本失败:', error)
}
}
function handleFileSelect(event: Event) {
const target = event.target as HTMLInputElement
if (target.files && target.files.length > 0) {
@@ -203,7 +181,6 @@ async function handleSubmit() {
update_method: formData.value.update_method,
changelog: formData.value.changelog,
entry_file: formData.value.entry_file,
base_version_id: formData.value.base_version_id ? Number(formData.value.base_version_id) : null,
file_path: uploadedData.value.file_path,
file_size: uploadedData.value.file_size,
file_hash: uploadedData.value.file_hash,
@@ -223,14 +200,6 @@ async function handleSubmit() {
onMounted(() => {
fetchApplications()
})
watch(() => formData.value.application_id, (newAppId) => {
formData.value.base_version_id = ''
previousVersions.value = []
if (newAppId) {
fetchPreviousVersions(newAppId)
}
})
</script>
<template>
@@ -462,30 +431,6 @@ watch(() => formData.value.application_id, (newAppId) => {
</UiSelect>
</div>
<div class="space-y-2">
<UiLabel>{{ t('admin.versions.createForm.baseVersion') }}</UiLabel>
<UiSelect v-model="formData.base_version_id" :disabled="saving || !formData.application_id">
<UiSelectTrigger>
<UiSelectValue :placeholder="t('admin.versions.createForm.baseVersionPlaceholder')" />
</UiSelectTrigger>
<UiSelectContent>
<UiSelectItem value="__none__">
{{ t('admin.versions.createForm.noBaseVersion') }}
</UiSelectItem>
<UiSelectItem
v-for="ver in previousVersions"
:key="ver.id"
:value="String(ver.id)"
>
v{{ ver.version }}
</UiSelectItem>
</UiSelectContent>
</UiSelect>
<p class="text-xs text-muted-foreground">
{{ t('admin.versions.createForm.baseVersionDesc') }}
</p>
</div>
<div class="space-y-2">
<UiLabel for="changelog">
{{ t('admin.versions.createForm.changelog') }}
@@ -16,7 +16,6 @@ export const versionSchema = z.object({
update_strategy: updateStrategySchema,
update_method: updateMethodSchema,
status: versionStatusSchema,
base_version_id: z.number().nullable(),
changelog: z.string(),
created_at: z.string(),
updated_at: z.string(),