Commit 7e2b7cfc by pangchong

style(api): 优化条件判断提升代码可读性

- 合并多行的contentType判断条件为一行
- 避免不必要的多行缩进和换行

style(components): 精简模板和代码格式

- 将CommonCheckboxSingle标签内容内联,减少多余换行
- 简化computedChecked计算属性的条件表达式
- 统一CommonCheckboxSingle的插槽写法,增加可读性
parent 2e5e0bef
......@@ -60,11 +60,7 @@ const createService = (baseURL: string) => {
}
return json
}
} else if (
contentType.includes('xml') ||
contentType.includes('text/html') ||
contentType.includes('text/plain')
) {
} else if (contentType.includes('xml') || contentType.includes('text/html') || contentType.includes('text/plain')) {
return await response.text()
} else {
const isBinary =
......
<template>
<n-checkbox
:checked="computedChecked"
:disabled="disabled"
:indeterminate="indeterminate"
v-bind="$attrs"
@update:checked="handleUpdateChecked"
>
<n-checkbox :checked="computedChecked" :disabled="disabled" :indeterminate="indeterminate" v-bind="$attrs" @update:checked="handleUpdateChecked">
<slot>{{ label }}</slot>
</n-checkbox>
</template>
......@@ -74,9 +68,7 @@ const normalizeValue = (v: any) => {
*/
const computedChecked = computed(() => {
// 依次判断绑定的属性
const val = props.modelValue !== undefined
? props.modelValue
: (props.value !== undefined ? props.value : props.checked)
const val = props.modelValue !== undefined ? props.modelValue : props.value !== undefined ? props.value : props.checked
if (val === undefined || val === null) {
return false
......
......@@ -31,7 +31,9 @@
<n-icon><checkmark-circle-outline /></n-icon>
可安全删除的节点 ({{ safeNodes.length }} 个):
</span>
<CommonCheckboxSingle :checked="isAllChecked" :indeterminate="isIndeterminate" @update:checked="toggleCheckAll">全选</CommonCheckboxSingle>
<CommonCheckboxSingle :checked="isAllChecked" :indeterminate="isIndeterminate" @update:checked="toggleCheckAll">
全选
</CommonCheckboxSingle>
</div>
<CommonNodeDetailList
:items="formattedSafeNodes"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment