Commit 7e2b7cfc by pangchong

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

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

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

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