fix: Switch组件必须使用v-model而非:checked+@update:checked

This commit is contained in:
2026-05-08 21:45:14 +08:00
parent 426290e299
commit 221f3de9c7
3 changed files with 125 additions and 302 deletions
+8 -2
View File
@@ -71,6 +71,13 @@ const fileSize = computed(() => {
return null
})
const isForcedUpdate = computed({
get: () => formData.value.update_strategy === 'forced',
set: (val: boolean) => {
formData.value.update_strategy = val ? 'forced' : 'optional'
},
})
function formatFileSize(size: number): string {
if (size < 1024)
return `${size} B`
@@ -413,9 +420,8 @@ onMounted(() => {
</p>
</div>
<UiSwitch
:checked="formData.update_strategy === 'forced'"
v-model="isForcedUpdate"
:disabled="saving"
@update:checked="formData.update_strategy = $event ? 'forced' : 'optional'"
/>
</div>
+8 -2
View File
@@ -77,6 +77,13 @@ const fileSize = computed(() => {
return null
})
const isForcedUpdate = computed({
get: () => formData.value.update_strategy === 'forced',
set: (val: boolean) => {
formData.value.update_strategy = val ? 'forced' : 'optional'
},
})
function formatFileSize(size: number): string {
if (size < 1024)
return `${size} B`
@@ -430,9 +437,8 @@ watch(() => formData.value.application_id, (newAppId) => {
</p>
</div>
<UiSwitch
:checked="formData.update_strategy === 'forced'"
v-model="isForcedUpdate"
:disabled="saving"
@update:checked="formData.update_strategy = $event ? 'forced' : 'optional'"
/>
</div>