fix(admin): 修复零值字段无法保存的问题
- 用户允许分组:前端发送空数组而非 null 表示"允许全部" - 账户代理:前端发送 0 而非 null 表示"无代理" - 后端 UpdateAccount/BulkUpdate 正确处理 ProxyID=0 为清除代理
This commit is contained in:
@@ -52,7 +52,7 @@ const load = async () => { loading.value = true; try { const res = await adminAP
|
||||
const handleSave = async () => {
|
||||
if (!props.user) return; submitting.value = true
|
||||
try {
|
||||
await adminAPI.users.update(props.user.id, { allowed_groups: selectedIds.value.length > 0 ? selectedIds.value : null })
|
||||
await adminAPI.users.update(props.user.id, { allowed_groups: selectedIds.value })
|
||||
appStore.showSuccess(t('admin.users.allowedGroupsUpdated')); emit('success'); emit('close')
|
||||
} catch {} finally { submitting.value = false }
|
||||
}
|
||||
|
||||
@@ -98,11 +98,11 @@
|
||||
<!-- No Proxy option -->
|
||||
<div
|
||||
@click="selectOption(null)"
|
||||
:class="['select-option', modelValue === null && 'select-option-selected']"
|
||||
:class="['select-option', (modelValue === null || modelValue === 0) && 'select-option-selected']"
|
||||
>
|
||||
<span class="select-option-label">{{ t('admin.accounts.noProxy') }}</span>
|
||||
<svg
|
||||
v-if="modelValue === null"
|
||||
v-if="modelValue === null || modelValue === 0"
|
||||
class="h-4 w-4 text-primary-500"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
@@ -265,7 +265,7 @@ const testingProxyIds = reactive(new Set<number>())
|
||||
const batchTesting = ref(false)
|
||||
|
||||
const selectedProxy = computed(() => {
|
||||
if (props.modelValue === null) return null
|
||||
if (props.modelValue === null || props.modelValue === 0) return null
|
||||
return props.proxies.find((p) => p.id === props.modelValue) || null
|
||||
})
|
||||
|
||||
@@ -300,7 +300,8 @@ const toggle = () => {
|
||||
}
|
||||
|
||||
const selectOption = (value: number | null) => {
|
||||
emit('update:modelValue', value)
|
||||
// 使用 0 表示"无代理",以便后端能正确识别清除意图
|
||||
emit('update:modelValue', value === null ? 0 : value)
|
||||
isOpen.value = false
|
||||
searchQuery.value = ''
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user