refactor(components): 优化瀑布流布局和日期选择组件

-移除了瀑布流布局组件中的冗余注释和代码
-优化了日期选择组件的结构,删除了不必要的注释和空行
- 提高了代码的可读性和维护性
This commit is contained in:
xingyy 2025-02-17 10:14:12 +08:00
parent 2f8eb36a52
commit 0e80600f51
2 changed files with 0 additions and 12 deletions

View File

@ -11,7 +11,6 @@
:key="item.id"
class="waterfall-item"
>
<!-- 默认插槽传入当前item数据 -->
<slot :item="item">
</slot>
</div>
@ -35,19 +34,15 @@ const props = defineProps({
const columns = ref([])
//
const calculateColumns = () => {
const cols = Array.from({ length: props.columnCount }, () => [])
props.items.forEach((item, index) => {
//
const columnIndex = index % props.columnCount
cols[columnIndex].push(item)
})
columns.value = cols
}
// items
watch(() => props.items, () => {
calculateColumns()
}, { deep: true })

View File

@ -1,7 +1,6 @@
<script setup>
import {ref, computed} from 'vue'
import dayjs from 'dayjs'
const props = defineProps({
modelValue: {
type: [Date, String, Number]
@ -39,7 +38,6 @@ const props = defineProps({
const emit = defineEmits(['update:modelValue', 'change'])
const show = ref(false)
//
const defaultValue = computed(() => {
let date
if (props.modelValue) {
@ -48,7 +46,6 @@ const defaultValue = computed(() => {
date = dayjs()
}
//
if (!date.isValid()) {
date = dayjs()
}
@ -60,20 +57,17 @@ const defaultValue = computed(() => {
]
})
//
const formatDate = (dateArr) => {
const [year, month, day] = dateArr
return dayjs(`${year}-${month}-${day}`).format(props.format)
}
//
const displayValue = computed(() => {
if (!props.modelValue) return ''
const date = dayjs(props.modelValue)
return date.isValid() ? date.format(props.format) : ''
})
//
const onConfirm = ({selectedValues}) => {
show.value = false
const formattedDate = formatDate(selectedValues)
@ -81,7 +75,6 @@ const onConfirm = ({selectedValues}) => {
emit('change', formattedDate)
}
//
const onCancel = () => {
show.value = false
}